mirror-linux/drivers/infiniband/hw/bnxt_re
Lord Ulf Henrik Holmberg f6b079629b RDMA/bnxt_re: zero shared page before exposing to userspace
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: 1ac5a40479 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
Signed-off-by: Lord Ulf Henrik Holmberg <henrik.holmberg@defensify.se>
Link: https://patch.msgid.link/20260509084011.11971-1-pomzm67@gmail.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
2026-05-13 14:40:48 -04:00
..
Kconfig
Makefile RDMA/bnxt_re: Move the UAPI methods to a dedicated file 2026-03-08 06:20:25 -04:00
bnxt_re.h RDMA/bnxt_re: Add a debugfs entry for CQE coalescing tuning 2025-11-09 04:02:27 -05:00
debugfs.c fwctl/bnxt_en: Move common definitions to include/linux/bnxt/ 2026-03-27 09:12:36 -03:00
debugfs.h RDMA/bnxt_re: Add a debugfs entry for CQE coalescing tuning 2025-11-09 04:02:27 -05:00
hw_counters.c RDMA/bnxt_re: Remove non-statistics counters from hw_counters 2025-09-24 10:42:14 -03:00
hw_counters.h RDMA/bnxt_re: Fix OOB write in bnxt_re_copy_err_stats() 2025-12-22 03:56:35 -05:00
ib_verbs.c RDMA/bnxt_re: zero shared page before exposing to userspace 2026-05-13 14:40:48 -04:00
ib_verbs.h RDMA/bnxt_re: Simplify bnxt_re_init_depth() callers and implementation 2026-03-30 13:47:44 -04:00
main.c RDMA v7.1 merge window 2026-04-20 11:20:35 -07:00
qplib_fp.c RDMA v7.1 merge window 2026-04-20 11:20:35 -07:00
qplib_fp.h RDMA/bnxt_re: Refactor bnxt_qplib_create_qp() function 2026-03-08 06:20:25 -04:00
qplib_rcfw.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
qplib_rcfw.h RDMA/bnxt_re: Add data structures for RoCE mirror support 2025-09-11 02:17:59 -04:00
qplib_res.c RDMA/bnxt_re: Support doorbell extensions 2026-03-08 06:20:25 -04:00
qplib_res.h RDMA v7.1 merge window 2026-04-20 11:20:35 -07:00
qplib_sp.c RDMA/bnxt_re: Add support for QP rate limiting 2026-02-02 08:37:59 -05:00
qplib_sp.h RDMA/bnxt_re: Add support for QP rate limiting 2026-02-02 08:37:59 -05:00
qplib_tlv.h IB: Use capital "OR" for multiple licenses in SPDX 2023-09-11 14:14:00 +03:00
roce_hsi.h RDMA/bnxt_re: Add support for QP rate limiting 2026-02-02 08:37:59 -05:00
uapi.c RDMA/bnxt_re: Support doorbell extensions 2026-03-08 06:20:25 -04:00