From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC8763D34AC for ; Tue, 14 Apr 2026 12:18:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776169097; cv=none; b=VJnhUghQ9SCQAuoHSl+GGVxthlwtQdpC0P3OoaprQuDxD3v5Q+jahAtCGQ7X2WXNoKBmiyDBd5mOaq8SMRlVSJg9Oa0NMKy2kq/px1a9jSba0pTVNPNrGHWcMpS6wt9ktbj9cyKr6jySYmx98GkjSU3NQU3iFWBopE2bKS85I2Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776169097; c=relaxed/simple; bh=TMTPOjpMU0GH+PrZFSP3rKyQVVAjWTS5qyahdWFT3mA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DNn/VF/4HXRHhegnJyle3JZeNrPCmhLHu1YEFuJa1P+Gm5AzkFHky13VSeuPX8zP1+j1EUXPpIgja1iarz3E9qn4sjNymUAu7fqZ8hNz79Y32Q0JwQJ99KfV0eV7gCMz/ArNWWjJCtWtSexeKRqrq8Vt/xqJlt2b9MBP6uzUWDw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=fENkWsfW; arc=none smtp.client-ip=209.85.160.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="fENkWsfW" Received: by mail-qt1-f180.google.com with SMTP id d75a77b69052e-50d876329bbso58286741cf.2 for ; Tue, 14 Apr 2026 05:18:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1776169095; x=1776773895; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=U936AlL2EkStYn6Vl0fAksDLSIrbwVXz8JpMIKb14Sw=; b=fENkWsfWLkxJv/VcLYFbX2Lo5bSQ97ttLjEtMoR0McfWE6vi4Cdw12wg55HPwMIjwt yAvcurr4p6PCt5p970r9BA0d82L5xjgCANiEdOUnU+hx8907qmVHRdFM9cIXo+5y91HY we3VN6lR9JAT7ru1IhcyvUmqz2rkjDdRsu1dNZdgUxD3Q5F7XKTnBVsxwjNS09Zm5h94 Q6pNdLrwbe/ZHgks8J/aTEH+D+FqhEv75KhMwh0FNE6r/ESjogF4k/YTKQVXiIO9TZKU 9eH/ZU2zLJNxOK7kPxi3R5UUQGpycSxURPCxsHVHCdWvzgeEr+PjO8oLvttxgX5qMl8p LwFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776169095; x=1776773895; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U936AlL2EkStYn6Vl0fAksDLSIrbwVXz8JpMIKb14Sw=; b=TRngi+61eK5gojgNxMnEQHiRKhFCehB4mlIVU3R2O/bOGIKKEcDtbWKNIt/P55O+Fa wKQdK6WonAfV1qQV7EnTw0QO0kYILZjgXN/PTRQcL7wXAM9LmVXGcNsQBuXU3QcqgbcP TVX8hBNqoqmOmFYfl3S5dN3bEHP0FCdzofQcvWdhlVb/FSvOTuKFuwOobVo11seJBLGV VzaXJYysMoE77QV0iEvJK7cblq+CIy19VorpOp4XO1G33q7riQtUZJWFQ3oWogA2261k y5muk1J07fdzt5lj09ex8umS0LdT08EpFGlRyRWK/kxCWHO4oo8fYg9H+c2VW5RxIw01 uVZg== X-Forwarded-Encrypted: i=1; AFNElJ9Ezx2XuJg88a3ra8BwUMYouRhAJFAaHzfBTHnQsJJXwIfgEuK0OJ8D1jCuEMQKRgw+cVXawwfHQy9am3c=@vger.kernel.org X-Gm-Message-State: AOJu0YxefAy4Eg8+oYd+bz9KQbvZ0aNHZ8EEQb6cCu0m8Rmuu4Hhw30y D4336LB0tcppk3EAg1Y57kXGQ2IA1HbB6+uZYpVjR/GS8AJeSDQTbjT/aO1C/djnzvGQjplEILi +1+aT X-Gm-Gg: AeBDiesCZPrsRNr9rKMXWuwYH/AHTndh71qa//Xktce0bqGiff7YlN5cZBojdvEqACC IsAk/W9mV/0A5FYmjF898HVQucR5SARi+mNNvxgEDVSHv4qphEZhgTxOcYMvtzSzw6Smnf2KNZT h+FsSFxDsqu+ZnLWXVmDaaZlirDYQC8ImQ4zfip+yvLW+hTk2yuOYx0c+87GGq9JJNmOWscp3fy lqubHSCpuKAxj/iz2YNeB3IXCpEMT9IVyySvpJZlEXoW4Qg5IbGfwwtYRTih2pJnYJAG7qNr25B CD85CPBUGDjJlNxxxCykAQGxJGBzn4C9PNtYf7K4/M2N/jNO92kIu2e8LS64I/FLkKrgEHKiDAb 0/2sTJ9ZOB06vzpEiHa5nJDiPu0nInFedWKfUWfi8T+QL5/IFRr6KrSKOUqJ51G47N6fXHrfU6l ZDDP7uunvczLrBzlVxof6Tjg4sTW+fSj7PiMlCg1KkQR55hgizFoejO6kwPlMGZr6K186nK/A8R lPzlQ== X-Received: by 2002:a05:622a:a992:10b0:50d:7d8a:5d45 with SMTP id d75a77b69052e-50dd5b7c087mr192284391cf.36.1776169094681; Tue, 14 Apr 2026 05:18:14 -0700 (PDT) Received: from ziepe.ca (crbknf0213w-47-54-130-67.pppoe-dynamic.high-speed.nl.bellaliant.net. [47.54.130.67]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8aca57b465bsm65499196d6.38.2026.04.14.05.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2026 05:18:14 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1wCcib-0000000Acat-24la; Tue, 14 Apr 2026 09:18:13 -0300 Date: Tue, 14 Apr 2026 09:18:13 -0300 From: Jason Gunthorpe To: Leon Romanovsky Cc: Jiri Pirko , syzbot , "linux-kernel@vger.kernel.org" , "linux-rdma@vger.kernel.org" , "syzkaller-bugs@googlegroups.com" Subject: Re: [syzbot] [rdma?] WARNING in ib_dealloc_device Message-ID: <20260414121813.GU3694781@ziepe.ca> References: <69dc3310.a00a0220.475f0.0018.GAE@google.com> <20260413154353.GK21470@unreal> <20260413174228.GQ3694781@ziepe.ca> <20260414104701.GB361495@unreal> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260414104701.GB361495@unreal> On Tue, Apr 14, 2026 at 01:47:01PM +0300, Leon Romanovsky wrote: > 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. Is this actually true? What is the point of implementing downgrade_write like this? > 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). This is half a thought, okay, so even if they race, the entry to remove_compat_devs() is sill gated by /* Pairs with refcount_set in enable_device */ ib_device_put(device); wait_for_completion(&device->unreg_completion); And we still have the refcount guarding it: refcount_set(&device->refcount, 2); down_write(&devices_rwsem); xa_set_mark(&devices, device->index, DEVICE_REGISTERED); So we can't race add_compat_devs and remove_compat_devs() like this unless there is some way for the refcount to have been dropped to zero also. I don't think there is. > 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 race is also impossible due to the mark and the refcount. > 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. Huh? your claude has lost its mind :) Jason