syzbot
general protection fault in cma_process_remove
Status:
moderation: reported on 2026/12/03 02:40
Subsystems:
rdma
Labels:
prio:low
[Documentation on labels]
Reported-by: syzbot+910679a4184033009829@syzkaller.appspotmail.com
First crash: 1h21m, last: 1h21m
✨ AI-generated root cause summary:
In drivers/infiniband/core/cma.c, cma_send_device_removal_put() releases id_priv->handler_mutex after delivering RDMA_CM_EVENT_DEVICE_REMOVAL and before calling cma_cancel_operation(id_priv, state). If the event handler returns 0 (e.g., ucma_event_handler() queuing ucma_close_id()), a concurrent rdma_destroy_id() can acquire handler_mutex, transition id_priv->state from RDMA_CM_DEVICE_REMOVAL to RDMA_CM_DESTROYING, and invoke _destroy_id() -> cma_release_dev(), which sets id_priv->id.device = NULL. When cma_send_device_removal_put() subsequently calls cma_cancel_operation() with the previously saved RDMA_CM_ROUTE_QUERY state, cma_cancel_route() passes the NULL id_priv->id.device to rdma_cap_ib_sa(), dereferencing offset 0x798 (struct ib_device::port_data) and triggering a NULL-pointer dereference.
▶
▼
✨ Full AI root cause analysis
Root Cause Analysis
The crash is a NULL-pointer dereference in rdma_cap_ib_sa() (include/rdma/ib_verbs.h:3563), triggered by a race condition between RDMA device removal in cma_send_device_removal_put() and concurrent ID destruction in rdma_destroy_id() (drivers/infiniband/core/cma.c).
Involved Functions, Structs, and Fields
drivers/infiniband/core/cma.c:
cma_process_remove()
cma_send_device_removal_put()
cma_cancel_operation() / cma_cancel_route()
rdma_destroy_id() -> destroy_id_handler_unlock() -> _destroy_id() -> cma_release_dev()
struct rdma_id_private (id.device, id.port_num, state, handler_mutex, lock, cma_dev, comp)
drivers/infiniband/core/ucma.c:
ucma_event_handler(), ucma_close_id() (or ucma_destroy_id())
include/rdma/ib_verbs.h:
rdma_cap_ib_sa() accessing struct ib_device::port_data (at offset 0x798 in struct ib_device)
Triggering Mechanism and Violated Invariant
- An
rdma_id_private (id_priv) bound to an RDMA device (here Soft-RoCE rxe0) is placed in RDMA_CM_ROUTE_QUERY state (e.g., via rdma_resolve_route()), while attached to cma_dev->id_list with id_priv->id.device non-NULL.
- Before route resolution completes and transitions
id_priv->state out of RDMA_CM_ROUTE_QUERY, the device is unregistered (via nldev_dellink() -> ib_unregister_device_and_put() -> ... -> cma_remove_one() -> cma_process_remove()).
cma_process_remove() removes id_priv from cma_dev->id_list, takes a reference with cma_id_get(id_priv), and calls cma_send_device_removal_put(id_priv):
- Under
id_priv->handler_mutex and id_priv->lock, it reads state = id_priv->state (RDMA_CM_ROUTE_QUERY) and updates id_priv->state = RDMA_CM_DEVICE_REMOVAL.
- It calls
cma_cm_event_handler(id_priv, &event) with RDMA_CM_EVENT_DEVICE_REMOVAL. For ucma, ucma_event_handler() queues ctx->close_work (ucma_close_id()) on system_dfl_wq and returns 0.
- Because
cma_cm_event_handler() returned 0, cma_send_device_removal_put() calls mutex_unlock(&id_priv->handler_mutex) before calling cma_cancel_operation(id_priv, state).
- Once
handler_mutex is released (or if a concurrent ucma_destroy_id() / ucma_close_id() runs), rdma_destroy_id() acquires id_priv->handler_mutex in destroy_id_handler_unlock(id_priv):
- It reads
state = id_priv->state (RDMA_CM_DEVICE_REMOVAL), sets id_priv->state = RDMA_CM_DESTROYING, unlocks handler_mutex, and invokes _destroy_id(id_priv, RDMA_CM_DEVICE_REMOVAL).
- Because
state is RDMA_CM_DEVICE_REMOVAL, _destroy_id()'s cma_cancel_operation(id_priv, state) is a no-op (hitting default: break;).
_destroy_id() then calls cma_release_dev(id_priv), which clears id_priv->cma_dev = NULL and id_priv->id.device = NULL, and subsequently waits in wait_for_completion(&id_priv->comp) for cma_send_device_removal_put() to drop its reference.
- Meanwhile,
cma_send_device_removal_put() resumes after mutex_unlock(&id_priv->handler_mutex) and executes cma_cancel_operation(id_priv, state) with the saved state == RDMA_CM_ROUTE_QUERY:
cma_cancel_operation() calls cma_cancel_route(id_priv).
cma_cancel_route() calls rdma_cap_ib_sa(id_priv->id.device, id_priv->id.port_num).
- With
id_priv->id.device == NULL and id_priv->id.port_num == 1, rdma_cap_ib_sa() dereferences device->port_data[port_num] at address 0x798 (RBX: 0000000000000798), causing the reported KASAN NULL-pointer dereference (0xdffffc00000000f3).
The violated invariant is that cma_send_device_removal_put() assumes id_priv->id.device remains valid until cma_cancel_operation() completes, even though unlocking id_priv->handler_mutex after delivering RDMA_CM_EVENT_DEVICE_REMOVAL allows rdma_destroy_id() -> _destroy_id() -> cma_release_dev() to clear id_priv->id.device before cma_cancel_operation() runs.
Sample crash report:
smc: removing ib device rxe0
Oops: general protection fault, probably for non-canonical address 0xdffffc00000000f3: 0000 [#1] SMP KASAN PTI
KASAN: null-ptr-deref in range [0x0000000000000798-0x000000000000079f]
CPU: 0 UID: 0 PID: 12705 Comm: syz.0.1633 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
RIP: 0010:rdma_cap_ib_sa include/rdma/ib_verbs.h:3563 [inline]
RIP: 0010:cma_cancel_route drivers/infiniband/core/cma.c:1924 [inline]
RIP: 0010:cma_cancel_operation drivers/infiniband/core/cma.c:1979 [inline]
RIP: 0010:cma_send_device_removal_put drivers/infiniband/core/cma.c:5356 [inline]
RIP: 0010:cma_process_remove+0x6ae/0xc50 drivers/infiniband/core/cma.c:5372
Code: 4d 8d 74 24 98 4c 89 f0 48 c1 e8 03 42 0f b6 04 28 84 c0 0f 85 a2 03 00 00 45 8b 36 48 81 c3 98 07 00 00 48 89 d8 48 c1 e8 03 <42> 80 3c 28 00 74 08 48 89 df e8 13 c3 40 f9 48 8b 03 49 69 ce a0
RSP: 0018:ffffc90007226de0 EFLAGS: 00010206
RAX: 00000000000000f3 RBX: 0000000000000798 RCX: 0000000000000005
RDX: ffffffff89007be5 RSI: ffffffff9140e0f0 RDI: 0000000000000003
RBP: ffffc90007226f20 R08: ffff88804ed61f40 R09: 0000000000000003
R10: 0000000000000008 R11: 0000000000000000 R12: ffff88807d252240
R13: dffffc0000000000 R14: 0000000000000001 R15: ffff88807d252000
FS: 00007f95837d56c0(0000) GS:ffff8881233ea000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ff764f2fd80 CR3: 00000000774b4000 CR4: 00000000003526f0
Call Trace:
<TASK>
cma_remove_one+0x18a/0x340 drivers/infiniband/core/cma.c:5479
remove_client_context+0xb9/0x1e0 drivers/infiniband/core/device.c:810
disable_device+0x137/0x330 drivers/infiniband/core/device.c:1325
__ib_unregister_device+0x2c9/0x400 drivers/infiniband/core/device.c:1571
ib_unregister_device_and_put+0xb8/0xf0 drivers/infiniband/core/device.c:1636
nldev_dellink+0x3a4/0x440 drivers/infiniband/core/nldev.c:1906
rdma_nl_rcv_msg drivers/infiniband/core/netlink.c:-1 [inline]
rdma_nl_rcv_skb drivers/infiniband/core/netlink.c:239 [inline]
rdma_nl_rcv+0x6ef/0xa40 drivers/infiniband/core/netlink.c:259
netlink_unicast_kernel net/netlink/af_netlink.c:1336 [inline]
netlink_unicast+0x8ef/0xa80 net/netlink/af_netlink.c:1362
netlink_sendmsg+0x7f0/0xb20 net/netlink/af_netlink.c:1921
sock_sendmsg_nosec+0x14e/0x190 net/socket.c:800
__sock_sendmsg net/socket.c:818 [inline]
____sys_sendmsg+0x49f/0x790 net/socket.c:2713
___sys_sendmsg+0x2f8/0x3d0 net/socket.c:2770
__sys_sendmsg net/socket.c:2802 [inline]
__do_sys_sendmsg net/socket.c:2807 [inline]
__se_sys_sendmsg net/socket.c:2805 [inline]
__x64_sys_sendmsg+0x1b1/0x290 net/socket.c:2805
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x171/0x540 arch/x86/entry/syscall_64.c:89
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f95855a9c99
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f95837d5028 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007f9585836190 RCX: 00007f95855a9c99
RDX: 0000000000000080 RSI: 0000200000000e80 RDI: 0000000000000003
RBP: 00007f958563b18b R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f9585836228 R14: 00007f9585836190 R15: 00007ffe16905ea8
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:rdma_cap_ib_sa include/rdma/ib_verbs.h:3563 [inline]
RIP: 0010:cma_cancel_route drivers/infiniband/core/cma.c:1924 [inline]
RIP: 0010:cma_cancel_operation drivers/infiniband/core/cma.c:1979 [inline]
RIP: 0010:cma_send_device_removal_put drivers/infiniband/core/cma.c:5356 [inline]
RIP: 0010:cma_process_remove+0x6ae/0xc50 drivers/infiniband/core/cma.c:5372
Code: 4d 8d 74 24 98 4c 89 f0 48 c1 e8 03 42 0f b6 04 28 84 c0 0f 85 a2 03 00 00 45 8b 36 48 81 c3 98 07 00 00 48 89 d8 48 c1 e8 03 <42> 80 3c 28 00 74 08 48 89 df e8 13 c3 40 f9 48 8b 03 49 69 ce a0
RSP: 0018:ffffc90007226de0 EFLAGS: 00010206
RAX: 00000000000000f3 RBX: 0000000000000798 RCX: 0000000000000005
RDX: ffffffff89007be5 RSI: ffffffff9140e0f0 RDI: 0000000000000003
RBP: ffffc90007226f20 R08: ffff88804ed61f40 R09: 0000000000000003
R10: 0000000000000008 R11: 0000000000000000 R12: ffff88807d252240
R13: dffffc0000000000 R14: 0000000000000001 R15: ffff88807d252000
FS: 00007f95837d56c0(0000) GS:ffff8881234ea000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ff765e43ff8 CR3: 00000000774b4000 CR4: 00000000003526f0
----------------
Code disassembly (best guess):
0: 4d 8d 74 24 98 lea -0x68(%r12),%r14
5: 4c 89 f0 mov %r14,%rax
8: 48 c1 e8 03 shr $0x3,%rax
c: 42 0f b6 04 28 movzbl (%rax,%r13,1),%eax
11: 84 c0 test %al,%al
13: 0f 85 a2 03 00 00 jne 0x3bb
19: 45 8b 36 mov (%r14),%r14d
1c: 48 81 c3 98 07 00 00 add $0x798,%rbx
23: 48 89 d8 mov %rbx,%rax
26: 48 c1 e8 03 shr $0x3,%rax
* 2a: 42 80 3c 28 00 cmpb $0x0,(%rax,%r13,1) <-- trapping instruction
2f: 74 08 je 0x39
31: 48 89 df mov %rbx,%rdi
34: e8 13 c3 40 f9 call 0xf940c34c
39: 48 8b 03 mov (%rbx),%rax
3c: 49 rex.WB
3d: 69 .byte 0x69
3e: ce (bad)
3f: a0 .byte 0xa0
* Struck through repros no longer work on HEAD.