netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stanislav Fomichev <stfomichev@gmail.com>
To: Kuniyuki Iwashima <kuniyu@amazon.com>
Cc: sdf@fomichev.me, andrew+netdev@lunn.ch, atenart@kernel.org,
	davem@davemloft.net, edumazet@google.com, enjuk@amazon.com,
	horms@kernel.org, jasowang@redhat.com, jdamato@fastly.com,
	kory.maincent@bootlin.com, kuba@kernel.org,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	pabeni@redhat.com, willemdebruijn.kernel@gmail.com
Subject: Re: [PATCH net-next 2/2] net: reorder dev_addr_sem lock
Date: Wed, 12 Mar 2025 01:59:52 -0700	[thread overview]
Message-ID: <Z9FNCH5_skuEBYGl@mini-arch> (raw)
In-Reply-To: <20250312022757.69200-1-kuniyu@amazon.com>

On 03/11, Kuniyuki Iwashima wrote:
> From: Stanislav Fomichev <sdf@fomichev.me>
> Date: Tue, 11 Mar 2025 01:45:07 -0700
> > diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> > index 9355058bf996..c9d44dad203d 100644
> > --- a/net/core/rtnetlink.c
> > +++ b/net/core/rtnetlink.c
> > @@ -3080,21 +3080,32 @@ static int do_setlink(const struct sk_buff *skb, struct net_device *dev,
> >  		struct sockaddr *sa;
> >  		int len;
> >  
> > +		netdev_unlock_ops(dev);
> > +
> > +		/* dev_addr_sem is an outer lock, enforce proper ordering */
> > +		down_write(&dev_addr_sem);
> > +		netdev_lock_ops(dev);
> > +
> >  		len = sizeof(sa_family_t) + max_t(size_t, dev->addr_len,
> >  						  sizeof(*sa));
> >  		sa = kmalloc(len, GFP_KERNEL);
> >  		if (!sa) {
> > +			up_write(&dev_addr_sem);
> >  			err = -ENOMEM;
> >  			goto errout;
> >  		}
> >  		sa->sa_family = dev->type;
> >  		memcpy(sa->sa_data, nla_data(tb[IFLA_ADDRESS]),
> >  		       dev->addr_len);
> 
> Can we move down_write() and netdev_lock_ops() here ?

Should be doable, yes, will also remove that up_write from the !sa
error condition. Will do, thanks for the review!

  reply	other threads:[~2025-03-12  8:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-11  8:45 [PATCH net-next 0/2] net: bring back dev_addr_sem Stanislav Fomichev
2025-03-11  8:45 ` [PATCH net-next 1/2] Revert "net: replace dev_addr_sem with netdev instance lock" Stanislav Fomichev
2025-03-12  2:11   ` Kuniyuki Iwashima
2025-03-11  8:45 ` [PATCH net-next 2/2] net: reorder dev_addr_sem lock Stanislav Fomichev
2025-03-12  2:27   ` Kuniyuki Iwashima
2025-03-12  8:59     ` Stanislav Fomichev [this message]
2025-03-12 13:25 ` [PATCH net-next 0/2] net: bring back dev_addr_sem Lei Yang

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=Z9FNCH5_skuEBYGl@mini-arch \
    --to=stfomichev@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=atenart@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=enjuk@amazon.com \
    --cc=horms@kernel.org \
    --cc=jasowang@redhat.com \
    --cc=jdamato@fastly.com \
    --cc=kory.maincent@bootlin.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --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 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).