提交 a1ccb4ad 编写于 作者: T Tony Luck 提交者: Xie XiuQi

acpi/nfit: Fix race accessing memdev in nfit_get_smbios_id()

mainline inclusion
from mainline-5.0
commit 0919871ac37f
category: bugfix
bugzilla: 7088
CVE: NA

-------------------------------------------------

Possible race accessing memdev structures after dropping the
mutex. Dan Williams says this could race against another thread
that is doing:

 # echo "ACPI0012:00" > /sys/bus/acpi/drivers/nfit/unbind
Reported-by: NJane Chu <jane.chu@oracle.com>
Fixes: 23222f8f ("acpi, nfit: Add function to look up nvdimm...")
Signed-off-by: NTony Luck <tony.luck@intel.com>
Signed-off-by: NDan Williams <dan.j.williams@intel.com>
Signed-off-by: NHanjun Guo <guohanjun@huawei.com>
Reviewed-by: NXiongfeng Wang <wangxiongfeng2@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 7b6b7862
...@@ -719,6 +719,7 @@ int nfit_get_smbios_id(u32 device_handle, u16 *flags) ...@@ -719,6 +719,7 @@ int nfit_get_smbios_id(u32 device_handle, u16 *flags)
struct acpi_nfit_memory_map *memdev; struct acpi_nfit_memory_map *memdev;
struct acpi_nfit_desc *acpi_desc; struct acpi_nfit_desc *acpi_desc;
struct nfit_mem *nfit_mem; struct nfit_mem *nfit_mem;
u16 physical_id;
mutex_lock(&acpi_desc_lock); mutex_lock(&acpi_desc_lock);
list_for_each_entry(acpi_desc, &acpi_descs, list) { list_for_each_entry(acpi_desc, &acpi_descs, list) {
...@@ -726,10 +727,11 @@ int nfit_get_smbios_id(u32 device_handle, u16 *flags) ...@@ -726,10 +727,11 @@ int nfit_get_smbios_id(u32 device_handle, u16 *flags)
list_for_each_entry(nfit_mem, &acpi_desc->dimms, list) { list_for_each_entry(nfit_mem, &acpi_desc->dimms, list) {
memdev = __to_nfit_memdev(nfit_mem); memdev = __to_nfit_memdev(nfit_mem);
if (memdev->device_handle == device_handle) { if (memdev->device_handle == device_handle) {
*flags = memdev->flags;
physical_id = memdev->physical_id;
mutex_unlock(&acpi_desc->init_mutex); mutex_unlock(&acpi_desc->init_mutex);
mutex_unlock(&acpi_desc_lock); mutex_unlock(&acpi_desc_lock);
*flags = memdev->flags; return physical_id;
return memdev->physical_id;
} }
} }
mutex_unlock(&acpi_desc->init_mutex); mutex_unlock(&acpi_desc->init_mutex);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册