[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250312022757.69200-1-kuniyu@amazon.com>
Date: Tue, 11 Mar 2025 19:27:53 -0700
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <sdf@...ichev.me>
CC: <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>, <kuniyu@...zon.com>, <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
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 ?
> - err = netif_set_mac_address_user(dev, sa, extack);
> + err = netif_set_mac_address(dev, sa, extack);
> kfree(sa);
> - if (err)
> + if (err) {
> + up_write(&dev_addr_sem);
> goto errout;
> + }
> status |= DO_SETLINK_MODIFIED;
> +
> + up_write(&dev_addr_sem);
> }
>
> if (tb[IFLA_MTU]) {
> --
> 2.48.1
Powered by blists - more mailing lists