RDMA/rxe: bound the ODP page index against the umem in rxe_check_pagefault()
Subsystems (3)
PATCH 1/1 RDMA/rxe: bound the ODP page index against the umem in rxe_check_pagefault()
An ODP MR's page array map.pfn_list[] is sized from the umem's start, but rxe_check_pagefault() indexes it with an iova taken relative to that start, while the access was range-checked against the MR's iova (ibmr.iova). reg_mr only requires start and hca_va to share a page offset, so a user can register with hca_va = start + N*PAGE, and the index skew (hca_va - start) >> PAGE_SHIFT then lands out of bounds of pfn_list[], which is read with no bound check. An unprivileged local user reaches this with a single RDMA operation on a self-connected rxe QP: observed as a KASAN slab-out-of-bounds read and, when the out-of-bounds qword looks like a writable HMM pfn, a write into an attacker-influenced page.
Reject an index that leaves the umem and force the fault path, which fails the out-of-range access via the umem range check in ib_umem_odp_map_dma_and_lock(). The downstream pfn_list[] users (__rxe_odp_mr_copy() and the atomic helpers) run only after a successful map, so this check protects them as well.
---
Notes (not part of the commit):
Reproduced on a KASAN x86-64 build of 7.3-rc4 as uid 1000; the data-only write primitive was used to reach uid 0 on a fully hardened build. drivers/infiniband/sw/rxe/ is unchanged between 7.3-rc4 (93f51579e7df) and mainline 551c722f4080 (2026-09-29) and rdma for-next, so both are affected. Compile-tested (KASAN+RDMA_RXE), not runtime-tested. Found through AI-assisted review; per Documentation/process/security-bugs.rst this is public and a reproducer can be shared on request. A maintainer may prefer to also index relative to ibmr.iova (as the non-ODP rxe_mr_iova_to_index() does) so legitimately skewed MRs keep working; this patch takes the minimal, safe route.
drivers/infiniband/sw/rxe/rxe_odp.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/infiniband/sw/rxe/rxe_odp.c +5 -0
@@ -136,6 +136,11 @@ static inline bool rxe_check_pagefault(struct ib_umem_odp *umem_odp, u64 iova,while (addr < iova + length) { idx = (addr -ib_umem_start (umem_odp)) >> umem_odp->page_shift; +if (idx >=ib_umem_odp_num_pages (umem_odp)) { + need_fault = true; +break ; + } +if ((umem_odp->map.pfn_list[idx] & access) != access) { need_fault = true;break ;
--
2.43.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 12 lines
An ODP MR's page array map.pfn_list[] is sized from the umem's start, but
rxe_check_pagefault()indexes it with an iova taken relative to that start, while the access was range-checked against the MR's iova (ibmr.iova).reg_mronly requires start andhca_vato share a page offset, so a user can register withhca_va= start + N*PAGE, and the index skew (hca_va- start) >>PAGE_SHIFTthen lands out of bounds of pfn_list[], which is read with no bound check. An unprivileged local user reaches this with a single RDMA operation on a self-connected rxe QP: observed as a KASAN slab-out-of-bounds read and, when the out-of-bounds qword looks like a writable HMM pfn, a write into an attacker-influenced page.
Quoted 8 lines
Reject an index that leaves the umem and force the fault path, which fails the out-of-range access via the umem range check in
ib_umem_odp_map_dma_and_lock(). The downstream pfn_list[] users (__rxe_odp_mr_copy()and the atomic helpers) run only after a successful map, so this check protects them as well.Fixes 2fae67ab63db ("RDMA/rxe: Add support for Send/Recv/Write/Read with ODP")Signed-off-by Youngsung Ahn <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Hello,
Quoted 12 lines · Youngsung Ahn
An ODP MR's page array map.pfn_list[] is sized from the umem's start, but
rxe_check_pagefault()indexes it with an iova taken relative to that start, while the access was range-checked against the MR's iova (ibmr.iova).reg_mronly requires start andhca_vato share a page offset, so a user can register withhca_va= start + N*PAGE, and the index skew (hca_va- start) >>PAGE_SHIFTthen lands out of bounds of pfn_list[], which is read with no bound check. An unprivileged local user reaches this with a single RDMA operation on a self-connected rxe QP: observed as a KASAN slab-out-of-bounds read and, when the out-of-bounds qword looks like a writable HMM pfn, a write into an attacker-influenced page.
Quoted 8 lines
Reject an index that leaves the umem and force the fault path, which fails the out-of-range access via the umem range check in
ib_umem_odp_map_dma_and_lock(). The downstream pfn_list[] users (__rxe_odp_mr_copy()and the atomic helpers) run only after a successful map, so this check protects them as well.Fixes 2fae67ab63db ("RDMA/rxe: Add support for Send/Recv/Write/Read with ODP")Signed-off-by Youngsung Ahn <[email protected]>
Are you sure you're not missing an Assisted-by: tag here ?
I didn't notice that you sent this to a public list, that's fine but in this case there's no need to Cc [email protected] since the essential role of the team is to help route the message to its destination :-)
thanks,
Willy
PATCH v2 1/1 RDMA/rxe: bound the ODP page index against the umem in rxe_check_pagefault()
In reply to Youngsung AhnAn ODP MR's page array map.pfn_list[] is sized from the umem's start, but rxe_check_pagefault() indexes it with an iova taken relative to that start, while the access was range-checked against the MR's iova (ibmr.iova). reg_mr only requires start and hca_va to share a page offset, so a user can register with hca_va = start + N*PAGE, and the index skew (hca_va - start) >> PAGE_SHIFT then lands out of bounds of pfn_list[], which is read with no bound check. An unprivileged local user reaches this with a single RDMA operation on a self-connected rxe QP: observed as a KASAN slab-out-of-bounds read and, when the out-of-bounds qword looks like a writable HMM pfn, a write into an attacker-influenced page.
Reject an index that leaves the umem and force the fault path, which fails the out-of-range access via the umem range check in ib_umem_odp_map_dma_and_lock(). The downstream pfn_list[] users (__rxe_odp_mr_copy() and the atomic helpers) run only after a successful map, so this check protects them as well.
---
Notes (not part of the commit):
Reproduced on a KASAN x86-64 build of 7.3-rc4 as uid 1000; the data-only write primitive was used to reach uid 0 on a fully hardened build. drivers/infiniband/sw/rxe/ is unchanged between 7.3-rc4 (93f51579e7df) and mainline 551c722f4080 (2026-09-29) and rdma for-next, so both are affected. Compile-tested (KASAN+RDMA_RXE), not runtime-tested. Found through AI-assisted review; per Documentation/process/security-bugs.rst this is public and a reproducer can be shared on request. A maintainer may prefer to also index relative to ibmr.iova (as the non-ODP rxe_mr_iova_to_index() does) so legitimately skewed MRs keep working; this patch takes the minimal, safe route.
v2: no code change. Added Assisted-by: LLM and dropped the [email protected] Cc, per review of v1.
drivers/infiniband/sw/rxe/rxe_odp.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/infiniband/sw/rxe/rxe_odp.c +5 -0
@@ -136,6 +136,11 @@ static inline bool rxe_check_pagefault(struct ib_umem_odp *umem_odp, u64 iova,while (addr < iova + length) { idx = (addr -ib_umem_start (umem_odp)) >> umem_odp->page_shift; +if (idx >=ib_umem_odp_num_pages (umem_odp)) { + need_fault = true; +break ; + } +if ((umem_odp->map.pfn_list[idx] & access) != access) { need_fault = true;break ;
--
2.43.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 18 lines
An ODP MR's page array map.pfn_list[] is sized from the umem's start, but
rxe_check_pagefault()indexes it with an iova taken relative to that start, while the access was range-checked against the MR's iova (ibmr.iova).reg_mronly requires start andhca_vato share a page offset, so a user can register withhca_va= start + N*PAGE, and the index skew (hca_va- start) >>PAGE_SHIFTthen lands out of bounds of pfn_list[], which is read with no bound check. An unprivileged local user reaches this with a single RDMA operation on a self-connected rxe QP: observed as a KASAN slab-out-of-bounds read and, when the out-of-bounds qword looks like a writable HMM pfn, a write into an attacker-influenced page.Reject an index that leaves the umem and force the fault path, which fails the out-of-range access via the umem range check in
ib_umem_odp_map_dma_and_lock(). The downstream pfn_list[] users (__rxe_odp_mr_copy()and the atomic helpers) run only after a successful map, so this check protects them as well.
Quoted 3 lines
Fixes 2fae67ab63db ("RDMA/rxe: Add support for Send/Recv/Write/Read with ODP")Signed-off-by Youngsung Ahn <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1