net: Protect dev->name by seqlock.
authorKuniyuki Iwashima <kuniyu@amazon.com>
Tue, 30 Apr 2024 01:58:12 +0000 (18:58 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 2 May 2024 01:37:07 +0000 (18:37 -0700)
commit0840556e5a3a331b6932ef17dd4bc94445df3297
treecb33bf3e2a686696f6db4ce268fe77c5f3c9836c
parenta428bfc77a4dd4ba19b7646e887fa655fcfee5a0
net: Protect dev->name by seqlock.

We will convert ioctl(SIOCGARP) to RCU, and then we need to copy
dev->name which is currently protected by rtnl_lock().

This patch does the following:

  1) Add seqlock netdev_rename_lock to protect dev->name

  2) Add netdev_copy_name() that copies dev->name to buffer
     under netdev_rename_lock

  3) Use netdev_copy_name() in netdev_get_name() and drop
     devnet_rename_sem

Suggested-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/netdev/CANn89iJEWs7AYSJqGCUABeVqOCTkErponfZdT5kV-iD=-SajnQ@mail.gmail.com/
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Link: https://lore.kernel.org/r/20240430015813.71143-7-kuniyu@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/netdevice.h
net/core/dev.c