arp: Random clean up and RCU conversion for ioctl(SIOCGARP).
Subsystems (3)
v3 cover arp: Random clean up and RCU conversion for ioctl(SIOCGARP).
arp_ioctl() holds rtnl_lock() regardless of cmd (SIOCDARP, SIOCSARP, and SIOCGARP) to get net_device by __dev_get_by_name() and copy dev->name safely.
In the SIOCGARP path, arp_req_get() calls neigh_lookup(), which looks up a neighbour entry under RCU.
This series cleans up ioctl() code a bit and extends the RCU section not to take rtnl_lock() and instead use dev_get_by_name_rcu() and netdev_copy_name() for SIOCGARP.
Changes:
v3:
Add Patch 6 to read dev->name safely under seqlock.
v2: https://lore.kernel.org/netdev/[email protected]/
Patch 5: s/!IS_ERR/IS_ERR/ in arp_req_delete().
v1: https://lore.kernel.org/netdev/[email protected]/
Kuniyuki Iwashima (7):
arp: Move ATF_COM setting in arp_req_set().
arp: Validate netmask earlier for SIOCDARP and SIOCSARP in
arp_ioctl().
arp: Factorise ip_route_output() call in arp_req_set() and
arp_req_delete(). arp: Remove a nest in arp_req_get().
arp: Get dev after calling arp_req_(delete|set|get)().
net: Protect dev->name by seqlock.
arp: Convert ioctl(SIOCGARP) to RCU.
include/linux/netdevice.h | 1 + net/core/dev.c | 27 ++++- net/ipv4/arp.c | 203 +++++++++++++++++++++++--------------- 3 files changed, 147 insertions(+), 84 deletions(-)
Signature · 1 line
2.30.2
PATCH v3 1/7 arp: Move ATF_COM setting in arp_req_set().
In arp_req_set(), if ATF_PERM is set in arpreq.arp_flags, ATF_COM is set automatically.
The flag will be used later for neigh_update() only when a neighbour entry is found.
Let's set ATF_COM just before calling neigh_update().
--- net/ipv4/arp.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/ipv4/arp.c +6 -3
@@ -1054,8 +1054,7 @@ static int arp_req_set(struct net *net, struct arpreq *r,return arp_req_set_public (net, r, dev); ip = ((struct sockaddr_in *)&r->arp_pa)->sin_addr.s_addr; -if (r->arp_flags &ATF_PERM ) - r->arp_flags |=ATF_COM ; +if (!dev) {struct rtable *rt =ip_route_output (net, ip,0 ,0 ,0 ,RT_SCOPE_LINK );
@@ -1092,8 +1091,12 @@ static int arp_req_set(struct net *net, struct arpreq *r, err =PTR_ERR (neigh);if (!IS_ERR (neigh)) {unsigned int state =NUD_STALE ; -if (r->arp_flags &ATF_PERM ) + +if (r->arp_flags &ATF_PERM ) { + r->arp_flags |=ATF_COM ; state =NUD_PERMANENT ; + } + err = neigh_update(neigh, (r->arp_flags & ATF_COM) ? r->arp_ha.sa_data : NULL, state, NEIGH_UPDATE_F_OVERRIDE |
Signature · 1 line
2.30.2
PATCH v3 2/7 arp: Validate netmask earlier for SIOCDARP and SIOCSARP in arp_ioctl().
In reply to Kuniyuki IwashimaWhen ioctl(SIOCDARP/SIOCSARP) is issued with ATF_PUBL, r.arp_netmask must be 0.0.0.0 or 255.255.255.255.
Currently, the netmask is validated in arp_req_delete_public() or arp_req_set_public() under rtnl_lock().
We have ATF_NETMASK test in arp_ioctl() before holding rtnl_lock(), so let's move the netmask validation there.
--- net/ipv4/arp.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)
net/ipv4/arp.c +15 -12
@@ -1023,11 +1023,8 @@ static int arp_req_set_proxy(struct net *net, struct net_device *dev, int on)static int arp_req_set_public (struct net *net,struct arpreq *r,struct net_device *dev) { -__be32 ip = ((struct sockaddr_in *)&r->arp_pa)->sin_addr.s_addr;__be32 mask = ((struct sockaddr_in *)&r->arp_netmask)->sin_addr.s_addr; -if (mask && mask !=htonl (0xFFFFFFFF )) -return -EINVAL ;if (!dev && (r->arp_flags &ATF_COM )) { dev =dev_getbyhwaddr_rcu (net, r->arp_ha.sa_family, r->arp_ha.sa_data);
@@ -1035,6 +1032,8 @@ static int arp_req_set_public(struct net *net, struct arpreq *r,return -ENODEV ; }if (mask) { +__be32 ip = ((struct sockaddr_in *)&r->arp_pa)->sin_addr.s_addr; +if (!pneigh_lookup (&arp_tbl, net, &ip, dev,1 ))return -ENOBUFS ;return 0 ;
@@ -1171,14 +1170,13 @@ int arp_invalidate(struct net_device *dev, __be32 ip, bool force)static int arp_req_delete_public (struct net *net,struct arpreq *r,struct net_device *dev) { -__be32 ip = ((struct sockaddr_in *) &r->arp_pa)->sin_addr.s_addr;__be32 mask = ((struct sockaddr_in *)&r->arp_netmask)->sin_addr.s_addr; -if (mask ==htonl (0xFFFFFFFF )) -return pneigh_delete (&arp_tbl, net, &ip, dev); +if (mask) { +__be32 ip = ((struct sockaddr_in *)&r->arp_pa)->sin_addr.s_addr; -if (mask) -return -EINVAL ; +return pneigh_delete (&arp_tbl, net, &ip, dev); + }return arp_req_set_proxy (net, dev,0 ); }
@@ -1211,9 +1209,10 @@ static int arp_req_delete(struct net *net, struct arpreq *r,int arp_ioctl (struct net *net,unsigned int cmd,void __user *arg) { -int err; -struct arpreq r;struct net_device *dev =NULL ; +struct arpreq r; +__be32 *netmask; +int err;switch (cmd) {case SIOCDARP :
@@ -1236,9 +1235,13 @@ int arp_ioctl(struct net *net, unsigned int cmd, void __user *arg)if (!(r.arp_flags &ATF_PUBL ) && (r.arp_flags & (ATF_NETMASK |ATF_DONTPUB )))return -EINVAL ; + + netmask = &((struct sockaddr_in *)&r.arp_netmask)->sin_addr.s_addr;if (!(r.arp_flags &ATF_NETMASK )) - ((struct sockaddr_in *)&r.arp_netmask)->sin_addr.s_addr = -htonl (0xFFFFFFFFUL ); + *netmask =htonl (0xFFFFFFFFUL ); +else if (*netmask && *netmask !=htonl (0xFFFFFFFFUL )) +return -EINVAL ; +rtnl_lock ();if (r.arp_dev[0 ]) { err = -ENODEV ;
Signature · 1 line
2.30.2
PATCH v3 3/7 arp: Factorise ip_route_output() call in arp_req_set() and arp_req_delete().
In reply to Kuniyuki IwashimaWhen ioctl(SIOCDARP/SIOCSARP) is issued for non-proxy entry (no ATF_COM) without arpreq.arp_dev[] set, arp_req_set() and arp_req_delete() looks up dev based on IPv4 address by ip_route_output().
Let's factorise the same code as arp_req_dev().
--- net/ipv4/arp.c | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-)
net/ipv4/arp.c +30 -20
@@ -1003,6 +1003,27 @@ static int arp_rcv(struct sk_buff *skb, struct net_device *dev,* User level interface (ioctl) */ +static struct net_device *arp_req_dev (struct net *net,struct arpreq *r) +{ +struct net_device *dev; +struct rtable *rt; +__be32 ip; + + ip = ((struct sockaddr_in *)&r->arp_pa)->sin_addr.s_addr; + + rt =ip_route_output (net, ip,0 ,0 ,0 ,RT_SCOPE_LINK ); +if (IS_ERR (rt)) +return ERR_CAST (rt); + + dev = rt->dst.dev; +ip_rt_put (rt); + +if (!dev) +return ERR_PTR (-EINVAL ); + +return dev; +} +/* * Set (create) an ARP cache entry. */
@@ -1045,25 +1066,17 @@ static int arp_req_set_public(struct net *net, struct arpreq *r,static int arp_req_set (struct net *net,struct arpreq *r,struct net_device *dev) { -__be32 ip;struct neighbour *neigh; +__be32 ip;int err;if (r->arp_flags &ATF_PUBL )return arp_req_set_public (net, r, dev); - ip = ((struct sockaddr_in *)&r->arp_pa)->sin_addr.s_addr; -if (!dev) { -struct rtable *rt =ip_route_output (net, ip,0 ,0 ,0 , -RT_SCOPE_LINK ); - -if (IS_ERR (rt)) -return PTR_ERR (rt); - dev = rt->dst.dev; -ip_rt_put (rt); -if (!dev) -return -EINVAL ; + dev =arp_req_dev (net, r); +if (IS_ERR (dev)) +return PTR_ERR (dev); }switch (dev->type) {#if IS_ENABLED (CONFIG_FDDI )
@@ -1086,6 +1099,8 @@ static int arp_req_set(struct net *net, struct arpreq *r,break ; } + ip = ((struct sockaddr_in *)&r->arp_pa)->sin_addr.s_addr; + neigh =__neigh_lookup_errno (&arp_tbl, &ip, dev); err =PTR_ERR (neigh);if (!IS_ERR (neigh)) {
@@ -1191,14 +1206,9 @@ static int arp_req_delete(struct net *net, struct arpreq *r, ip = ((struct sockaddr_in *)&r->arp_pa)->sin_addr.s_addr;if (!dev) { -struct rtable *rt =ip_route_output (net, ip,0 ,0 ,0 , -RT_SCOPE_LINK ); -if (IS_ERR (rt)) -return PTR_ERR (rt); - dev = rt->dst.dev; -ip_rt_put (rt); -if (!dev) -return -EINVAL ; + dev =arp_req_dev (net, r); +if (IS_ERR (dev)) +return PTR_ERR (dev); }return arp_invalidate (dev, ip, true); }
Signature · 1 line
2.30.2
PATCH v3 4/7 arp: Remove a nest in arp_req_get().
In reply to Kuniyuki IwashimaThis is a prep patch to make the following changes tidy.
No functional change intended.
--- net/ipv4/arp.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-)
net/ipv4/arp.c +18 -13
@@ -1138,23 +1138,28 @@ static int arp_req_get(struct arpreq *r, struct net_device *dev) {__be32 ip = ((struct sockaddr_in *) &r->arp_pa)->sin_addr.s_addr;struct neighbour *neigh; -int err = -ENXIO ; neigh =neigh_lookup (&arp_tbl, &ip, dev); -if (neigh) { -if (!(READ_ONCE (neigh->nud_state) &NUD_NOARP )) { -read_lock_bh (&neigh->lock); -memcpy (r->arp_ha.sa_data, neigh->ha, -min (dev->addr_len,sizeof (r->arp_ha.sa_data_min))); - r->arp_flags =arp_state_to_flags (neigh); -read_unlock_bh (&neigh->lock); - r->arp_ha.sa_family = dev->type; -strscpy (r->arp_dev, dev->name,sizeof (r->arp_dev)); - err =0 ; - } +if (!neigh) +return -ENXIO ; + +if (READ_ONCE (neigh->nud_state) &NUD_NOARP ) {neigh_release (neigh); +return -ENXIO ; } -return err; + +read_lock_bh (&neigh->lock); +memcpy (r->arp_ha.sa_data, neigh->ha, +min (dev->addr_len,sizeof (r->arp_ha.sa_data_min))); + r->arp_flags =arp_state_to_flags (neigh); +read_unlock_bh (&neigh->lock); + +neigh_release (neigh); + + r->arp_ha.sa_family = dev->type; +strscpy (r->arp_dev, dev->name,sizeof (r->arp_dev)); + +return 0 ; }int arp_invalidate (struct net_device *dev,__be32 ip,bool force)
Signature · 1 line
2.30.2
PATCH v3 5/7 arp: Get dev after calling arp_req_(delete|set|get)().
In reply to Kuniyuki Iwashimaarp_ioctl() holds rtnl_lock() first regardless of cmd (SIOCDARP, SIOCSARP, and SIOCGARP) to get net_device by __dev_get_by_name() and copy dev->name safely.
In the SIOCGARP path, arp_req_get() calls neigh_lookup(), which looks up a neighbour entry under RCU.
We will extend the RCU section not to take rtnl_lock() and instead use dev_get_by_name_rcu() for SIOCGARP.
As a preparation, let's move __dev_get_by_name() into another function and call it from arp_req_delete(), arp_req_set(), and arp_req_get().
--- net/ipv4/arp.c | 86 +++++++++++++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 36 deletions(-)
net/ipv4/arp.c +50 -36
@@ -1003,12 +1003,36 @@ static int arp_rcv(struct sk_buff *skb, struct net_device *dev,* User level interface (ioctl) */ +static struct net_device *arp_req_dev_by_name (struct net *net,struct arpreq *r) +{ +struct net_device *dev; + + dev =__dev_get_by_name (net, r->arp_dev); +if (!dev) +return ERR_PTR (-ENODEV ); + +/* Mmmm... It is wrong... ARPHRD_NETROM == 0 */ +if (!r->arp_ha.sa_family) + r->arp_ha.sa_family = dev->type; + +if ((r->arp_flags &ATF_COM ) && r->arp_ha.sa_family != dev->type) +return ERR_PTR (-EINVAL ); + +return dev; +} +static struct net_device *arp_req_dev (struct net *net,struct arpreq *r) {struct net_device *dev;struct rtable *rt;__be32 ip; +if (r->arp_dev[0 ]) +return arp_req_dev_by_name (net, r); + +if (r->arp_flags &ATF_PUBL ) +return NULL ; + ip = ((struct sockaddr_in *)&r->arp_pa)->sin_addr.s_addr; rt =ip_route_output (net, ip,0 ,0 ,0 ,RT_SCOPE_LINK );
@@ -1063,21 +1087,20 @@ static int arp_req_set_public(struct net *net, struct arpreq *r,return arp_req_set_proxy (net, dev,1 ); } -static int arp_req_set (struct net *net,struct arpreq *r, -struct net_device *dev) +static int arp_req_set (struct net *net,struct arpreq *r) {struct neighbour *neigh; +struct net_device *dev;__be32 ip;int err; + dev =arp_req_dev (net, r); +if (IS_ERR (dev)) +return PTR_ERR (dev); +if (r->arp_flags &ATF_PUBL )return arp_req_set_public (net, r, dev); -if (!dev) { - dev =arp_req_dev (net, r); -if (IS_ERR (dev)) -return PTR_ERR (dev); - }switch (dev->type) {#if IS_ENABLED (CONFIG_FDDI )case ARPHRD_FDDI :
@@ -1134,10 +1157,18 @@ static unsigned int arp_state_to_flags(struct neighbour *neigh)* Get an ARP cache entry. */ -static int arp_req_get (struct arpreq *r,struct net_device *dev) +static int arp_req_get (struct net *net,struct arpreq *r) {__be32 ip = ((struct sockaddr_in *) &r->arp_pa)->sin_addr.s_addr;struct neighbour *neigh; +struct net_device *dev; + +if (!r->arp_dev[0 ]) +return -ENODEV ; + + dev =arp_req_dev_by_name (net, r); +if (IS_ERR (dev)) +return PTR_ERR (dev); neigh =neigh_lookup (&arp_tbl, &ip, dev);if (!neigh)
@@ -1201,20 +1232,20 @@ static int arp_req_delete_public(struct net *net, struct arpreq *r,return arp_req_set_proxy (net, dev,0 ); } -static int arp_req_delete (struct net *net,struct arpreq *r, -struct net_device *dev) +static int arp_req_delete (struct net *net,struct arpreq *r) { +struct net_device *dev;__be32 ip; + dev =arp_req_dev (net, r); +if (IS_ERR (dev)) +return PTR_ERR (dev); +if (r->arp_flags &ATF_PUBL )return arp_req_delete_public (net, r, dev); ip = ((struct sockaddr_in *)&r->arp_pa)->sin_addr.s_addr; -if (!dev) { - dev =arp_req_dev (net, r); -if (IS_ERR (dev)) -return PTR_ERR (dev); - } +return arp_invalidate (dev, ip, true); }
@@ -1224,7 +1255,6 @@ static int arp_req_delete(struct net *net, struct arpreq *r,int arp_ioctl (struct net *net,unsigned int cmd,void __user *arg) { -struct net_device *dev =NULL ;struct arpreq r;__be32 *netmask;int err;
@@ -1258,35 +1288,19 @@ int arp_ioctl(struct net *net, unsigned int cmd, void __user *arg)return -EINVAL ;rtnl_lock (); -if (r.arp_dev[0 ]) { - err = -ENODEV ; - dev =__dev_get_by_name (net, r.arp_dev); -if (!dev) - goto out; - -/* Mmmm... It is wrong... ARPHRD_NETROM==0 */ -if (!r.arp_ha.sa_family) - r.arp_ha.sa_family = dev->type; - err = -EINVAL ; -if ((r.arp_flags &ATF_COM ) && r.arp_ha.sa_family != dev->type) - goto out; - }else if (cmd ==SIOCGARP ) { - err = -ENODEV ; - goto out; - }switch (cmd) {case SIOCDARP : - err =arp_req_delete (net, &r, dev); + err =arp_req_delete (net, &r);break ;case SIOCSARP : - err =arp_req_set (net, &r, dev); + err =arp_req_set (net, &r);break ;case SIOCGARP : - err =arp_req_get (&r, dev); + err =arp_req_get (net, &r);break ; } -out: +rtnl_unlock ();if (cmd ==SIOCGARP && !err &©_to_user (arg, &r,sizeof (r))) err = -EFAULT ;
Signature · 1 line
2.30.2
PATCH v3 6/7 net: Protect dev->name by seqlock.
In reply to Kuniyuki IwashimaWe 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
--- include/linux/netdevice.h | 1 + net/core/dev.c | 27 +++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-)
include/linux/netdevice.h +1 -0
@@ -3136,6 +3136,7 @@ struct net_device *netdev_get_by_name(struct net *net, const char *name, netdevice_tracker *tracker, gfp_t gfp);struct net_device *dev_get_by_index_rcu (struct net *net,int ifindex);struct net_device *dev_get_by_napi_id (unsigned int napi_id); +void netdev_copy_name (struct net_device *dev,char *name); static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
net/core/dev.c +23 -4
@@ -940,6 +940,18 @@ struct net_device *dev_get_by_napi_id(unsigned int napi_id) }EXPORT_SYMBOL (dev_get_by_napi_id); +static DEFINE_SEQLOCK (netdev_rename_lock); + +void netdev_copy_name (struct net_device *dev,char *name) +{ +unsigned int seq; + +do { + seq =read_seqbegin (&netdev_rename_lock); +strscpy (name, dev->name,IFNAMSIZ ); + }while (read_seqretry (&netdev_rename_lock, seq)); +} +/** * netdev_get_name - get a netdevice name, knowing its ifindex. * @net: network namespace
@@ -951,7 +963,6 @@ int netdev_get_name(struct net *net, char *name, int ifindex)struct net_device *dev;int ret; -down_read (&devnet_rename_sem);rcu_read_lock (); dev =dev_get_by_index_rcu (net, ifindex);
@@ -960,12 +971,11 @@ int netdev_get_name(struct net *net, char *name, int ifindex) goto out; } -strcpy (name, dev->name); +netdev_copy_name (dev, name); ret =0 ; out:rcu_read_unlock (); -up_read (&devnet_rename_sem);return ret; }
@@ -1217,7 +1227,10 @@ int dev_change_name(struct net_device *dev, const char *newname)memcpy (oldname, dev->name,IFNAMSIZ ); +write_seqlock (&netdev_rename_lock); err =dev_get_valid_name (net, dev, newname); +write_sequnlock (&netdev_rename_lock); +if (err <0 ) {up_write (&devnet_rename_sem);return err;
@@ -1257,7 +1270,9 @@ int dev_change_name(struct net_device *dev, const char *newname)if (err >=0 ) { err = ret;down_write (&devnet_rename_sem); +write_seqlock (&netdev_rename_lock);memcpy (dev->name, oldname,IFNAMSIZ ); +write_sequnlock (&netdev_rename_lock);memcpy (oldname, newname,IFNAMSIZ );WRITE_ONCE (dev->name_assign_type, old_assign_type); old_assign_type =NET_NAME_RENAMED ;
@@ -11404,8 +11419,12 @@ int __dev_change_net_namespace(struct net_device *dev, struct net *net,dev_net_set (dev, net); dev->ifindex = new_ifindex; -if (new_name[0 ])/* Rename the netdev to prepared name */ +if (new_name[0 ]) { +/* Rename the netdev to prepared name */ +write_seqlock (&netdev_rename_lock);strscpy (dev->name, new_name,IFNAMSIZ ); +write_sequnlock (&netdev_rename_lock); + }/* Fixup kobjects */ dev_set_uevent_suppress (&dev->dev,1 );
Signature · 1 line
2.30.2
PATCH v3 7/7 arp: Convert ioctl(SIOCGARP) to RCU.
In reply to Kuniyuki Iwashimaioctl(SIOCGARP) holds rtnl_lock() to get netdev by __dev_get_by_name() and copy dev->name safely and calls neigh_lookup() later, which looks up a neighbour entry under RCU.
Let's replace __dev_get_by_name() with dev_get_by_name_rcu() and strscpy() with netdev_copy_name() to avoid locking rtnl_lock().
--- net/ipv4/arp.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-)
net/ipv4/arp.c +18 -10
@@ -1003,11 +1003,15 @@ static int arp_rcv(struct sk_buff *skb, struct net_device *dev,* User level interface (ioctl) */ -static struct net_device *arp_req_dev_by_name (struct net *net,struct arpreq *r) +static struct net_device *arp_req_dev_by_name (struct net *net,struct arpreq *r, +bool getarp) {struct net_device *dev; - dev =__dev_get_by_name (net, r->arp_dev); +if (getarp) + dev =dev_get_by_name_rcu (net, r->arp_dev); +else + dev =__dev_get_by_name (net, r->arp_dev);if (!dev)return ERR_PTR (-ENODEV );
@@ -1028,7 +1032,7 @@ static struct net_device *arp_req_dev(struct net *net, struct arpreq *r)__be32 ip;if (r->arp_dev[0 ]) -return arp_req_dev_by_name (net, r); +return arp_req_dev_by_name (net, r, false);if (r->arp_flags &ATF_PUBL )return NULL ;
@@ -1166,7 +1170,7 @@ static int arp_req_get(struct net *net, struct arpreq *r)if (!r->arp_dev[0 ])return -ENODEV ; - dev =arp_req_dev_by_name (net, r); + dev =arp_req_dev_by_name (net, r, true);if (IS_ERR (dev))return PTR_ERR (dev);
@@ -1188,7 +1192,7 @@ static int arp_req_get(struct net *net, struct arpreq *r)neigh_release (neigh); r->arp_ha.sa_family = dev->type; -strscpy (r->arp_dev, dev->name,sizeof (r->arp_dev)); +netdev_copy_name (dev, r->arp_dev);return 0 ; }
@@ -1287,23 +1291,27 @@ int arp_ioctl(struct net *net, unsigned int cmd, void __user *arg)else if (*netmask && *netmask !=htonl (0xFFFFFFFFUL ))return -EINVAL ; -rtnl_lock (); -switch (cmd) {case SIOCDARP : +rtnl_lock (); err =arp_req_delete (net, &r); +rtnl_unlock ();break ;case SIOCSARP : +rtnl_lock (); err =arp_req_set (net, &r); +rtnl_unlock ();break ;case SIOCGARP : +rcu_read_lock (); err =arp_req_get (net, &r); +rcu_read_unlock (); + +if (!err &©_to_user (arg, &r,sizeof (r))) + err = -EFAULT ;break ; } -rtnl_unlock (); -if (cmd ==SIOCGARP && !err &©_to_user (arg, &r,sizeof (r))) - err = -EFAULT ;return err; }
Signature · 1 line
2.30.2
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Mon, 29 Apr 2024 18:58:06 -0700 you wrote:
arp_ioctl()holdsrtnl_lock()regardless of cmd (SIOCDARP, SIOCSARP, and SIOCGARP) to getnet_deviceby__dev_get_by_name()and copydev->namesafely.In the SIOCGARP path,
arp_req_get()callsneigh_lookup(), which looks up a neighbour entry under RCU.[...]
Here is the summary with links:
- [v3,net-next,1/7] arp: Move ATF_COM setting in arp_req_set().
https://git.kernel.org/netdev/net-next/c/42033d0cfc86 - [v3,net-next,2/7] arp: Validate netmask earlier for SIOCDARP and SIOCSARP in arp_ioctl(). https://git.kernel.org/netdev/net-next/c/0592367424bb - [v3,net-next,3/7] arp: Factorise ip_route_output() call in arp_req_set() and arp_req_delete(). https://git.kernel.org/netdev/net-next/c/f8696133f6aa - [v3,net-next,4/7] arp: Remove a nest in arp_req_get(). https://git.kernel.org/netdev/net-next/c/51e9ba48d487 - [v3,net-next,5/7] arp: Get dev after calling arp_req_(delete|set|get)(). https://git.kernel.org/netdev/net-next/c/a428bfc77a4d - [v3,net-next,6/7] net: Protect dev->name by seqlock. https://git.kernel.org/netdev/net-next/c/0840556e5a3a - [v3,net-next,7/7] arp: Convert ioctl(SIOCGARP) to RCU. https://git.kernel.org/netdev/net-next/c/bf4ea58874df
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html