Skip to content
  1. Jan 19, 2018
  2. Jan 16, 2018
    • Arnd Bergmann's avatar
      netfilter: nf_defrag: move NF_CONNTRACK bits into #ifdef · 41e4b391
      Arnd Bergmann authored
      We cannot access the skb->_nfct field when CONFIG_NF_CONNTRACK is
      disabled:
      
      net/ipv4/netfilter/nf_defrag_ipv4.c: In function 'ipv4_conntrack_defrag':
      net/ipv4/netfilter/nf_defrag_ipv4.c:83:9: error: 'struct sk_buff' has no member named '_nfct'
      net/ipv6/netfilter/nf_defrag_ipv6_hooks.c: In function 'ipv6_defrag':
      net/ipv6/netfilter/nf_defrag_ipv6_hooks.c:68:9: error: 'struct sk_buff' has no member named '_nfct'
      
      Both functions already have an #ifdef for this, so let's move the
      check in there.
      
      Fixes: 902d6a4c
      
       ("netfilter: nf_defrag: Skip defrag if NOTRACK is set")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      41e4b391
    • Arnd Bergmann's avatar
      netfilter: nf_defrag: mark xt_table structures 'const' again · b069b37a
      Arnd Bergmann authored
      As a side-effect of adding the module option, we now get a section
      mismatch warning:
      
      WARNING: net/ipv4/netfilter/iptable_raw.o(.data+0x1c): Section mismatch in reference from the variable packet_raw to the function .init.text:iptable_raw_table_init()
      The variable packet_raw references
      the function __init iptable_raw_table_init()
      If the reference is valid then annotate the
      variable with __init* or __refdata (see linux/init.h) or name the variable:
      *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console
      
      Apparently it's ok to link to a __net_init function from .rodata but not
      from .data. We can address this by rearranging the logic so that the
      structure is read-only again. Instead of writing to the .priority field
      later, we have an extra copies of the structure with that flag. An added
      advantage is that that we don't have writable function pointers with this
      approach.
      
      Fixes: 902d6a4c
      
       ("netfilter: nf_defrag: Skip defrag if NOTRACK is set")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      b069b37a
    • Subash Abhinov Kasiviswanathan's avatar
      netfilter: ipv6: nf_defrag: Pass on packets to stack per RFC2460 · 83f1999c
      Subash Abhinov Kasiviswanathan authored
      ipv6_defrag pulls network headers before fragment header. In case of
      an error, the netfilter layer is currently dropping these packets.
      This results in failure of some IPv6 standards tests which passed on
      older kernels due to the netfilter framework using cloning.
      
      The test case run here is a check for ICMPv6 error message replies
      when some invalid IPv6 fragments are sent. This specific test case is
      listed in https://www.ipv6ready.org/docs/Core_Conformance_Latest.pdf
      
      
      in the Extension Header Processing Order section.
      
      A packet with unrecognized option Type 11 is sent and the test expects
      an ICMP error in line with RFC2460 section 4.2 -
      
      11 - discard the packet and, only if the packet's Destination
           Address was not a multicast address, send an ICMP Parameter
           Problem, Code 2, message to the packet's Source Address,
           pointing to the unrecognized Option Type.
      
      Since netfilter layer now drops all invalid IPv6 frag packets, we no
      longer see the ICMP error message and fail the test case.
      
      To fix this, save the transport header. If defrag is unable to process
      the packet due to RFC2460, restore the transport header and allow packet
      to be processed by stack. There is no change for other packet
      processing paths.
      
      Tested by confirming that stack sends an ICMP error when it receives
      these packets. Also tested that fragmented ICMP pings succeed.
      
      v1->v2: Instead of cloning always, save the transport_header and
      restore it in case of this specific error. Update the title and
      commit message accordingly.
      
      Signed-off-by: default avatarSubash Abhinov Kasiviswanathan <subashab@codeaurora.org>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      83f1999c
    • Florian Westphal's avatar
      netfilter: x_tables: don't return garbage pointer on modprobe failure · e3eeacba
      Florian Westphal authored
      
      
      request_module may return a positive error result from modprobe,
      if we cast this to ERR_PTR this returns a garbage result (it passes
      IS_ERR checks).
      
      Fix it by ignoring modprobe return values entirely, just retry the
      table lookup instead.
      
      Reported-by: default avatar <syzbot+980925dbfbc7f93bc2ef@syzkaller.appspotmail.com>
      Fixes: 03d13b68 ("netfilter: xtables: add and use xt_request_find_table_lock")
      Fixes: 20651cef
      
       ("netfilter: x_tables: unbreak module auto loading")
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      e3eeacba
    • Arnd Bergmann's avatar
      netfilter: nf_tables: flow_offload depends on flow_table · 9be9d04b
      Arnd Bergmann authored
      Without CONFIG_NF_FLOW_TABLE, the new nft_flow_offload module produces
      a link error:
      
      net/netfilter/nft_flow_offload.o: In function `nft_flow_offload_iterate_cleanup':
      nft_flow_offload.c:(.text+0xb0): undefined reference to `nf_flow_table_iterate'
      net/netfilter/nft_flow_offload.o: In function `flow_offload_iterate_cleanup':
      nft_flow_offload.c:(.text+0x160): undefined reference to `flow_offload_dead'
      net/netfilter/nft_flow_offload.o: In function `nft_flow_offload_eval':
      nft_flow_offload.c:(.text+0xc4c): undefined reference to `flow_offload_alloc'
      nft_flow_offload.c:(.text+0xc64): undefined reference to `flow_offload_add'
      nft_flow_offload.c:(.text+0xc94): undefined reference to `flow_offload_free'
      
      This adds a Kconfig dependency for it.
      
      Fixes: a3c90f7a
      
       ("netfilter: nf_tables: flow offload expression")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      9be9d04b
  3. Jan 11, 2018
    • Subash Abhinov Kasiviswanathan's avatar
      netfilter: nf_defrag: Skip defrag if NOTRACK is set · 902d6a4c
      Subash Abhinov Kasiviswanathan authored
      
      
      conntrack defrag is needed only if some module like CONNTRACK or NAT
      explicitly requests it. For plain forwarding scenarios, defrag is
      not needed and can be skipped if NOTRACK is set in a rule.
      
      Since conntrack defrag is currently higher priority than raw table,
      setting NOTRACK is not sufficient. We need to move raw to a higher
      priority for iptables only.
      
      This is achieved by introducing a module parameter "raw_before_defrag"
      which allows to change the priority of raw table to place it before
      defrag. By default, the parameter is disabled and the priority of raw
      table is NF_IP_PRI_RAW to support legacy behavior. If the module
      parameter is enabled, then the priority of the raw table is set to
      NF_IP_PRI_RAW_BEFORE_DEFRAG.
      
      Signed-off-by: default avatarSubash Abhinov Kasiviswanathan <subashab@codeaurora.org>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      902d6a4c
    • Florian Westphal's avatar
      netfilter: clusterip: make sure arp hooks are available · 5ed001ba
      Florian Westphal authored
      The clusterip target needs to register an arp mangling hook,
      so make sure NF_ARP hooks are available.
      
      Fixes: 2a95183a
      
       ("netfilter: don't allocate space for arp/bridge hooks unless needed")
      Reported-by: default avatarkernel test robot <fengguang.wu@intel.com>
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      5ed001ba
    • Arnd Bergmann's avatar
      netfilter: improve flow table Kconfig dependencies · a0a97f2a
      Arnd Bergmann authored
      The newly added NF_FLOW_TABLE options cause some build failures in
      randconfig kernels:
      
      - when CONFIG_NF_CONNTRACK is disabled, or is a loadable module but
        NF_FLOW_TABLE is built-in:
      
        In file included from net/netfilter/nf_flow_table.c:8:0:
        include/net/netfilter/nf_conntrack.h:59:22: error: field 'ct_general' has incomplete type
          struct nf_conntrack ct_general;
        include/net/netfilter/nf_conntrack.h: In function 'nf_ct_get':
        include/net/netfilter/nf_conntrack.h:148:15: error: 'const struct sk_buff' has no member named '_nfct'
        include/net/netfilter/nf_conntrack.h: In function 'nf_ct_put':
        include/net/netfilter/nf_conntrack.h:157:2: error: implicit declaration of function 'nf_conntrack_put'; did you mean 'nf_ct_put'? [-Werror=implicit-function-declaration]
      
        net/netfilter/nf_flow_table.o: In function `nf_flow_offload_work_gc':
        (.text+0x1540): undefined reference to `nf_ct_delete'
      
      - when CONFIG_NF_TABLES is disabled:
      
        In file included from net/ipv6/netfilter/nf_flow_table_ipv6.c:13:0:
        include/net/netfilter/nf_tables.h: In function 'nft_gencursor_next':
        include/net/netfilter/nf_tables.h:1189:14: error: 'const struct net' has no member named 'nft'; did you mean 'nf'?
      
       - when CONFIG_NF_FLOW_TABLE_INET is enabled, but NF_FLOW_TABLE_IPV4
        or NF_FLOW_TABLE_IPV6 are not, or are loadable modules
      
        net/netfilter/nf_flow_table_inet.o: In function `nf_flow_offload_inet_hook':
        nf_flow_table_inet.c:(.text+0x94): undefined reference to `nf_flow_offload_ipv6_hook'
        nf_flow_table_inet.c:(.text+0x40): undefined reference to `nf_flow_offload_ip_hook'
      
      - when CONFIG_NF_FLOW_TABLES is disabled, but the other options are
        enabled:
      
        net/netfilter/nf_flow_table_inet.o: In function `nf_flow_offload_inet_hook':
        nf_flow_table_inet.c:(.text+0x6c): undefined reference to `nf_flow_offload_ipv6_hook'
        net/netfilter/nf_flow_table_inet.o: In function `nf_flow_inet_module_exit':
        nf_flow_table_inet.c:(.exit.text+0x8): undefined reference to `nft_unregister_flowtable_type'
        net/netfilter/nf_flow_table_inet.o: In function `nf_flow_inet_module_init':
        nf_flow_table_inet.c:(.init.text+0x8): undefined reference to `nft_register_flowtable_type'
        net/ipv4/netfilter/nf_flow_table_ipv4.o: In function `nf_flow_ipv4_module_exit':
        nf_flow_table_ipv4.c:(.exit.text+0x8): undefined reference to `nft_unregister_flowtable_type'
        net/ipv4/netfilter/nf_flow_table_ipv4.o: In function `nf_flow_ipv4_module_init':
        nf_flow_table_ipv4.c:(.init.text+0x8): undefined reference to `nft_register_flowtable_type'
      
      This adds additional Kconfig dependencies to ensure that NF_CONNTRACK and NF_TABLES
      are always visible from NF_FLOW_TABLE, and that the internal dependencies between
      the four new modules are met.
      
      Fixes: 7c23b629 ("netfilter: flow table support for the mixed IPv4/IPv6 family")
      Fixes: 09952107 ("netfilter: flow table support for IPv6")
      Fixes: 97add9f0
      
       ("netfilter: flow table support for IPv4")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      a0a97f2a
  4. Jan 10, 2018