All of lore.kernel.org
 help / color / mirror / Atom feed
From: willemb@google.com
To: Shuai Liu <847807867@qq.com>,
	willemdebruijn.kernel@gmail.com, jasowangio@gmail.com,
	 andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
	 kuba@kernel.org, pabeni@redhat.com
Cc: syzbot+a2220efe757ca2a7358d@syzkaller.appspotmail.com,
	 netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Shuai Liu <847807867@qq.com>
Subject: Re: [PATCH] net: tap: fix inconsistent lock state in tap_sock_destruct
Date: Thu, 26 Nov 2026 12:34:25 -0500	[thread overview]
Message-ID: <willemb.9c5fa5d89f88@google.com> (raw)
In-Reply-To: <tencent_934E899D4D24BB3B4827B2A0C9D73461E00A@qq.com>

Shuai Liu wrote:
> tap_sock_destruct() calls ptr_ring_cleanup(), which in turn uses
> ptr_ring_consume() with a plain spin_lock() for consumer_lock.
> This destructor runs in two distinct contexts:

> 1. softirq context: from softirq rx drop paths via
>     skb_release_head_state() -> sock_wfree() -> __sk_free() ->
>     sk_destruct() -> tap_sock_destruct().  In softirq the BH
>     state is already disabled, so consumer_lock is taken with
>     SOFTIRQ-ON-W semantics.

> 2. process context: from tap_release() -> __fput() -> sk_free()
>     -> sk_destruct() -> tap_sock_destruct() (triggered by
>     close_range syscall).  Here softirq is enabled when the
>     same consumer_lock is taken.

> lockdep flags this as inconsistent {IN-SOFTIRQ-W} ->
> {SOFTIRQ-ON-W} usage of (&r->consumer_lock) and warns about
> a possible deadlock scenario.

> Fix by hand-rolling the cleanup loop with spin_lock_irqsave() /
> spin_unlock_irqrestore() so consumer_lock is always taken from a
> uniform softirq state.  irqsave is a no-op on the softirq path
> (interrupts are already off), so there is no extra cost there.

> Reported-by: syzbot  
> <syzbot+a2220efe757ca2a7358d@syzkaller.appspotmail.com>
> Link: https://syzkaller.appspot.com/bug?extid=a2220efe757ca2a7358d
> Signed-off-by: Shuai Liu <847807867@qq.com>

Dropped in line with your below comment, thanks

https://lore.kernel.org/netdev/tencent_21D314AEB4D8C2C489FB8D74348B93FC7706@qq.com/

  reply	other threads:[~2026-11-26 17:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  0:34 [PATCH] net: tap: fix inconsistent lock state in tap_sock_destruct Shuai Liu
2026-11-26 17:34 ` willemb [this message]
2026-11-27  1:00 ` netdev-bot+sashiko

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=willemb.9c5fa5d89f88@google.com \
    --to=willemb@google.com \
    --cc=847807867@qq.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=jasowangio@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=syzbot+a2220efe757ca2a7358d@syzkaller.appspotmail.com \
    --cc=willemdebruijn.kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.