From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Xiaoguang Wang <xiaoguang.wang@linux.alibaba.com>,
Bodo Stroesser <bostroesser@gmail.com>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
Sasha Levin <sashal@kernel.org>,
linux-scsi@vger.kernel.org, target-devel@vger.kernel.org
Subject: [PATCH AUTOSEL 4.14 04/11] scsi: target: tcmu: Fix possible page UAF
Date: Mon, 11 Apr 2022 20:52:13 -0400 [thread overview]
Message-ID: <20220412005222.351554-4-sashal@kernel.org> (raw)
In-Reply-To: <20220412005222.351554-1-sashal@kernel.org>
From: Xiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
[ Upstream commit a6968f7a367f128d120447360734344d5a3d5336 ]
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>
---
drivers/target/target_core_user.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index 96601fda47b1..f687481ccfdc 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1165,6 +1165,7 @@ static struct page *tcmu_try_get_block_page(struct tcmu_dev *udev, uint32_t dbi)
mutex_lock(&udev->cmdr_lock);
page = tcmu_get_block_page(udev, dbi);
if (likely(page)) {
+ get_page(page);
mutex_unlock(&udev->cmdr_lock);
return page;
}
@@ -1233,6 +1234,7 @@ static int tcmu_vma_fault(struct vm_fault *vmf)
/* For the vmalloc()ed cmd area pages */
addr = (void *)(unsigned long)info->mem[mi].addr + offset;
page = vmalloc_to_page(addr);
+ get_page(page);
} else {
uint32_t dbi;
@@ -1243,7 +1245,6 @@ static int tcmu_vma_fault(struct vm_fault *vmf)
return VM_FAULT_NOPAGE;
}
- get_page(page);
vmf->page = page;
return 0;
}
--
2.35.1
next prev parent reply other threads:[~2022-04-12 1:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-12 0:52 [PATCH AUTOSEL 4.14 01/11] drm/amd: Add USBC connector ID Sasha Levin
2022-04-12 0:52 ` [PATCH AUTOSEL 4.14 02/11] drm/amdkfd: Check for potential null return of kmalloc_array() Sasha Levin
2022-04-12 0:52 ` [PATCH AUTOSEL 4.14 03/11] Drivers: hv: vmbus: Prevent load re-ordering when reading ring buffer Sasha Levin
2022-04-12 0:52 ` Sasha Levin [this message]
2022-04-12 0:52 ` [PATCH AUTOSEL 4.14 05/11] scsi: ibmvscsis: Increase INITIAL_SRP_LIMIT to 1024 Sasha Levin
2022-04-12 0:52 ` [PATCH AUTOSEL 4.14 06/11] net: micrel: fix KS8851_MLL Kconfig Sasha Levin
2022-04-12 0:52 ` [PATCH AUTOSEL 4.14 07/11] ata: libata-core: Disable READ LOG DMA EXT for Samsung 840 EVOs Sasha Levin
2022-04-12 0:52 ` [PATCH AUTOSEL 4.14 08/11] gpu: ipu-v3: Fix dev_dbg frequency output Sasha Levin
2022-04-12 0:52 ` [PATCH AUTOSEL 4.14 09/11] arm64: alternatives: mark patch_alternative() as `noinstr` Sasha Levin
2022-04-12 0:52 ` [PATCH AUTOSEL 4.14 10/11] scsi: mvsas: Add PCI ID of RocketRaid 2640 Sasha Levin
2022-04-12 0:52 ` [PATCH AUTOSEL 4.14 11/11] drivers: net: slip: fix NPD bug in sl_tx_timeout() Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220412005222.351554-4-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=bostroesser@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=stable@vger.kernel.org \
--cc=target-devel@vger.kernel.org \
--cc=xiaoguang.wang@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox