mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shuai Liu <847807867@qq.com>
To: zhangjiayi1014@gmail.com,willemdebruijn.kernel@gmail.com,jasowangio@gmail.com
Cc: andrew+netdev@lunn.ch,davem@davemloft.net,edumazet@kernel.org,kuba@kernel.org,pabeni@redhat.com,mst@redhat.com,847807867@qq.com,netdev@vger.kernel.org,linux-kernel@vger.kernel.org,syzbot+a2220efe757ca2a7358d@syzkaller.appspotmail.com,syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH net] tap: do not take consumer_lock in tap_sock_destruct()
Message-ID: <tencent_21D314AEB4D8C2C489FB8D74348B93FC7706@qq.com> (raw)
In-Reply-To: <20261126090306.3416278-1-zhangjiayi1014@gmail.com>

Hi Jiayi,

Thanks for your detailed analysis — your fix is definitely the right
approach, and you caught a flaw in my reasoning that I missed entirely.

My patch only changed tap_sock_destruct() to acquire consumer_lock with
spin_lock_irqsave(), assuming that making the destructor take the lock
with uniform BH semantics would be enough. But I completely failed to
consider the other holders of consumer_lock: tap_do_read(), tap_poll(),
tap_peek_len() and vhost_net_buf_produce() all take it with plain
spin_lock(), and tap_queue_resize() with spin_lock_bh(). So lockdep
would still flag the inconsistency between {IN-SOFTIRQ-W} and
{SOFTIRQ-ON-W} for the same lock class — exactly as you demonstrated.

Your argument that the destructor does not need the lock at all is
solid: tap_put_queue() runs synchronize_rcu() and RCU_INIT_POINTER(q->tap,
NULL) before the final sock_put(), so tap_handle_frame() can no longer
reach the queue via RCU dereference. The dellink paths unregister the rx
handler before tap_del_queues(). No other path can race with the
destructor.

Applied your patch locally, builds cleanly and passes checkpatch strict
with 0 errors / 0 warnings.

Please ignore my earlier patch — it's wrong and should not be applied.

Reviewed-by: Shuai Liu <847807867@qq.com>
Tested-by: Shuai Liu <847807867@qq.com>

Shuai

      reply	other threads:[~2026-11-26 10:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  9:03 Jiayi Zhang
2026-11-26 10:16 ` Shuai Liu [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=tencent_21D314AEB4D8C2C489FB8D74348B93FC7706@qq.com \
    --to=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=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=syzbot+a2220efe757ca2a7358d@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=willemdebruijn.kernel@gmail.com \
    --cc=zhangjiayi1014@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

all inboxes | Powered by JetHome®