From: Leon Romanovsky <leon@kernel.org>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jiri Pirko <jiri@nvidia.com>,
syzbot <syzbot+03393ff6c35fd2cc43de@syzkaller.appspotmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
"syzkaller-bugs@googlegroups.com"
<syzkaller-bugs@googlegroups.com>
Subject: Re: [syzbot] [rdma?] WARNING in ib_dealloc_device
Date: Tue, 14 Apr 2026 13:47:01 +0300 [thread overview]
Message-ID: <20260414104701.GB361495@unreal> (raw)
In-Reply-To: <20260413174228.GQ3694781@ziepe.ca>
On Mon, Apr 13, 2026 at 02:42:28PM -0300, Jason Gunthorpe wrote:
> On Mon, Apr 13, 2026 at 04:12:09PM +0000, Jiri Pirko wrote:
> > Will check it tmrw
>
> I fed it to Claude and after 40 mins it is stumped too.. It should not
> be possible for this to happen.
Interesting, I used Chris's prompts for this debug and got the following
suggestions (CONFIG_PREEMPT_RT=y in this .config):
------------------------------------------------------------------------
REMAINING HYPOTHESES
------------------------------------------------------------------------
1. PREEMPT_RT rwsem behavior (most likely for syzkaller SOFTLOCKUP trigger):
Under PREEMPT_RT, down_write/down_read use rt_mutex internally. Priority
inheritance and preemption semantics differ from non-RT. There may be a
window in the rwsem downgrade path inside enable_device_and_get (which
downgrades from WRITE to READ after setting DEVICE_REGISTERED) that allows
a concurrent disable_device to observe an inconsistent state.
Specifically: enable_device_and_get does:
down_write(devices_rwsem)
xa_set_mark(DEVICE_REGISTERED)
downgrade_write(devices_rwsem) [WRITE -> READ]
add_compat_devs()
up_read(devices_rwsem)
Under PREEMPT_RT, could disable_device acquire WRITE between the xa_set_mark
and downgrade_write? If so, it would clear DEVICE_REGISTERED while
add_compat_devs is about to run (but hasn't yet seen the mark cleared).
2. xa_for_each skipping entries during concurrent xa_erase restructuring:
If rdma_dev_exit_net's remove_one_compat_dev erases an entry concurrently
with remove_compat_devs iterating, xas_shrink (called inside xa_erase) could
restructure the xarray tree. If xa_find_after then traverses a restructured
tree and skips a subsequent entry, that entry remains in compat_devs.
This is subtle: xa_erase takes the xarray spinlock (or rt_mutex), but
xa_for_each calls xa_find_after under RCU. The RCU read side might see a
partially-restructured tree that looks different from the spinlock-visible
view. Under PREEMPT_RT, RCU critical sections can be longer.
3. rdma_compatdev_set (ib_devices_shared_netns sysctl) race:
add_all_compat_devs() is guarded by DEVICE_REGISTERED + devices_rwsem, so
the same analysis as T3a applies and the race is eliminated. However, if
there is a remove_all_compat_devs() implementation, its interaction with
the unregistration flow deserves verification.
------------------------------------------------------------------------
RECOMMENDED NEXT STEPS
------------------------------------------------------------------------
1. Add WARN_ON with stack trace inside add_one_compat_dev (compat_devs_mutex
held) that fires if DEVICE_REGISTERED is not set. If this never fires, the
insertion is always properly gated. If it fires, the unmarked insertion path
is identified.
2. Add ftrace or kprobe on remove_compat_devs and add_one_compat_dev to
capture the exact sequence of events. The key question: does any
add_one_compat_dev call happen AFTER remove_compat_devs for the same device?
3. Check whether the bug exists on non-PREEMPT_RT kernels. If only PREEMPT_RT
is affected, hypothesis 1 (rwsem downgrade race) or hypothesis 2 (RCU/xarray
interaction) is more likely.
4. Look at the kernel version of the syzkaller report. Check git log for any
changes to drivers/infiniband/core/device.c around the report date that may
have introduced or fixed the issue.
5. Investigate enable_device_and_get's downgrade_write() path -- specifically
whether a concurrent disable_device can observe DEVICE_REGISTERED set between
xa_set_mark and the downgrade, then fail to clear it before add_compat_devs runs.
------------------------------------------------------------------------
next prev parent reply other threads:[~2026-04-14 10:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 0:04 [syzbot] [rdma?] WARNING in ib_dealloc_device syzbot
2026-04-13 15:43 ` Leon Romanovsky
[not found] ` <PH7PR12MB66356E0176748BFFF081D9B4B0242@PH7PR12MB6635.namprd12.prod.outlook.com>
2026-04-13 17:42 ` Jason Gunthorpe
2026-04-14 10:47 ` Leon Romanovsky [this message]
2026-04-14 12:18 ` Jason Gunthorpe
2026-04-14 15:57 ` Jiri Pirko
2026-04-16 8:10 ` Jiri Pirko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260414104701.GB361495@unreal \
--to=leon@kernel.org \
--cc=jgg@ziepe.ca \
--cc=jiri@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=syzbot+03393ff6c35fd2cc43de@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox