aboutsummaryrefslogtreecommitdiffstats
path: root/net/socket.c
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2013-11-18 12:04:13 -0500
committerBen Hutchings <bhutchings@solarflare.com>2013-11-18 18:50:13 -0500
commit590d4693fb1c96ce441d11c6d1acb413a90b62e5 (patch)
treee00ec0ec4ea195390e7a746abb6fbed8ce3960cf /net/socket.c
parent417c3522b3202dacce4873cfb0190459fbce95c5 (diff)
net/compat: Merge multiple implementations of ifreq::ifr_data conversion
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Diffstat (limited to 'net/socket.c')
-rw-r--r--net/socket.c49
1 files changed, 6 insertions, 43 deletions
diff --git a/net/socket.c b/net/socket.c
index fbb6ec13b1f4..7a766ab83ca5 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2964,11 +2964,8 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
2964 struct compat_ifreq __user *ifr32) 2964 struct compat_ifreq __user *ifr32)
2965{ 2965{
2966 struct ifreq kifr; 2966 struct ifreq kifr;
2967 struct ifreq __user *uifr;
2968 mm_segment_t old_fs; 2967 mm_segment_t old_fs;
2969 int err; 2968 int err;
2970 u32 data;
2971 void __user *datap;
2972 2969
2973 switch (cmd) { 2970 switch (cmd) {
2974 case SIOCBONDENSLAVE: 2971 case SIOCBONDENSLAVE:
@@ -2985,26 +2982,13 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
2985 set_fs(old_fs); 2982 set_fs(old_fs);
2986 2983
2987 return err; 2984 return err;
2988 case SIOCBONDSLAVEINFOQUERY:
2989 case SIOCBONDINFOQUERY:
2990 uifr = compat_alloc_user_space(sizeof(*uifr));
2991 if (copy_in_user(&uifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
2992 return -EFAULT;
2993
2994 if (get_user(data, &ifr32->ifr_ifru.ifru_data))
2995 return -EFAULT;
2996
2997 datap = compat_ptr(data);
2998 if (put_user(datap, &uifr->ifr_ifru.ifru_data))
2999 return -EFAULT;
3000
3001 return dev_ioctl(net, cmd, uifr);
3002 default: 2985 default:
3003 return -ENOIOCTLCMD; 2986 return -ENOIOCTLCMD;
3004 } 2987 }
3005} 2988}
3006 2989
3007static int siocdevprivate_ioctl(struct net *net, unsigned int cmd, 2990/* Handle ioctls that use ifreq::ifr_data and just need struct ifreq converted */
2991static int compat_ifr_data_ioctl(struct net *net, unsigned int cmd,
3008 struct compat_ifreq __user *u_ifreq32) 2992 struct compat_ifreq __user *u_ifreq32)
3009{ 2993{
3010 struct ifreq __user *u_ifreq64; 2994 struct ifreq __user *u_ifreq64;
@@ -3104,27 +3088,6 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
3104 return err; 3088 return err;
3105} 3089}
3106 3090
3107static int compat_siocshwtstamp(struct net *net, struct compat_ifreq __user *uifr32)
3108{
3109 void __user *uptr;
3110 compat_uptr_t uptr32;
3111 struct ifreq __user *uifr;
3112
3113 uifr = compat_alloc_user_space(sizeof(*uifr));
3114 if (copy_in_user(uifr, uifr32, sizeof(struct compat_ifreq)))
3115 return -EFAULT;
3116
3117 if (get_user(uptr32, &uifr32->ifr_data))
3118 return -EFAULT;
3119
3120 uptr = compat_ptr(uptr32);
3121
3122 if (put_user(uptr, &uifr->ifr_data))
3123 return -EFAULT;
3124
3125 return dev_ioctl(net, SIOCSHWTSTAMP, uifr);
3126}
3127
3128struct rtentry32 { 3091struct rtentry32 {
3129 u32 rt_pad1; 3092 u32 rt_pad1;
3130 struct sockaddr rt_dst; /* target address */ 3093 struct sockaddr rt_dst; /* target address */
@@ -3236,7 +3199,7 @@ static int compat_sock_ioctl_trans(struct file *file, struct socket *sock,
3236 struct net *net = sock_net(sk); 3199 struct net *net = sock_net(sk);
3237 3200
3238 if (cmd >= SIOCDEVPRIVATE && cmd <= (SIOCDEVPRIVATE + 15)) 3201 if (cmd >= SIOCDEVPRIVATE && cmd <= (SIOCDEVPRIVATE + 15))
3239 return siocdevprivate_ioctl(net, cmd, argp); 3202 return compat_ifr_data_ioctl(net, cmd, argp);
3240 3203
3241 switch (cmd) { 3204 switch (cmd) {
3242 case SIOCSIFBR: 3205 case SIOCSIFBR:
@@ -3256,8 +3219,6 @@ static int compat_sock_ioctl_trans(struct file *file, struct socket *sock,
3256 case SIOCBONDENSLAVE: 3219 case SIOCBONDENSLAVE:
3257 case SIOCBONDRELEASE: 3220 case SIOCBONDRELEASE:
3258 case SIOCBONDSETHWADDR: 3221 case SIOCBONDSETHWADDR:
3259 case SIOCBONDSLAVEINFOQUERY:
3260 case SIOCBONDINFOQUERY:
3261 case SIOCBONDCHANGEACTIVE: 3222 case SIOCBONDCHANGEACTIVE:
3262 return bond_ioctl(net, cmd, argp); 3223 return bond_ioctl(net, cmd, argp);
3263 case SIOCADDRT: 3224 case SIOCADDRT:
@@ -3267,8 +3228,10 @@ static int compat_sock_ioctl_trans(struct file *file, struct socket *sock,
3267 return do_siocgstamp(net, sock, cmd, argp); 3228 return do_siocgstamp(net, sock, cmd, argp);
3268 case SIOCGSTAMPNS: 3229 case SIOCGSTAMPNS:
3269 return do_siocgstampns(net, sock, cmd, argp); 3230 return do_siocgstampns(net, sock, cmd, argp);
3231 case SIOCBONDSLAVEINFOQUERY:
3232 case SIOCBONDINFOQUERY:
3270 case SIOCSHWTSTAMP: 3233 case SIOCSHWTSTAMP:
3271 return compat_siocshwtstamp(net, argp); 3234 return compat_ifr_data_ioctl(net, cmd, argp);
3272 3235
3273 case FIOSETOWN: 3236 case FIOSETOWN:
3274 case SIOCSPGRP: 3237 case SIOCSPGRP: