diff mbox series

[v1,net-next,1/3] dev: Acquire netdev_rename_lock before restoring dev->name in dev_change_name().

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

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 6 this patch: 6
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 79 this patch: 79
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2025-01-15--12-00 (tests: 882)

Commit Message

Kuniyuki Iwashima Jan. 15, 2025, 9:55 a.m. UTC
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(+)

Comments

Eric Dumazet Jan. 15, 2025, 10:22 a.m. UTC | #1
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 mbox series

Patch

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;