diff options
author | Christoph Hellwig <hch@lst.de> | 2020-05-18 08:28:05 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-05-18 17:35:02 -0700 |
commit | 7c1552da900c159a13473a2106c7547746ebe4a1 (patch) | |
tree | 07c7793ab12204af32811dac6f080b8ed12e22ff /net/ipv6/route.c | |
parent | a307593a644443db12888f45eed0dafb5869e2cc (diff) | |
download | linux-7c1552da900c159a13473a2106c7547746ebe4a1.tar.bz2 |
ipv6: lift copy_from_user out of ipv6_route_ioctl
Prepare for better compat ioctl handling by moving the user copy out
of ipv6_route_ioctl.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/route.c')
-rw-r--r-- | net/ipv6/route.c | 44 |
1 files changed, 16 insertions, 28 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index a8b4add0b545..a52ec1b86432 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -4336,41 +4336,29 @@ static void rtmsg_to_fib6_config(struct net *net, }; } -int ipv6_route_ioctl(struct net *net, unsigned int cmd, void __user *arg) +int ipv6_route_ioctl(struct net *net, unsigned int cmd, struct in6_rtmsg *rtmsg) { struct fib6_config cfg; - struct in6_rtmsg rtmsg; int err; - switch (cmd) { - case SIOCADDRT: /* Add a route */ - case SIOCDELRT: /* Delete a route */ - if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) - return -EPERM; - err = copy_from_user(&rtmsg, arg, - sizeof(struct in6_rtmsg)); - if (err) - return -EFAULT; + if (cmd != SIOCADDRT && cmd != SIOCDELRT) + return -EINVAL; + if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) + return -EPERM; - rtmsg_to_fib6_config(net, &rtmsg, &cfg); + rtmsg_to_fib6_config(net, rtmsg, &cfg); - rtnl_lock(); - switch (cmd) { - case SIOCADDRT: - err = ip6_route_add(&cfg, GFP_KERNEL, NULL); - break; - case SIOCDELRT: - err = ip6_route_del(&cfg, NULL); - break; - default: - err = -EINVAL; - } - rtnl_unlock(); - - return err; + rtnl_lock(); + switch (cmd) { + case SIOCADDRT: + err = ip6_route_add(&cfg, GFP_KERNEL, NULL); + break; + case SIOCDELRT: + err = ip6_route_del(&cfg, NULL); + break; } - - return -EINVAL; + rtnl_unlock(); + return err; } /* |