1. 20 6月, 2017 3 次提交
    • F
      netns: add and use net_ns_barrier · 7866cc57
      Florian Westphal 提交于
      Quoting Joe Stringer:
        If a user loads nf_conntrack_ftp, sends FTP traffic through a network
        namespace, destroys that namespace then unloads the FTP helper module,
        then the kernel will crash.
      
      Events that lead to the crash:
      1. conntrack is created with ftp helper in netns x
      2. This netns is destroyed
      3. netns destruction is scheduled
      4. netns destruction wq starts, removes netns from global list
      5. ftp helper is unloaded, which resets all helpers of the conntracks
      via for_each_net()
      
      but because netns is already gone from list the for_each_net() loop
      doesn't include it, therefore all of these conntracks are unaffected.
      
      6. helper module unload finishes
      7. netns wq invokes destructor for rmmod'ed helper
      
      CC: "Eric W. Biederman" <ebiederm@xmission.com>
      Reported-by: NJoe Stringer <joe@ovn.org>
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Acked-by: NDavid S. Miller <davem@davemloft.net>
      Acked-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      7866cc57
    • F
      netfilter: move table iteration out of netns exit paths · 2c41f33c
      Florian Westphal 提交于
      We only need to iterate & remove in case of module removal;
      for netns destruction all conntracks will be removed anyway.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      2c41f33c
    • X
      netfilter: ipt_CLUSTERIP: do not hold dev · 202f59af
      Xin Long 提交于
      It's a terrible thing to hold dev in iptables target. When the dev is
      being removed, unregister_netdevice has to wait for the dev to become
      free. dmesg will keep logging the err:
      
        kernel:unregister_netdevice: waiting for veth0_in to become free. \
        Usage count = 1
      
      until iptables rules with this target are removed manually.
      
      The worse thing is when deleting a netns, a virtual nic will be deleted
      instead of reset to init_net in default_device_ops exit/exit_batch. As
      it is earlier than to flush the iptables rules in iptable_filter_net_ops
      exit, unregister_netdevice will block to wait for the nic to become free.
      
      As unregister_netdevice is actually waiting for iptables rules flushing
      while iptables rules have to be flushed after unregister_netdevice. This
      'dead lock' will cause unregister_netdevice to block there forever. As
      the netns is not available to operate at that moment, iptables rules can
      not even be flushed manually either.
      
      The reproducer can be:
      
        # ip netns add test
        # ip link add veth0_in type veth peer name veth0_out
        # ip link set veth0_in netns test
        # ip netns exec test ip link set lo up
        # ip netns exec test ip link set veth0_in up
        # ip netns exec test iptables -I INPUT -d 1.2.3.4 -i veth0_in -j \
          CLUSTERIP --new --clustermac 89:d4:47:eb:9a:fa --total-nodes 3 \
          --local-node 1 --hashmode sourceip-sourceport
        # ip netns del test
      
      This issue can be triggered by all virtual nics with ipt_CLUSTERIP.
      
      This patch is to fix it by not holding dev in ipt_CLUSTERIP, but saving
      the dev->ifindex instead of the dev.
      
      As Pablo Neira Ayuso's suggestion, it will refresh c->ifindex and dev's
      mc by registering a netdevice notifier, just as what xt_TEE does. So it
      removes the old codes updating dev's mc, and also no need to initialize
      c->ifindex with dev->ifindex.
      
      But as one config can be shared by more than one targets, and the netdev
      notifier is per config, not per target. It couldn't get e->ip.iniface
      in the notifier handler. So e->ip.iniface has to be saved into config.
      
      Note that for backwards compatibility, this patch doesn't remove the
      codes checking if the dev exists before creating a config.
      
      v1->v2:
        - As Pablo Neira Ayuso's suggestion, register a netdevice notifier to
          manage c->ifindex and dev's mc.
      Reported-by: NJianlin Shi <jishi@redhat.com>
      Signed-off-by: NXin Long <lucien.xin@gmail.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      202f59af
  2. 29 5月, 2017 20 次提交
  3. 23 5月, 2017 17 次提交