lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z9FNCH5_skuEBYGl@mini-arch>
Date: Wed, 12 Mar 2025 01:59:52 -0700
From: Stanislav Fomichev <stfomichev@...il.com>
To: Kuniyuki Iwashima <kuniyu@...zon.com>
Cc: sdf@...ichev.me, andrew+netdev@...n.ch, atenart@...nel.org,
	davem@...emloft.net, edumazet@...gle.com, enjuk@...zon.com,
	horms@...nel.org, jasowang@...hat.com, jdamato@...tly.com,
	kory.maincent@...tlin.com, kuba@...nel.org,
	linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
	pabeni@...hat.com, willemdebruijn.kernel@...il.com
Subject: Re: [PATCH net-next 2/2] net: reorder dev_addr_sem lock

On 03/11, Kuniyuki Iwashima wrote:
> From: Stanislav Fomichev <sdf@...ichev.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!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ