netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: netdev@vger.kernel.org, Cong Wang <cong.wang@bytedance.com>,
	shaozhengchao <shaozhengchao@huawei.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Tom Herbert <tom@herbertland.com>,
	Eric Dumazet <edumazet@google.com>
Subject: Re: [Patch net] kcm: fix a race condition in kcm_recvmsg()
Date: Fri, 28 Oct 2022 16:27:56 -0700	[thread overview]
Message-ID: <20221028162756.6c1f64f0@kernel.org> (raw)
In-Reply-To: <Y1wrp4pL4BmUL0LE@pop-os.localdomain>

On Fri, 28 Oct 2022 12:21:11 -0700 Cong Wang wrote:
> On Tue, Oct 25, 2022 at 04:02:22PM -0700, Jakub Kicinski wrote:
> > On Sat, 22 Oct 2022 19:30:44 -0700 Cong Wang wrote:  
> > > +			spin_lock_bh(&mux->rx_lock);
> > >  			KCM_STATS_INCR(kcm->stats.rx_msgs);
> > >  			skb_unlink(skb, &sk->sk_receive_queue);
> > > +			spin_unlock_bh(&mux->rx_lock);  
> > 
> > Why not switch to __skb_unlink() at the same time?
> > Abundance of caution?  
> 
> What gain do we have? Since we have rx_lock, skb queue lock should never
> be contended?

I was thinking mostly about readability, the performance is secondary.
Other parts of the code use unlocked skb queue helpers so it may be
confusing to a reader why this on isn't, and therefore what lock
protects the queue. But no strong feelings.

  reply	other threads:[~2022-10-28 23:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-23  2:30 [Patch net] kcm: fix a race condition in kcm_recvmsg() Cong Wang
2022-10-25 23:02 ` Jakub Kicinski
2022-10-25 23:49   ` Eric Dumazet
2022-10-28 19:24     ` Cong Wang
2022-10-28 19:21   ` Cong Wang
2022-10-28 23:27     ` Jakub Kicinski [this message]
2022-11-01 20:52 ` Cong Wang

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=20221028162756.6c1f64f0@kernel.org \
    --to=kuba@kernel.org \
    --cc=cong.wang@bytedance.com \
    --cc=edumazet@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shaozhengchao@huawei.com \
    --cc=tom@herbertland.com \
    --cc=xiyou.wangcong@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;
as well as URLs for NNTP newsgroup(s).