Skip to contentSkip to conversation

Use-After-Free in RDMA Subsystem (rxe_queue_cleanup) - CVE Request

VulnerabilityReport Zhu Yanjun 1 participant 1 message Mar 24, 2025 3 messages not in the archive InfiniBand

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): 2025032355-penniless-ferocious-d459@gregkh

A message that is not in the archive (sent off-list or not yet received): [email protected]

Zhu Yanjun

author
#3 lore raw

Sorry. Add linux rdma maillist.

Zhu Yanjun

Quoted 82 lines · Zhu Yanjun
Quoted 21 lines · Greg KH

RDMA maintainers on the To: list here, I've bounced the original to them as well.

More comments below:

Quoted 15 lines · On Sun, Mar 23, 2025 at 03:10:28PM +0800, [email protected] wrote:

Dear Linux Kernel Security Team,

I am reporting a security vulnerability in the Linux kernel's RDMA subsystem involving a use-after-free condition. Below are the technical details and proposed fix.

Vulnerability Details
Component: RDMA subsystem (drivers/infiniband/sw/rxe/rxe_queue.c)
Function: rxe_queue_cleanup() (line 195)
Issue: KASAN: slab-use-after-free Read in rxe_queue_cleanup
Kernel Version: 6.13.6 (observed in a QEMU VM with Debian 11 x86_64)
Impact: May allow local attackers to escalate privileges or cause denial-of-service (DoS) via uncontrolled memory corruption.
PoC: Generated by Syzkaller. Full report and trigger: https://paste.ubuntu.com/p/tJgC42wDf6/

I have attempted to anaylse the root cause, and I find that the rxe_queue_cleanup() function accesses cq->queue after it has been freed. This occurs when error handling in rxe_cq.c frees cq->queue but does not set the pointer to NULL, leading to a dangling reference.

Attached below is a patch for drivers/infiniband/sw/rxe/rxe_cq.c to nullify the pointer after freeing:

Hi, Liuy22

If I get you correctly, in the function rxe_create_cq, rxe_cq_from_init fails because the function do_mmap_info

1062 static int rxe_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, 1063              struct uverbs_attr_bundle *attrs)
1064 {

...

1098
1099     err = rxe_cq_from_init(rxe, cq, attr->cqe, attr->comp_vector, udata,   <----This function failed because do_mmap_info failed. 1100                    uresp);
1101     if (err) {
1102         rxe_dbg_cq(cq, "create cq failed, err = %d\n", err);
1103         goto err_cleanup;
1104     }
...

1108 err_cleanup:
1109     cleanup_err = rxe_cleanup(cq);
1110     if (cleanup_err)
1111         rxe_err_cq(cq, "cleanup failed, err = %d\n", cleanup_err);

Then rxe_cleanup is called to clean up cq.

Is it correct? Can you share the call trace with us? So we can delve into this problem, discuss this problem, find out the root cause, then fix it.

Thanks a lot.

Zhu Yanjun

Quoted 25 lines

Review line 64

Quoted 13 lines

diff -u a/drivers/infiniband/sw/rxe/rxe_cq.c b/drivers/infiniband/sw/rxe/rxe_cq.c --- a/drivers/infiniband/sw/rxe/rxe_cq.c 2025-03-23 10:02:17.436250465 +0800
+++ b/drivers/infiniband/sw/rxe/rxe_cq.c 2025-03-23 10:02:12.656152582 +0800

(quoted diff) +1 -0
@@ -59,6 +59,7 @@
    if (err) {
    vfree(cq->queue->buf);
    kfree(cq->queue);
+ cq->queue = NULL;
    return err;
    }

Can you submit this as a proper patch for inclusion in the tree, so that you get proper credit for fixing the issue as well as finding it?

Quoted 3 lines

After applying the patch, the PoC no longer triggers the use-after-free.

I kindly hope that this report is acknowledged as soon as possible, and a CVE ID is assigned for tracking. I also look forward to advice on further steps (e.g., embargo coordination).

This is not how CVE ids are handled, please read our documentation for how that happens (hint, not here.)

thanks,

greg k-h

Signature · 2 lines
Best Regards,
Yanjun.Zhu