From: "Zhou, Yun" <yun.zhou@windriver.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: jirislaby@kernel.org, socketcan@hartkopp.net,
linux-serial@vger.kernel.org, mkl@pengutronix.de,
linux-can@vger.kernel.org, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
horms@kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] tty: ldisc: fix deadlock between ldisc_sem and rtnl_mutex
Date: Fri, 31 Jul 2026 13:54:31 +0800 [thread overview]
Message-ID: <ccbe9f70-8ec6-41f3-af8e-2cbf84b4d652@windriver.com> (raw)
In-Reply-To: <2026073027-nervy-imposing-0068@gregkh>
On 7/30/2026 10:50 PM, Greg KH wrote:
> On Fri, Jul 24, 2026 at 04:46:48PM +0800, Yun Zhou wrote:
>> syzbot reported a circular lock dependency involving tty ldisc_sem and
>> the networking rtnl_mutex. The full chain is:
>>
>> rtnl_mutex --> nft_commit_mutex --> ... --> ep->mtx --> ldisc_sem --> rtnl_mutex
>>
>> The last edge (ldisc_sem -> rtnl_mutex) is created because tty line
>> discipline .open() callbacks (slcan, slip) call register_netdev() which
>> acquires rtnl_mutex, and .open() runs under ldisc_sem write lock in
>> tty_set_ldisc().
>>
>> Fix by moving the .open() call outside the ldisc_sem write lock. The
>> ldisc .open() is initialization of the NEW discipline after the old one
>> has been closed - there is no need for ldisc_sem protection at this
>> point since:
>>
>> - tty_lock is held throughout, preventing concurrent tty_set_ldisc,
>> hangup, or close
>> - tty->ldisc is set to NULL during the window. tty_ldisc_ref_wait()
>> waits for the transition to complete. tty_ldisc_ref() returns NULL
>> which callers already handle.
>> - tty buffer data stays queued until the ldisc is installed
>>
>> The sequence becomes:
>> 1. Hold ldisc_sem(write): close old ldisc, set tty->ldisc = NULL
>> 2. Release ldisc_sem(write)
>> 3. Call new_ldisc->ops->open() without ldisc_sem
>> 4. Re-acquire ldisc_sem(write): install new ldisc (or restore old)
>> 5. Release ldisc_sem(write)
>>
>> Reported-by: syzbot+de610eeef174bd59a8a3@syzkaller.appspotmail.com
>> Closes: https://syzkaller.appspot.com/bug?extid=de610eeef174bd59a8a3
>> Signed-off-by: Yun Zhou <yun.zhou@windriver.com>
>> ---
>
> Sashiko has some comments:
> https://sashiko.dev/#/patchset/20260724084648.3879356-1-yun.zhou@windriver.com
> are they correct?
>
I've already responded to Sashiko about the "New issue" - this scenario
does not exist [1] . I'm not sure why my reply didn't CC you - my bad.
https://sashiko.dev/#/message/3894bbdd-1930-4ad4-8b28-431a162aece0%40windriver.com
As for the pre-existing issue, it's very hard to trigger and practically
impossible in real-world scenarios. If we really need to fix it, I'll
send a separate patch series for it later.
BR,
Yun
prev parent reply other threads:[~2026-07-31 5:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 8:46 [PATCH v3] tty: ldisc: fix deadlock between ldisc_sem and rtnl_mutex Yun Zhou
2026-07-25 8:47 ` sashiko-bot
2026-07-26 3:25 ` Zhou, Yun
2026-07-30 14:50 ` Greg KH
2026-07-31 5:54 ` Zhou, Yun [this message]
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=ccbe9f70-8ec6-41f3-af8e-2cbf84b4d652@windriver.com \
--to=yun.zhou@windriver.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=horms@kernel.org \
--cc=jirislaby@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=socketcan@hartkopp.net \
/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