Commit c486da34390846b430896a407b47f0cea3a4189c

Authored by Lucian Adrian Grijincu
Committed by David S. Miller
1 parent cdf64c803e

sysctl: ipv6: use correct net in ipv6_sysctl_rtcache_flush

Before this patch issuing these commands:

  fd = open("/proc/sys/net/ipv6/route/flush")
  unshare(CLONE_NEWNET)
  write(fd, "stuff")

would flush the newly created net, not the original one.

The equivalent ipv4 code is correct (stores the net inside ->extra1).
Acked-by: Daniel Lezcano <daniel.lezcano@free.fr>

Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 10 additions and 7 deletions Side-by-side Diff

... ... @@ -2557,14 +2557,16 @@
2557 2557 int ipv6_sysctl_rtcache_flush(ctl_table *ctl, int write,
2558 2558 void __user *buffer, size_t *lenp, loff_t *ppos)
2559 2559 {
2560   - struct net *net = current->nsproxy->net_ns;
2561   - int delay = net->ipv6.sysctl.flush_delay;
2562   - if (write) {
2563   - proc_dointvec(ctl, write, buffer, lenp, ppos);
2564   - fib6_run_gc(delay <= 0 ? ~0UL : (unsigned long)delay, net);
2565   - return 0;
2566   - } else
  2560 + struct net *net;
  2561 + int delay;
  2562 + if (!write)
2567 2563 return -EINVAL;
  2564 +
  2565 + net = (struct net *)ctl->extra1;
  2566 + delay = net->ipv6.sysctl.flush_delay;
  2567 + proc_dointvec(ctl, write, buffer, lenp, ppos);
  2568 + fib6_run_gc(delay <= 0 ? ~0UL : (unsigned long)delay, net);
  2569 + return 0;
2568 2570 }
2569 2571  
2570 2572 ctl_table ipv6_route_table_template[] = {
... ... @@ -2651,6 +2653,7 @@
2651 2653  
2652 2654 if (table) {
2653 2655 table[0].data = &net->ipv6.sysctl.flush_delay;
  2656 + table[0].extra1 = net;
2654 2657 table[1].data = &net->ipv6.ip6_dst_ops.gc_thresh;
2655 2658 table[2].data = &net->ipv6.sysctl.ip6_rt_max_size;
2656 2659 table[3].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval;