mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-07 22:34:18 +08:00
scsi: target: tcmu: Fix possible page UAF
[ Upstream commit a6968f7a36
]
tcmu_try_get_data_page() looks up pages under cmdr_lock, but it does not
take refcount properly and just returns page pointer. When
tcmu_try_get_data_page() returns, the returned page may have been freed by
tcmu_blocks_release().
We need to get_page() under cmdr_lock to avoid concurrent
tcmu_blocks_release().
Link: https://lore.kernel.org/r/20220311132206.24515-1-xiaoguang.wang@linux.alibaba.com
Reviewed-by: Bodo Stroesser <bostroesser@gmail.com>
Signed-off-by: Xiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
44f95a5aae
commit
b7f3b5d70c
@ -1821,6 +1821,7 @@ static struct page *tcmu_try_get_data_page(struct tcmu_dev *udev, uint32_t dpi)
|
|||||||
mutex_lock(&udev->cmdr_lock);
|
mutex_lock(&udev->cmdr_lock);
|
||||||
page = xa_load(&udev->data_pages, dpi);
|
page = xa_load(&udev->data_pages, dpi);
|
||||||
if (likely(page)) {
|
if (likely(page)) {
|
||||||
|
get_page(page);
|
||||||
mutex_unlock(&udev->cmdr_lock);
|
mutex_unlock(&udev->cmdr_lock);
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
@ -1877,6 +1878,7 @@ static vm_fault_t tcmu_vma_fault(struct vm_fault *vmf)
|
|||||||
/* For the vmalloc()ed cmd area pages */
|
/* For the vmalloc()ed cmd area pages */
|
||||||
addr = (void *)(unsigned long)info->mem[mi].addr + offset;
|
addr = (void *)(unsigned long)info->mem[mi].addr + offset;
|
||||||
page = vmalloc_to_page(addr);
|
page = vmalloc_to_page(addr);
|
||||||
|
get_page(page);
|
||||||
} else {
|
} else {
|
||||||
uint32_t dpi;
|
uint32_t dpi;
|
||||||
|
|
||||||
@ -1887,7 +1889,6 @@ static vm_fault_t tcmu_vma_fault(struct vm_fault *vmf)
|
|||||||
return VM_FAULT_SIGBUS;
|
return VM_FAULT_SIGBUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
get_page(page);
|
|
||||||
vmf->page = page;
|
vmf->page = page;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user