From: Yu Gao <SuperSkidder@qq.com>
To: Martin Schiller <ms@dev.tdt.de>, netdev@vger.kernel.org
Cc: syzbot+8328573e4d0514392471@syzkaller.appspotmail.com,
Eric Dumazet <edumazet@kernel.org>,
Simon Horman <horms@kernel.org>,
linux-x25@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Hillf Danton <hdanton@sina.com>,
Willem de Bruijn <willemb@google.com>,
Xie He <xie.he.0141@gmail.com>,
syzbot+059a2795ad4cff2a2695@syzkaller.appspotmail.com
Subject: [PATCH net v2 1/2] net: lapb: drop lapb_list_lock before waiting for users
Date: Mon, 30 Nov 2026 20:14:47 +0800 [thread overview]
Message-ID: <tencent_BFB53B9AEE4AF90B99337798FB43DACAC506@qq.com> (raw)
In-Reply-To: <20261130-lapb-unlock-v2-0-6b2e44e3f69a@qq.com>
lapb_unregister() sleeps in usleep_range() under
write_lock_bh(&lapb_list_lock) while waiting for other users of the
control block, and then takes lapb->lock under that lock, which adds
lapb_list_lock --> &lapb->lock
to the cycle syzbot reports in lapb_connect_request().
Unlink the block and drop lapb_list_lock before waiting. Once the
block is unlinked, nothing can look it up and take a new reference.
Found by code inspection. With this patch alone, the syzbot
reproducers still report a cycle; the next patch removes it.
Fixes: b491e6a7391e ("net: lapb: Add locking to the lapb module")
Suggested-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Yu Gao <SuperSkidder@qq.com>
---
net/lapb/lapb_iface.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/lapb/lapb_iface.c b/net/lapb/lapb_iface.c
index 670e085..1af36fd 100644
--- a/net/lapb/lapb_iface.c
+++ b/net/lapb/lapb_iface.c
@@ -179,9 +179,11 @@ int lapb_unregister(struct net_device *dev)
if (!lapb)
goto out;
lapb_put(lapb);
+ __lapb_remove_cb(lapb);
+ write_unlock_bh(&lapb_list_lock);
/* Wait for other refs to "lapb" to drop */
- while (refcount_read(&lapb->refcnt) > 2)
+ while (refcount_read(&lapb->refcnt) > 1)
usleep_range(1, 10);
spin_lock_bh(&lapb->lock);
@@ -197,10 +199,8 @@ int lapb_unregister(struct net_device *dev)
timer_delete_sync(&lapb->t1timer);
timer_delete_sync(&lapb->t2timer);
- __lapb_remove_cb(lapb);
-
lapb_put(lapb);
- rc = LAPB_OK;
+ return LAPB_OK;
out:
write_unlock_bh(&lapb_list_lock);
return rc;
--
Git-157)
next parent reply other threads:[~2026-11-30 12:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261130-lapb-unlock-v2-0-6b2e44e3f69a@qq.com>
2026-11-30 12:14 ` Yu Gao [this message]
2026-12-01 13:37 ` [PATCH net v2 1/2] net: lapb: drop lapb_list_lock before waiting for users Martin Schiller
2026-11-30 12:14 ` [PATCH net v2 2/2] net: lapb: transmit frames outside the protocol lock Yu Gao
2026-12-01 12:57 ` netdev-bot+sashiko
2026-12-01 13:40 ` Martin Schiller
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=tencent_BFB53B9AEE4AF90B99337798FB43DACAC506@qq.com \
--to=superskidder@qq.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hdanton@sina.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-x25@vger.kernel.org \
--cc=ms@dev.tdt.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=syzbot+059a2795ad4cff2a2695@syzkaller.appspotmail.com \
--cc=syzbot+8328573e4d0514392471@syzkaller.appspotmail.com \
--cc=willemb@google.com \
--cc=xie.he.0141@gmail.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