remove compat_alloc_user_space()
Subsystems (7)
v5 cover remove compat_alloc_user_space()
From: Arnd Bergmann <[email protected]>
This is the fifth version of my series, now spanning four patches instead of two, with a new approach for handling struct ifreq compatibility after I realized that my earlier approach introduces additional problems.
The idea here is to always push down the compat conversion deeper into the call stack: rather than pretending to be native mode with a modified copy of the original data on the user space stack, have the code that actually works on the data understand the difference between native and compat versions.
I have spent a long time looking at all drivers that implement an ndo_do_ioctl callback to verify that my assumptions are correct. This has led to a series of 29 additional patches that I am not including here but will post separately, fixing a number of bugs in SIOCDEVPRIVATE ioctls, removing dead code, and splitting ndo_do_ioctl into two new ndo callbacks for private and ethernet specific commands.
The patches are largely identical to v4 that I sent last November, with small fixes for issues pointed out by Jakub and my own randconfig build bot.
Arnd
Changes in v5:
- Rebase to v5.14-rc2
- Fix a few build issues
Changes in v4:
- build fix without CONFIG_INET
- build fix without CONFIG_COMPAT
- style fixes pointed out by hch
Changes in v3:
- complete rewrite of the series
Arnd Bergmann (4):
ethtool: improve compat ioctl handling
net: socket: rework SIOC?IFMAP ioctls
net: socket: simplify dev_ifconf handling
net: socket: rework compat_ifreq_ioctl()
include/linux/compat.h | 82 +++++------ include/linux/ethtool.h | 4 - include/linux/inetdevice.h | 9 ++ include/linux/netdevice.h | 12 +- net/appletalk/ddp.c | 4 +- net/core/dev_ioctl.c | 152 ++++++++++--------- net/ethtool/ioctl.c | 136 +++++++++++++++-- net/ieee802154/socket.c | 4 +- net/ipv4/af_inet.c | 6 +- net/ipv4/devinet.c | 4 +- net/qrtr/qrtr.c | 4 +- net/socket.c | 292 +++++++++---------------------------- 12 files changed, 333 insertions(+), 376 deletions(-)
Signature · 1 line
2.29.2
PATCH v5 1/4 ethtool: improve compat ioctl handling
From: Arnd Bergmann <[email protected]>
The ethtool compat ioctl handling is hidden away in net/socket.c, which introduces a couple of minor oddities:
- The implementation may end up diverging, as seen in the RXNFC extension in commit 84a1d9c48200 ("net: ethtool: extend RXNFC API to support RSS spreading of filter matches") that does not work in compat mode.
- Most architectures do not need the compat handling at all because u64 and compat_u64 have the same alignment.
- On x86, the conversion is done for both x32 and i386 user space, but it's actually wrong to do it for x32 and cannot work there.
- On 32-bit Arm, it never worked for compat oabi user space, since that needs to do the same conversion but does not.
- It would be nice to get rid of both compat_alloc_user_space() and copy_in_user() throughout the kernel.
None of these actually seems to be a serious problem that real users are likely to encounter, but fixing all of them actually leads to code that is both shorter and more readable.
---
Changes in v2:
- remove extraneous 'inline' keyword (davem)
- split helper functions into smaller units (hch)
- remove arm oabi check with missing dependency (0day bot)
--- include/linux/ethtool.h | 4 -- net/ethtool/ioctl.c | 136 +++++++++++++++++++++++++++++++++++----- net/socket.c | 125 +----------------------------------- 3 files changed, 121 insertions(+), 144 deletions(-)
include/linux/ethtool.h +0 -4
@@ -17,8 +17,6 @@#include <linux/compat.h> #include <uapi/linux/ethtool.h> -#ifdef CONFIG_COMPAT -struct compat_ethtool_rx_flow_spec {u32 flow_type;union ethtool_flow_union h_u;
@@ -38,8 +36,6 @@ struct compat_ethtool_rxnfc {u32 rule_locs[]; }; -#endif /* CONFIG_COMPAT */ -#include <linux/rculist.h> /**
net/ethtool/ioctl.c +120 -16
178 lines not on this page · raw message
net/socket.c +1 -124
143 lines not on this page · raw message
Signature · 1 line
2.29.2
PATCH v5 2/4 net: socket: rework SIOC?IFMAP ioctls
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
SIOCGIFMAP and SIOCSIFMAP currently require compat_alloc_user_space() and copy_in_user() for compat mode.
Move the compat handling into the location where the structures are actually used, to avoid using those interfaces and get a clearer implementation.
---
changes in v3:
- complete rewrite
changes in v2:
- fix building with CONFIG_COMPAT disabled (0day bot)
- split up dev_ifmap() into more readable helpers (hch)
- move rcu_read_unlock() for readability (hch)
--- include/linux/compat.h | 18 ++++++------ net/core/dev_ioctl.c | 64 +++++++++++++++++++++++++++++++++--------- net/socket.c | 39 ++----------------------- 3 files changed, 62 insertions(+), 59 deletions(-)
include/linux/compat.h +9 -9
@@ -95,6 +95,15 @@ struct compat_iovec {compat_size_t iov_len; }; +struct compat_ifmap { +compat_ulong_t mem_start; +compat_ulong_t mem_end; +unsigned short base_addr; +unsigned char irq; +unsigned char dma; +unsigned char port; +}; +#ifdef CONFIG_COMPAT #ifndef compat_user_stack_pointer
@@ -317,15 +326,6 @@ typedef struct compat_sigevent { } _sigev_un; } compat_sigevent_t; -struct compat_ifmap { -compat_ulong_t mem_start; -compat_ulong_t mem_end; -unsigned short base_addr; -unsigned char irq; -unsigned char dma; -unsigned char port; -}; -struct compat_if_settings {unsigned int type;/* Type of physical device or protocol */ unsigned int size;/* Size of the data allocated by the caller */
net/core/dev_ioctl.c +51 -13
82 lines not on this page · raw message
net/socket.c +2 -37
@@ -3241,40 +3241,6 @@ static int compat_ifreq_ioctl(struct net *net, struct socket *sock,return err; } -static int compat_sioc_ifmap (struct net *net,unsigned int cmd, -struct compat_ifreq __user *uifr32) -{ -struct ifreq ifr; -struct compat_ifmap __user *uifmap32; -int err; - - uifmap32 = &uifr32->ifr_ifru.ifru_map; - err =copy_from_user (&ifr, uifr32,sizeof (ifr.ifr_name)); - err |=get_user (ifr.ifr_map.mem_start, &uifmap32->mem_start); - err |=get_user (ifr.ifr_map.mem_end, &uifmap32->mem_end); - err |=get_user (ifr.ifr_map.base_addr, &uifmap32->base_addr); - err |=get_user (ifr.ifr_map.irq, &uifmap32->irq); - err |=get_user (ifr.ifr_map.dma, &uifmap32->dma); - err |=get_user (ifr.ifr_map.port, &uifmap32->port); -if (err) -return -EFAULT ; - - err =dev_ioctl (net, cmd, &ifr,NULL ); - -if (cmd ==SIOCGIFMAP && !err) { - err =copy_to_user (uifr32, &ifr,sizeof (ifr.ifr_name)); - err |=put_user (ifr.ifr_map.mem_start, &uifmap32->mem_start); - err |=put_user (ifr.ifr_map.mem_end, &uifmap32->mem_end); - err |=put_user (ifr.ifr_map.base_addr, &uifmap32->base_addr); - err |=put_user (ifr.ifr_map.irq, &uifmap32->irq); - err |=put_user (ifr.ifr_map.dma, &uifmap32->dma); - err |=put_user (ifr.ifr_map.port, &uifmap32->port); -if (err) - err = -EFAULT ; - } -return err; -} -/* Since old style bridge ioctl's endup using SIOCDEVPRIVATE * for some operations; this forces use of the newer bridge-utils that * use compatible ioctls
@@ -3308,9 +3274,6 @@ static int compat_sock_ioctl_trans(struct file *file, struct socket *sock,return compat_dev_ifconf (net, argp);case SIOCWANDEV :return compat_siocwandev (net, argp); -case SIOCGIFMAP : -case SIOCSIFMAP : -return compat_sioc_ifmap (net, cmd, argp);case SIOCGSTAMP_OLD :case SIOCGSTAMPNS_OLD :if (!sock->ops->gettstamp)
@@ -3340,6 +3303,8 @@ static int compat_sock_ioctl_trans(struct file *file, struct socket *sock,case SIOCGIFFLAGS :case SIOCSIFFLAGS : +case SIOCGIFMAP : +case SIOCSIFMAP :case SIOCGIFMETRIC :case SIOCSIFMETRIC :case SIOCGIFMTU :
Signature · 1 line
2.29.2
PATCH v5 4/4 net: socket: rework compat_ifreq_ioctl()
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
compat_ifreq_ioctl() is one of the last users of copy_in_user() and compat_alloc_user_space(), as it attempts to convert the 'struct ifreq' arguments from 32-bit to 64-bit format as used by dev_ioctl() and a couple of socket family specific interpretations.
The current implementation works correctly when calling dev_ioctl(), inet_ioctl(), ieee802154_sock_ioctl(), atalk_ioctl(), qrtr_ioctl() and packet_ioctl(). The ioctl handlers for x25, netrom, rose and x25 do not interpret the arguments and only block the corresponding commands, so they do not care.
For af_inet6 and af_decnet however, the compat conversion is slightly incorrect, as it will copy more data than the native handler accesses, both of them use a structure that is shorter than ifreq.
Replace the copy_in_user() conversion with a pair of accessor functions to read and write the ifreq data in place with the correct length where needed, while leaving the other ones to copy the (already compatible) structures directly.
--- include/linux/compat.h | 53 ++++++++++---------- include/linux/netdevice.h | 2 + net/appletalk/ddp.c | 4 +- net/ieee802154/socket.c | 4 +- net/ipv4/af_inet.c | 6 +-- net/qrtr/qrtr.c | 4 +- net/socket.c | 103 ++++++++++++++++++++++++-------------- 7 files changed, 103 insertions(+), 73 deletions(-)
include/linux/compat.h +27 -26
@@ -109,6 +109,33 @@ struct compat_ifconf {compat_uptr_t ifcbuf; }; +struct compat_if_settings { +unsigned int type;/* Type of physical device or protocol */ +unsigned int size;/* Size of the data allocated by the caller */ +compat_uptr_t ifs_ifsu;/* union of pointers */ +}; + +struct compat_ifreq { +union { +char ifrn_name[IFNAMSIZ ];/* if name, e.g. "en0" */ + } ifr_ifrn; +union { +struct sockaddr ifru_addr; +struct sockaddr ifru_dstaddr; +struct sockaddr ifru_broadaddr; +struct sockaddr ifru_netmask; +struct sockaddr ifru_hwaddr; +short ifru_flags; +compat_int_t ifru_ivalue; +compat_int_t ifru_mtu; +struct compat_ifmap ifru_map; +char ifru_slave[IFNAMSIZ ];/* Just fits the size */ +char ifru_newname[IFNAMSIZ ]; +compat_uptr_t ifru_data; +struct compat_if_settings ifru_settings; + } ifr_ifru; +}; +#ifdef CONFIG_COMPAT #ifndef compat_user_stack_pointer
@@ -331,32 +358,6 @@ typedef struct compat_sigevent { } _sigev_un; } compat_sigevent_t; -struct compat_ifreq { -union { -char ifrn_name[IFNAMSIZ ];/* if name, e.g. "en0" */ - } ifr_ifrn; -union { -struct sockaddr ifru_addr; -struct sockaddr ifru_dstaddr; -struct sockaddr ifru_broadaddr; -struct sockaddr ifru_netmask; -struct sockaddr ifru_hwaddr; -short ifru_flags; -compat_int_t ifru_ivalue; -compat_int_t ifru_mtu; -struct compat_ifmap ifru_map; -char ifru_slave[IFNAMSIZ ];/* Just fits the size */ -char ifru_newname[IFNAMSIZ ]; -compat_caddr_t ifru_data; -struct compat_if_settings ifru_settings; - } ifr_ifru; -}; - -struct compat_ifconf { -compat_int_t ifc_len;/* size of buffer */ -compat_caddr_t ifcbuf; -}; -struct compat_robust_list {compat_uptr_t next; };
include/linux/netdevice.h +2 -0
@@ -4004,6 +4004,8 @@ int netdev_rx_handler_register(struct net_device *dev,void netdev_rx_handler_unregister (struct net_device *dev);bool dev_valid_name (const char *name); +int get_user_ifreq (struct ifreq *ifr,void __user **ifrdata,void __user *arg); +int put_user_ifreq (struct ifreq *ifr,void __user *arg);int dev_ioctl (struct net *net,unsigned int cmd,struct ifreq *ifr,bool *need_copyout);int dev_ifconf (struct net *net,struct ifconf __user *ifc);
net/appletalk/ddp.c +2 -2
@@ -666,7 +666,7 @@ static int atif_ioctl(int cmd, void __user *arg)struct rtentry rtdef;int add_route; -if (copy_from_user (&atreq, arg,sizeof (atreq))) +if (get_user_ifreq (&atreq,NULL , arg))return -EFAULT ; dev =__dev_get_by_name (&init_net, atreq.ifr_name);
@@ -865,7 +865,7 @@ static int atif_ioctl(int cmd, void __user *arg)return 0 ; } -return copy_to_user (arg, &atreq,sizeof (atreq)) ? -EFAULT :0 ; +return put_user_ifreq (&atreq, arg); }static int atrtr_ioctl_addrt (struct rtentry *rt)
net/ieee802154/socket.c +2 -2
@@ -129,7 +129,7 @@ static int ieee802154_dev_ioctl(struct sock *sk, struct ifreq __user *arg,int ret = -ENOIOCTLCMD ;struct net_device *dev; -if (copy_from_user (&ifr, arg,sizeof (struct ifreq ))) +if (get_user_ifreq (&ifr,NULL , arg))return -EFAULT ; ifr.ifr_name[IFNAMSIZ -1 ] =0 ;
@@ -143,7 +143,7 @@ static int ieee802154_dev_ioctl(struct sock *sk, struct ifreq __user *arg,if (dev->type ==ARPHRD_IEEE802154 && dev->netdev_ops->ndo_do_ioctl) ret = dev->netdev_ops->ndo_do_ioctl (dev, &ifr, cmd); -if (!ret &©_to_user (arg, &ifr,sizeof (struct ifreq ))) +if (!ret &&put_user_ifreq (&ifr, arg)) ret = -EFAULT ;dev_put (dev);
net/ipv4/af_inet.c +3 -3
@@ -953,10 +953,10 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)case SIOCGIFNETMASK :case SIOCGIFDSTADDR :case SIOCGIFPFLAGS : -if (copy_from_user (&ifr, p,sizeof (struct ifreq ))) +if (get_user_ifreq (&ifr,NULL , p))return -EFAULT ; err =devinet_ioctl (net, cmd, &ifr); -if (!err &©_to_user (p, &ifr,sizeof (struct ifreq ))) +if (!err &&put_user_ifreq (&ifr, p)) err = -EFAULT ;break ;
@@ -966,7 +966,7 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)case SIOCSIFDSTADDR :case SIOCSIFPFLAGS :case SIOCSIFFLAGS : -if (copy_from_user (&ifr, p,sizeof (struct ifreq ))) +if (get_user_ifreq (&ifr,NULL , p))return -EFAULT ; err =devinet_ioctl (net, cmd, &ifr);break ;
net/qrtr/qrtr.c +2 -2
@@ -1153,14 +1153,14 @@ static int qrtr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) rc =put_user (len, (int __user *)argp);break ;case SIOCGIFADDR : -if (copy_from_user (&ifr, argp,sizeof (ifr))) { +if (get_user_ifreq (&ifr,NULL , argp)) { rc = -EFAULT ;break ; } sq = (struct sockaddr_qrtr *)&ifr.ifr_addr; *sq = ipc->us; -if (copy_to_user (argp, &ifr,sizeof (ifr))) { +if (put_user_ifreq (&ifr, argp)) { rc = -EFAULT ;break ; }
net/socket.c +65 -38
141 lines not on this page · raw message
Signature · 1 line
2.29.2
PATCH v5 3/4 net: socket: simplify dev_ifconf handling
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
The dev_ifconf() calling conventions make compat handling more complicated than necessary, simplify this by moving the in_compat_syscall() check into the function. The implementation can be simplified further, based on the knowledge that the dynamic registration is only ever used for IPv4.
--- include/linux/compat.h | 11 +++-- include/linux/inetdevice.h | 9 ++++ include/linux/netdevice.h | 10 +---- net/core/dev_ioctl.c | 92 +++++++++++++++----------------------- net/ipv4/devinet.c | 4 +- net/socket.c | 59 ++++++------------------ 6 files changed, 66 insertions(+), 119 deletions(-)
include/linux/compat.h +5 -6
@@ -104,6 +104,11 @@ struct compat_ifmap {unsigned char port; }; +struct compat_ifconf { +compat_int_t ifc_len;/* size of buffer */ +compat_uptr_t ifcbuf; +}; +#ifdef CONFIG_COMPAT #ifndef compat_user_stack_pointer
@@ -326,12 +331,6 @@ typedef struct compat_sigevent { } _sigev_un; } compat_sigevent_t; -struct compat_if_settings { -unsigned int type;/* Type of physical device or protocol */ -unsigned int size;/* Size of the data allocated by the caller */ -compat_uptr_t ifs_ifsu;/* union of pointers */ -}; -struct compat_ifreq {union {char ifrn_name[IFNAMSIZ ];/* if name, e.g. "en0" */
include/linux/inetdevice.h +9 -0
@@ -178,6 +178,15 @@ static inline struct net_device *ip_dev_find(struct net *net, __be32 addr)int inet_addr_onlink (struct in_device *in_dev,__be32 a,__be32 b);int devinet_ioctl (struct net *net,unsigned int cmd,struct ifreq *); +#ifdef CONFIG_INET +int inet_gifconf (struct net_device *dev,char __user *buf,int len,int size); +#else +static inline int inet_gifconf (struct net_device *dev,char __user *buf, +int len,int size) +{ +return 0 ; +} +#endif void devinet_init (void );struct in_device *inetdev_by_index (struct net *,int );__be32 inet_select_addr (const struct net_device *dev,__be32 dst,int scope);
include/linux/netdevice.h +1 -9
@@ -3289,14 +3289,6 @@ static inline bool dev_has_header(const struct net_device *dev)return dev->header_ops && dev->header_ops->create; } -typedef int gifconf_func_t (struct net_device * dev,char __user * bufptr, -int len,int size); -int register_gifconf (unsigned int family,gifconf_func_t *gifconf); -static inline int unregister_gifconf (unsigned int family) -{ -return register_gifconf (family,NULL ); -} -#ifdef CONFIG_NET_FLOW_LIMIT #define FLOW_LIMIT_HISTORY (1 << 7)/* must be ^2 and !overflow buckets */ struct sd_flow_limit {
@@ -4014,7 +4006,7 @@ void netdev_rx_handler_unregister(struct net_device *dev);bool dev_valid_name (const char *name);int dev_ioctl (struct net *net,unsigned int cmd,struct ifreq *ifr,bool *need_copyout); -int dev_ifconf (struct net *net,struct ifconf *,int ); +int dev_ifconf (struct net *net,struct ifconf __user *ifc);int dev_ethtool (struct net *net,struct ifreq *);unsigned int dev_get_flags (const struct net_device *); int __dev_change_flags(struct net_device *dev, unsigned int flags,
net/core/dev_ioctl.c +36 -56
119 lines not on this page · raw message
net/ipv4/devinet.c +1 -3
@@ -1243,7 +1243,7 @@ int devinet_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr)return ret; } -static int inet_gifconf (struct net_device *dev,char __user *buf,int len,int size) +int inet_gifconf (struct net_device *dev,char __user *buf,int len,int size) {struct in_device *in_dev =__in_dev_get_rtnl (dev);const struct in_ifaddr *ifa;
@@ -2762,8 +2762,6 @@ void __init devinet_init(void)INIT_HLIST_HEAD (&inet_addr_lst[i]);register_pernet_subsys (&devinet_ops); - -register_gifconf (PF_INET , inet_gifconf);register_netdevice_notifier (&ip_netdev_notifier);queue_delayed_work (system_power_efficient_wq, &check_lifetime_work,0 );
net/socket.c +14 -45
96 lines not on this page · raw message
Signature · 1 line
2.29.2
Re: [PATCH v5 2/4] net: socket: rework SIOC?IFMAP ioctls
In reply to Arnd Bergmannnet/core/dev_ioctl.c int dev_ifconf(struct net *net, struct ifconf *ifc, int size) · line 106
Quoted 6 lines
net/core/dev_ioctl.c +6
-0+static int dev_getifmap (struct net_device *dev,struct ifreq *ifr) +{ +struct ifmap *ifmap = &ifr->ifr_map; +struct compat_ifmap *cifmap = (struct compat_ifmap *)&ifr->ifr_map; + +if (in_compat_syscall ()) {
Any reason that the cifmap declaration is outside this conditional?
net/core/dev_ioctl.c int dev_ifconf(struct net *net, struct ifconf *ifc, int size) · line 134
Quoted 8 lines
net/core/dev_ioctl.c +8
-0+static int dev_setifmap (struct net_device *dev,struct ifreq *ifr) +{ +struct compat_ifmap *cifmap = (struct compat_ifmap *)&ifr->ifr_map; + +if (!dev->netdev_ops->ndo_set_config) +return -EOPNOTSUPP ; + +if (in_compat_syscall ()) {
Same here.
Otherwise looks good:
Re: [PATCH v5 3/4] net: socket: simplify dev_ifconf handling
In reply to Arnd BergmannQuoted 3 lines
The implementation can be simplified further, based on the knowledge that the dynamic registration is only ever used
Quoted 1 line
for IPv4.
I think dropping register_gifconf (which seems like a nice cleanup!) needs to be a separate prep patch to not make this too confusing.
Quoted 16 lines
index
e6231837aff5..4727c7a3a988100644include/linux/compat.h +5
-0@@ -104,6 +104,11 @@ struct compat_ifmap {unsigned char port; }; +struct compat_ifconf { +compat_int_t ifc_len;/* size of buffer */ +compat_uptr_t ifcbuf; +}; +#ifdef CONFIG_COMPAT #ifndef compat_user_stack_pointer
include/linux/compat.h typedef struct compat_sigevent { · line 333
Quoted 8 lines
include/linux/compat.h +0
-5@@ -326,12 +331,6 @@ typedef struct compat_sigevent { } _sigev_un; } compat_sigevent_t; -struct compat_if_settings { -unsigned int type;/* Type of physical device or protocol */ -unsigned int size;/* Size of the data allocated by the caller */ -compat_uptr_t ifs_ifsu;/* union of pointers */ -};
Does this actually compile as-is? It adds a second definition of compat_ifconf but removes the still used compat_if_settings?
Maybe it would be a better idea to add a prep patch that makes as much as possible of compat.h available unconditionally instead of all these little moves.
Re: [PATCH v5 2/4] net: socket: rework SIOC?IFMAP ioctls
In reply to Christoph HellwigQuoted 9 lines · Christoph Hellwig
net/core/dev_ioctl.c int dev_ifconf(struct net *net, struct ifconf *ifc, int size) · line 106
Quoted 7 lines
net/core/dev_ioctl.c +6
-0+static int dev_getifmap (struct net_device *dev,struct ifreq *ifr) +{ +struct ifmap *ifmap = &ifr->ifr_map; +struct compat_ifmap *cifmap = (struct compat_ifmap *)&ifr->ifr_map; + +if (in_compat_syscall ()) {Any reason that the cifmap declaration is outside this conditional?
I was going for the slightly shorter version, as moving it into the block runs into the 80-character limit. I'll change it.
Quoted 11 lines
net/core/dev_ioctl.c int dev_ifconf(struct net *net, struct ifconf *ifc, int size) · line 134
Quoted 8 lines
net/core/dev_ioctl.c +8
-0+static int dev_setifmap (struct net_device *dev,struct ifreq *ifr) +{ +struct compat_ifmap *cifmap = (struct compat_ifmap *)&ifr->ifr_map; + +if (!dev->netdev_ops->ndo_set_config) +return -EOPNOTSUPP ; + +if (in_compat_syscall ()) {Same here.
Quoted 3 lines
Otherwise looks good:
Reviewed-by Christoph Hellwig <[email protected]>
Thanks!
Arnd
Re: [PATCH v5 3/4] net: socket: simplify dev_ifconf handling
In reply to Christoph HellwigQuoted 7 lines · Christoph Hellwig
Quoted 4 lines
The implementation can be simplified further, based on the knowledge that the dynamic registration is only ever used
Quoted 1 line
for IPv4.
I think dropping
register_gifconf(which seems like a nice cleanup!) needs to be a separate prep patch to not make this too confusing.
Right, good idea.
Quoted 19 lines
Quoted 19 lines
index
e6231837aff5..4727c7a3a988100644include/linux/compat.h +5
-0@@ -104,6 +104,11 @@ struct compat_ifmap {unsigned char port; }; +struct compat_ifconf { +compat_int_t ifc_len;/* size of buffer */ +compat_uptr_t ifcbuf; +}; +#ifdef CONFIG_COMPAT #ifndef compat_user_stack_pointer@@ -326,12 +331,6 @@ typedef struct compat_sigevent { } _sigev_un; } compat_sigevent_t;
Quoted 8 lines
include/linux/compat.h typedef struct compat_sigevent { · line 333
Quoted 5 lines
include/linux/compat.h +0
-5-struct compat_if_settings { -unsigned int type;/* Type of physical device or protocol */ -unsigned int size;/* Size of the data allocated by the caller */ -compat_uptr_t ifs_ifsu;/* union of pointers */ -};Does this actually compile as-is? It adds a second definition of
compat_ifconfbut removes the still usedcompat_if_settings?
Indeed it does not. I must have applied a hunk to the wrong patch in an earlier rebase, and the build bots never picked up on it because the series was fine in the end.
Quoted 3 lines
Maybe it would be a better idea to add a prep patch that makes as much as possible of
compat.havailable unconditionally instead of all these little moves.
Ok, I'll figure something out.
Arnd