Message ID | 20250115095545.52709-2-kuniyu@amazon.com (mailing list archive) |
---|---|
State | New |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | dev: Covnert dev_change_name() to per-netns RTNL. | expand |
On Wed, Jan 15, 2025 at 10:56 AM Kuniyuki Iwashima <kuniyu@amazon.com> wrote: > > The cited commit forgot to add netdev_rename_lock in one of the > error paths in dev_change_name(). > > Let's hold netdev_rename_lock before restoring the old dev->name. > > Fixes: 0840556e5a3a ("net: Protect dev->name by seqlock.") > Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> Reviewed-by: Eric Dumazet <edumazet@google.com>
diff --git a/net/core/dev.c b/net/core/dev.c index fda4e1039bf0..0237687d4a41 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -1277,7 +1277,9 @@ int dev_change_name(struct net_device *dev, const char *newname) rollback: ret = device_rename(&dev->dev, dev->name); if (ret) { + write_seqlock_bh(&netdev_rename_lock); memcpy(dev->name, oldname, IFNAMSIZ); + write_sequnlock_bh(&netdev_rename_lock); WRITE_ONCE(dev->name_assign_type, old_assign_type); up_write(&devnet_rename_sem); return ret;
The cited commit forgot to add netdev_rename_lock in one of the error paths in dev_change_name(). Let's hold netdev_rename_lock before restoring the old dev->name. Fixes: 0840556e5a3a ("net: Protect dev->name by seqlock.") Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> --- net/core/dev.c | 2 ++ 1 file changed, 2 insertions(+)