The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] RDMA/bnxt_re: zero shared page before exposing to userspace
       [not found] <2026050945-oversight-carefully-93e0@gregkh>
@ 2026-05-09  8:40 ` pomzm67
  2026-05-13 18:51   ` Leon Romanovsky
  0 siblings, 1 reply; 2+ messages in thread
From: pomzm67 @ 2026-05-09  8:40 UTC (permalink / raw)
  To: security
  Cc: selvin.xavier, kalesh-anakkur.purayil, jgg, leon, eddie.wai,
	somnath.kotur, sriharsha.basavapatna, devesh.sharma, dledford,
	gregkh, linux-rdma, linux-kernel, Lord Ulf Henrik Holmberg

From: Lord Ulf Henrik Holmberg <henrik.holmberg@defensify.se>

bnxt_re_alloc_ucontext() allocates uctx->shpg via
__get_free_page(GFP_KERNEL). The buddy allocator does not zero pages
without __GFP_ZERO, so the page contains stale kernel data from
whatever object most recently freed it.

The page is then mapped into userspace via vm_insert_page() under
BNXT_RE_MMAP_SH_PAGE in bnxt_re_mmap(). The driver only ever writes
4 bytes (a u32 AVID) at offset BNXT_RE_AVID_OFFT (0x10) inside
bnxt_re_create_ah(); the remaining 4092 bytes of the page are exposed
to userspace unsanitised, leaking kernel memory contents.

Any user with access to /dev/infiniband/uverbsX on a host with a
bnxt_re device (typically rdma group membership) can read this data
via a single mmap() at pgoff 0 after IB_USER_VERBS_CMD_GET_CONTEXT.

Other shared pages in the same file already use get_zeroed_page()
correctly:

  drivers/infiniband/hw/bnxt_re/ib_verbs.c
      srq->uctx_srq_page = (void *)get_zeroed_page(GFP_KERNEL);
      cq->uctx_cq_page  = (void *)get_zeroed_page(GFP_KERNEL);

uctx->shpg is the only outlier. Bring it in line with the existing
convention by switching to get_zeroed_page().

Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
Signed-off-by: Lord Ulf Henrik Holmberg <henrik.holmberg@defensify.se>
---
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index 7ed294516b7e..365ec2767d25 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -4638,7 +4638,7 @@ int bnxt_re_alloc_ucontext(struct ib_ucontext *ctx, struct ib_udata *udata)
 
 	uctx->rdev = rdev;
 
-	uctx->shpg = (void *)__get_free_page(GFP_KERNEL);
+	uctx->shpg = (void *)get_zeroed_page(GFP_KERNEL);
 	if (!uctx->shpg) {
 		rc = -ENOMEM;
 		goto fail;
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] RDMA/bnxt_re: zero shared page before exposing to userspace
  2026-05-09  8:40 ` [PATCH] RDMA/bnxt_re: zero shared page before exposing to userspace pomzm67
@ 2026-05-13 18:51   ` Leon Romanovsky
  0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2026-05-13 18:51 UTC (permalink / raw)
  To: security, pomzm67
  Cc: selvin.xavier, kalesh-anakkur.purayil, jgg, eddie.wai,
	somnath.kotur, sriharsha.basavapatna, devesh.sharma, dledford,
	gregkh, linux-rdma, linux-kernel, Lord Ulf Henrik Holmberg


On Sat, 09 May 2026 10:40:11 +0200, pomzm67@gmail.com wrote:
> bnxt_re_alloc_ucontext() allocates uctx->shpg via
> __get_free_page(GFP_KERNEL). The buddy allocator does not zero pages
> without __GFP_ZERO, so the page contains stale kernel data from
> whatever object most recently freed it.
> 
> The page is then mapped into userspace via vm_insert_page() under
> BNXT_RE_MMAP_SH_PAGE in bnxt_re_mmap(). The driver only ever writes
> 4 bytes (a u32 AVID) at offset BNXT_RE_AVID_OFFT (0x10) inside
> bnxt_re_create_ah(); the remaining 4092 bytes of the page are exposed
> to userspace unsanitised, leaking kernel memory contents.
> 
> [...]

Applied, thanks!

[1/1] RDMA/bnxt_re: zero shared page before exposing to userspace
      (no commit info)

Best regards,
-- 
Leon Romanovsky <leon@kernel.org>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-13 18:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <2026050945-oversight-carefully-93e0@gregkh>
2026-05-09  8:40 ` [PATCH] RDMA/bnxt_re: zero shared page before exposing to userspace pomzm67
2026-05-13 18:51   ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox