* [syzbot] [rdma?] kernel BUG in ib_device_get_by_index
@ 2026-02-28 4:38 syzbot
2026-02-28 5:07 ` Tetsuo Handa
0 siblings, 1 reply; 5+ messages in thread
From: syzbot @ 2026-02-28 4:38 UTC (permalink / raw)
To: jgg, leon, linux-kernel, linux-rdma, syzkaller-bugs
Hello,
syzbot found the following issue on:
HEAD commit: 779cae956c83 Add linux-next specific files for 20260223
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=172ebfb2580000
kernel config: https://syzkaller.appspot.com/x/.config?x=ee920513e4deca5f
dashboard link: https://syzkaller.appspot.com/bug?extid=53cf317e7803e4ef2f33
compiler: Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
Unfortunately, I don't have any reproducer for this issue yet.
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/0110c968351a/disk-779cae95.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/582a1d69266e/vmlinux-779cae95.xz
kernel image: https://storage.googleapis.com/syzbot-assets/13619a146558/bzImage-779cae95.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+53cf317e7803e4ef2f33@syzkaller.appspotmail.com
------------[ cut here ]------------
kernel BUG at ./include/rdma/ib_verbs.h:4611!
Oops: invalid opcode: 0000 [#1] SMP KASAN PTI
CPU: 0 UID: 0 PID: 5945 Comm: syz.0.12 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2026
RIP: 0010:ib_device_try_get include/rdma/ib_verbs.h:4611 [inline]
RIP: 0010:ib_device_get_by_index+0x2ae/0x2b0 drivers/infiniband/core/device.c:331
Code: f9 e9 76 fe ff ff 44 89 f1 80 e1 07 80 c1 03 38 c1 0f 8c 9d fe ff ff 4c 89 f7 e8 6d 6c 88 f9 e9 90 fe ff ff e8 23 46 1e f9 90 <0f> 0b 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 f3 0f 1e fa
RSP: 0018:ffffc900043e6fe0 EFLAGS: 00010287
RAX: ffffffff88a79c3d RBX: ffff8880277bc000 RCX: 0000000000080000
RDX: ffffc9000d882000 RSI: 0000000000000110 RDI: 0000000000000111
RBP: ffffc900043e7090 R08: ffff88801e7ebc80 R09: 0000000000000002
R10: 0000000000000406 R11: 0000000000000002 R12: 1ffff9200087ce00
R13: dffffc0000000000 R14: ffff8880277bd104 R15: dffffc0000000000
FS: 00007f2f67eba6c0(0000) GS:ffff888125009000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000200000001000 CR3: 0000000076cc8000 CR4: 00000000003526f0
Call Trace:
<TASK>
nldev_set_doit+0x23a/0x4c0 drivers/infiniband/core/nldev.c:1134
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+0x6d7/0xa10 drivers/infiniband/core/netlink.c:259
netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline]
netlink_unicast+0x80f/0x9b0 net/netlink/af_netlink.c:1344
netlink_sendmsg+0x813/0xb40 net/netlink/af_netlink.c:1894
sock_sendmsg_nosec+0x18f/0x1d0 net/socket.c:737
__sock_sendmsg net/socket.c:752 [inline]
____sys_sendmsg+0x589/0x8c0 net/socket.c:2610
___sys_sendmsg+0x2a5/0x360 net/socket.c:2664
__sys_sendmsg net/socket.c:2696 [inline]
__do_sys_sendmsg net/socket.c:2701 [inline]
__se_sys_sendmsg net/socket.c:2699 [inline]
__x64_sys_sendmsg+0x1bd/0x2a0 net/socket.c:2699
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f2f66f9c629
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:00007f2f67eba028 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007f2f67216090 RCX: 00007f2f66f9c629
RDX: 0000000000040810 RSI: 0000200000000140 RDI: 0000000000000004
RBP: 00007f2f67032b39 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f2f67216128 R14: 00007f2f67216090 R15: 00007fff55890bd8
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:ib_device_try_get include/rdma/ib_verbs.h:4611 [inline]
RIP: 0010:ib_device_get_by_index+0x2ae/0x2b0 drivers/infiniband/core/device.c:331
Code: f9 e9 76 fe ff ff 44 89 f1 80 e1 07 80 c1 03 38 c1 0f 8c 9d fe ff ff 4c 89 f7 e8 6d 6c 88 f9 e9 90 fe ff ff e8 23 46 1e f9 90 <0f> 0b 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 f3 0f 1e fa
RSP: 0018:ffffc900043e6fe0 EFLAGS: 00010287
RAX: ffffffff88a79c3d RBX: ffff8880277bc000 RCX: 0000000000080000
RDX: ffffc9000d882000 RSI: 0000000000000110 RDI: 0000000000000111
RBP: ffffc900043e7090 R08: ffff88801e7ebc80 R09: 0000000000000002
R10: 0000000000000406 R11: 0000000000000002 R12: 1ffff9200087ce00
R13: dffffc0000000000 R14: ffff8880277bd104 R15: dffffc0000000000
FS: 00007f2f67eba6c0(0000) GS:ffff888125109000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f37a17e82f8 CR3: 0000000076cc8000 CR4: 00000000003526f0
---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [syzbot] [rdma?] kernel BUG in ib_device_get_by_index
2026-02-28 4:38 [syzbot] [rdma?] kernel BUG in ib_device_get_by_index syzbot
@ 2026-02-28 5:07 ` Tetsuo Handa
2026-03-02 19:17 ` Leon Romanovsky
0 siblings, 1 reply; 5+ messages in thread
From: Tetsuo Handa @ 2026-02-28 5:07 UTC (permalink / raw)
To: syzbot+53cf317e7803e4ef2f33, syzkaller-bugs
Cc: jgg, leon, linux-kernel, linux-rdma
Hmm, this assertion was wrong because ib_device_get_by_index()
might be called before enable_device_and_get() is called.
#syz invalid
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [syzbot] [rdma?] kernel BUG in ib_device_get_by_index
2026-02-28 5:07 ` Tetsuo Handa
@ 2026-03-02 19:17 ` Leon Romanovsky
2026-03-03 13:38 ` Tetsuo Handa
0 siblings, 1 reply; 5+ messages in thread
From: Leon Romanovsky @ 2026-03-02 19:17 UTC (permalink / raw)
To: Tetsuo Handa
Cc: syzbot+53cf317e7803e4ef2f33, syzkaller-bugs, jgg, linux-kernel,
linux-rdma
On Sat, Feb 28, 2026 at 02:07:46PM +0900, Tetsuo Handa wrote:
> Hmm, this assertion was wrong because ib_device_get_by_index()
> might be called before enable_device_and_get() is called.
>
> #syz invalid
I think this is a valid syzkaller report. As you correctly noted, the device
was inserted into the xarray database in assign_name(), but its refcount was
only set later in enable_device_and_get().
The proper fix can be something like that:
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index c7b227e2e657..5fc2604ec482 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -321,7 +321,7 @@ struct ib_device *ib_device_get_by_index(const struct net *net, u32 index)
down_read(&devices_rwsem);
device = xa_load(&devices, index);
- if (device) {
+ if (device && xa_get_mark(&devices, index, DEVICE_REGISTERED)) {
if (!rdma_dev_access_netns(device, net)) {
device = NULL;
goto out;
Thanks
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [syzbot] [rdma?] kernel BUG in ib_device_get_by_index
2026-03-02 19:17 ` Leon Romanovsky
@ 2026-03-03 13:38 ` Tetsuo Handa
2026-03-04 14:22 ` Leon Romanovsky
0 siblings, 1 reply; 5+ messages in thread
From: Tetsuo Handa @ 2026-03-03 13:38 UTC (permalink / raw)
To: Leon Romanovsky
Cc: syzbot+53cf317e7803e4ef2f33, syzkaller-bugs, jgg, linux-kernel,
linux-rdma
On 2026/03/03 4:17, Leon Romanovsky wrote:
> On Sat, Feb 28, 2026 at 02:07:46PM +0900, Tetsuo Handa wrote:
>> Hmm, this assertion was wrong because ib_device_get_by_index()
>> might be called before enable_device_and_get() is called.
>>
>> #syz invalid
>
> I think this is a valid syzkaller report. As you correctly noted, the device
> was inserted into the xarray database in assign_name(), but its refcount was
> only set later in enable_device_and_get().
I was wondering why enable_device_and_get() is using not refcount_add()
but refcount_set(), and I tried
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit?id=510cd4b7d46753b4bf0f57004aa7b53b91b2b25a
in case commit 9af0feae8016 ("RDMA/core: Fix stale RoCE GIDs during netdev
events at registration") unexpectedly triggered modification of ->refcount
before refcount_set(&device->refcount, 2) is called.
But I concluded from this syzbot report that the reason enable_device_and_get() is
using refcount_set() is that we cannot use refcount_add() because ->refcount == 0.
Therefore, it is safe to call ib_device_try_get() before enable_device_and_get()
calls refcount_set().
>
> The proper fix can be something like that:
>
down_read(&devices_rwsem);
device = xa_load(&devices, index);
- if (device) {
+ if (device && xa_get_mark(&devices, index, DEVICE_REGISTERED)) {
if (!rdma_dev_access_netns(device, net)) {
device = NULL;
goto out;
}
if (!ib_device_try_get(device))
device = NULL;
}
Why do you want to make this change? Unless it is unsafe to call
rdma_dev_access_netns() when DEVICE_REGISTERED is not set,
refcount_inc_not_zero() from ib_device_try_get() makes the final
result same (i.e. device == NULL).
Since enable_device_and_get() sets ->refcount immediately before
xa_set_mark() is called, adding xa_get_mark() check does not change
effective behavior.
What I rather worry is that refcount_set() is called too early if
there is an ib_device_try_get() user who expects that
device->ops.enable_driver()/add_client_context()/add_compat_devs()
have already completed when ib_device_try_get() succeeded.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [syzbot] [rdma?] kernel BUG in ib_device_get_by_index
2026-03-03 13:38 ` Tetsuo Handa
@ 2026-03-04 14:22 ` Leon Romanovsky
0 siblings, 0 replies; 5+ messages in thread
From: Leon Romanovsky @ 2026-03-04 14:22 UTC (permalink / raw)
To: Tetsuo Handa
Cc: syzbot+53cf317e7803e4ef2f33, syzkaller-bugs, jgg, linux-kernel,
linux-rdma
On Tue, Mar 03, 2026 at 10:38:17PM +0900, Tetsuo Handa wrote:
> On 2026/03/03 4:17, Leon Romanovsky wrote:
> > On Sat, Feb 28, 2026 at 02:07:46PM +0900, Tetsuo Handa wrote:
> >> Hmm, this assertion was wrong because ib_device_get_by_index()
> >> might be called before enable_device_and_get() is called.
> >>
> >> #syz invalid
> >
> > I think this is a valid syzkaller report. As you correctly noted, the device
> > was inserted into the xarray database in assign_name(), but its refcount was
> > only set later in enable_device_and_get().
>
> I was wondering why enable_device_and_get() is using not refcount_add()
> but refcount_set(), and I tried
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit?id=510cd4b7d46753b4bf0f57004aa7b53b91b2b25a
> in case commit 9af0feae8016 ("RDMA/core: Fix stale RoCE GIDs during netdev
> events at registration") unexpectedly triggered modification of ->refcount
> before refcount_set(&device->refcount, 2) is called.
>
> But I concluded from this syzbot report that the reason enable_device_and_get() is
> using refcount_set() is that we cannot use refcount_add() because ->refcount == 0.
>
> Therefore, it is safe to call ib_device_try_get() before enable_device_and_get()
> calls refcount_set().
>
> >
> > The proper fix can be something like that:
> >
> down_read(&devices_rwsem);
> device = xa_load(&devices, index);
> - if (device) {
> + if (device && xa_get_mark(&devices, index, DEVICE_REGISTERED)) {
> if (!rdma_dev_access_netns(device, net)) {
> device = NULL;
> goto out;
> }
>
> if (!ib_device_try_get(device))
> device = NULL;
> }
>
> Why do you want to make this change? Unless it is unsafe to call
> rdma_dev_access_netns() when DEVICE_REGISTERED is not set,
> refcount_inc_not_zero() from ib_device_try_get() makes the final
> result same (i.e. device == NULL).
>
> Since enable_device_and_get() sets ->refcount immediately before
> xa_set_mark() is called, adding xa_get_mark() check does not change
> effective behavior.
xa_set_mark() is performed under down_write(&devices_rwsem) and it
ensures that xa_load(...) will return fully initialized device.
But yes, you are right, ib_device_try_get() should return 0 if this
device isn't set yet.
Thanks
>
> What I rather worry is that refcount_set() is called too early if
> there is an ib_device_try_get() user who expects that
> device->ops.enable_driver()/add_client_context()/add_compat_devs()
> have already completed when ib_device_try_get() succeeded.
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-03-04 14:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-28 4:38 [syzbot] [rdma?] kernel BUG in ib_device_get_by_index syzbot
2026-02-28 5:07 ` Tetsuo Handa
2026-03-02 19:17 ` Leon Romanovsky
2026-03-03 13:38 ` Tetsuo Handa
2026-03-04 14:22 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox