22 Jul, 2018

1 commit

  • commit 11ff7288beb2b7da889a014aff0a7b80bf8efcf3 upstream.

    the ebtables evaluation loop expects targets to return
    positive values (jumps), or negative values (absolute verdicts).

    This is completely different from what xtables does.
    In xtables, targets are expected to return the standard netfilter
    verdicts, i.e. NF_DROP, NF_ACCEPT, etc.

    ebtables will consider these as jumps.

    Therefore reject any target found due to unspec fallback.
    v2: also reject watchers. ebtables ignores their return value, so
    a target that assumes skb ownership (and returns NF_STOLEN) causes
    use-after-free.

    The only watchers in the 'ebtables' front-end are log and nflog;
    both have AF_BRIDGE specific wrappers on kernel side.

    Reported-by: syzbot+2b43f681169a2a0d306a@syzkaller.appspotmail.com
    Signed-off-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Florian Westphal
     

17 Jul, 2018

1 commit

  • commit c568503ef02030f169c9e19204def610a3510918 upstream.

    syzbot reports following splat:

    BUG: KMSAN: uninit-value in ebt_stp_mt_check+0x24b/0x450
    net/bridge/netfilter/ebt_stp.c:162
    ebt_stp_mt_check+0x24b/0x450 net/bridge/netfilter/ebt_stp.c:162
    xt_check_match+0x1438/0x1650 net/netfilter/x_tables.c:506
    ebt_check_match net/bridge/netfilter/ebtables.c:372 [inline]
    ebt_check_entry net/bridge/netfilter/ebtables.c:702 [inline]

    The uninitialised access is
    xt_mtchk_param->nft_compat

    ... which should be set to 0.
    Fix it by zeroing the struct beforehand, same for tgchk.

    ip(6)tables targetinfo uses c99-style initialiser, so no change
    needed there.

    Reported-by: syzbot+da4494182233c23a5fcf@syzkaller.appspotmail.com
    Fixes: 55917a21d0cc0 ("netfilter: x_tables: add context to know if extension runs from nft_compat")
    Signed-off-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Florian Westphal
     

08 Jul, 2018

1 commit

  • [ Upstream commit 94c752f99954797da583a84c4907ff19e92550a4 ]

    strlcpy() can't be safely used on a user-space provided string,
    as it can try to read beyond the buffer's end, if the latter is
    not NULL terminated.

    Leveraging the above, syzbot has been able to trigger the following
    splat:

    BUG: KASAN: stack-out-of-bounds in strlcpy include/linux/string.h:300
    [inline]
    BUG: KASAN: stack-out-of-bounds in compat_mtw_from_user
    net/bridge/netfilter/ebtables.c:1957 [inline]
    BUG: KASAN: stack-out-of-bounds in ebt_size_mwt
    net/bridge/netfilter/ebtables.c:2059 [inline]
    BUG: KASAN: stack-out-of-bounds in size_entry_mwt
    net/bridge/netfilter/ebtables.c:2155 [inline]
    BUG: KASAN: stack-out-of-bounds in compat_copy_entries+0x96c/0x14a0
    net/bridge/netfilter/ebtables.c:2194
    Write of size 33 at addr ffff8801b0abf888 by task syz-executor0/4504

    CPU: 0 PID: 4504 Comm: syz-executor0 Not tainted 4.17.0-rc2+ #40
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
    Google 01/01/2011
    Call Trace:
    __dump_stack lib/dump_stack.c:77 [inline]
    dump_stack+0x1b9/0x294 lib/dump_stack.c:113
    print_address_description+0x6c/0x20b mm/kasan/report.c:256
    kasan_report_error mm/kasan/report.c:354 [inline]
    kasan_report.cold.7+0x242/0x2fe mm/kasan/report.c:412
    check_memory_region_inline mm/kasan/kasan.c:260 [inline]
    check_memory_region+0x13e/0x1b0 mm/kasan/kasan.c:267
    memcpy+0x37/0x50 mm/kasan/kasan.c:303
    strlcpy include/linux/string.h:300 [inline]
    compat_mtw_from_user net/bridge/netfilter/ebtables.c:1957 [inline]
    ebt_size_mwt net/bridge/netfilter/ebtables.c:2059 [inline]
    size_entry_mwt net/bridge/netfilter/ebtables.c:2155 [inline]
    compat_copy_entries+0x96c/0x14a0 net/bridge/netfilter/ebtables.c:2194
    compat_do_replace+0x483/0x900 net/bridge/netfilter/ebtables.c:2285
    compat_do_ebt_set_ctl+0x2ac/0x324 net/bridge/netfilter/ebtables.c:2367
    compat_nf_sockopt net/netfilter/nf_sockopt.c:144 [inline]
    compat_nf_setsockopt+0x9b/0x140 net/netfilter/nf_sockopt.c:156
    compat_ip_setsockopt+0xff/0x140 net/ipv4/ip_sockglue.c:1279
    inet_csk_compat_setsockopt+0x97/0x120 net/ipv4/inet_connection_sock.c:1041
    compat_tcp_setsockopt+0x49/0x80 net/ipv4/tcp.c:2901
    compat_sock_common_setsockopt+0xb4/0x150 net/core/sock.c:3050
    __compat_sys_setsockopt+0x1ab/0x7c0 net/compat.c:403
    __do_compat_sys_setsockopt net/compat.c:416 [inline]
    __se_compat_sys_setsockopt net/compat.c:413 [inline]
    __ia32_compat_sys_setsockopt+0xbd/0x150 net/compat.c:413
    do_syscall_32_irqs_on arch/x86/entry/common.c:323 [inline]
    do_fast_syscall_32+0x345/0xf9b arch/x86/entry/common.c:394
    entry_SYSENTER_compat+0x70/0x7f arch/x86/entry/entry_64_compat.S:139
    RIP: 0023:0xf7fb3cb9
    RSP: 002b:00000000fff0c26c EFLAGS: 00000282 ORIG_RAX: 000000000000016e
    RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000000000
    RDX: 0000000000000080 RSI: 0000000020000300 RDI: 00000000000005f4
    RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
    R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000

    The buggy address belongs to the page:
    page:ffffea0006c2afc0 count:0 mapcount:0 mapping:0000000000000000 index:0x0
    flags: 0x2fffc0000000000()
    raw: 02fffc0000000000 0000000000000000 0000000000000000 00000000ffffffff
    raw: 0000000000000000 ffffea0006c20101 0000000000000000 0000000000000000
    page dumped because: kasan: bad access detected

    Fix the issue replacing the unsafe function with strscpy() and
    taking care of possible errors.

    Fixes: 81e675c227ec ("netfilter: ebtables: add CONFIG_COMPAT support")
    Reported-and-tested-by: syzbot+4e42a04e0bc33cb6c087@syzkaller.appspotmail.com
    Signed-off-by: Paolo Abeni
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Paolo Abeni
     

30 May, 2018

2 commits

  • [ Upstream commit 932909d9b28d27e807ff8eecb68c7748f6701628 ]

    The last rule in the blob has next_entry offset that is same as total size.
    This made "ebtables32 -A OUTPUT -d de:ad:be:ef:01:02" fail on 64 bit kernel.

    Fixes: b71812168571fa ("netfilter: ebtables: CONFIG_COMPAT: don't trust userland offsets")
    Signed-off-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Florian Westphal
     
  • [ Upstream commit fc6a5d0601c5ac1d02f283a46f60b87b2033e5ca ]

    All of these conditions are not fatal and should have
    been WARN_ONs from the get-go.

    Convert them to WARN_ONs and bail out.

    Signed-off-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Florian Westphal
     

19 May, 2018

1 commit

  • [ Upstream commit e8238fc2bd7b4c3c7554fa2df067e796610212fc ]

    When we set a bond slave's master to bridge via ioctl, we only check
    the IFF_BRIDGE_PORT flag. Although we will find the slave's real master
    at netdev_master_upper_dev_link() later, it already does some settings
    and allocates some resources. It would be better to return as early
    as possible.

    v1 -> v2:
    use netdev_master_upper_dev_get() instead of netdev_has_any_upper_dev()
    to check if we have a master, because not all upper devs are masters,
    e.g. vlan device.

    Reported-by: syzbot+de73361ee4971b6e6f75@syzkaller.appspotmail.com
    Signed-off-by: Hangbin Liu
    Acked-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Hangbin Liu
     

16 May, 2018

1 commit

  • commit 3f1e53abff84cf40b1adb3455d480dd295bf42e8 upstream.

    Dmitry reports 32bit ebtables on 64bit kernel got broken by
    a recent change that returns -EINVAL when ruleset has no entries.

    ebtables however only counts user-defined chains, so for the
    initial table nentries will be 0.

    Don't try to allocate the compat array in this case, as no user
    defined rules exist no rule will need 64bit translation.

    Reported-by: Dmitry Vyukov
    Fixes: 7d7d7e02111e9 ("netfilter: compat: reject huge allocation requests")
    Signed-off-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Florian Westphal
     

26 Apr, 2018

1 commit


08 Apr, 2018

1 commit

  • commit c8d70a700a5b486bfa8e5a7d33d805389f6e59f9 upstream.

    ebt_among is special, it has a dynamic match size and is exempt
    from the central size checks.

    commit c4585a2823edf ("bridge: ebt_among: add missing match size checks")
    added validation for pool size, but missed fact that the macros
    ebt_among_wh_src/dst can already return out-of-bound result because
    they do not check value of wh_src/dst_ofs (an offset) vs. the size
    of the match that userspace gave to us.

    v2:
    check that offset has correct alignment.
    Paolo Abeni points out that we should also check that src/dst
    wormhash arrays do not overlap, and src + length lines up with
    start of dst (or vice versa).
    v3: compact wormhash_sizes_valid() part

    NB: Fixes tag is intentionally wrong, this bug exists from day
    one when match was added for 2.6 kernel. Tag is there so stable
    maintainers will notice this one too.

    Tested with same rules from the earlier patch.

    Fixes: c4585a2823edf ("bridge: ebt_among: add missing match size checks")
    Reported-by:
    Signed-off-by: Florian Westphal
    Reviewed-by: Eric Dumazet
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Florian Westphal
     

15 Mar, 2018

2 commits

  • commit c4585a2823edf4d1326da44d1524ecbfda26bb37 upstream.

    ebt_among is special, it has a dynamic match size and is exempt
    from the central size checks.

    Therefore it must check that the size of the match structure
    provided from userspace is sane by making sure em->match_size
    is at least the minimum size of the expected structure.

    The module has such a check, but its only done after accessing
    a structure that might be out of bounds.

    tested with: ebtables -A INPUT ... \
    --among-dst fe:fe:fe:fe:fe:fe
    --among-dst fe:fe:fe:fe:fe:fe --among-src fe:fe:fe:fe:ff:f,fe:fe:fe:fe:fe:fb,fe:fe:fe:fe:fc:fd,fe:fe:fe:fe:fe:fd,fe:fe:fe:fe:fe:fe
    --among-src fe:fe:fe:fe:ff:f,fe:fe:fe:fe:fe:fa,fe:fe:fe:fe:fe:fd,fe:fe:fe:fe:fe:fe,fe:fe:fe:fe:fe:fe

    Reported-by:
    Signed-off-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Florian Westphal
     
  • commit b71812168571fa55e44cdd0254471331b9c4c4c6 upstream.

    We need to make sure the offsets are not out of range of the
    total size.
    Also check that they are in ascending order.

    The WARN_ON triggered by syzkaller (it sets panic_on_warn) is
    changed to also bail out, no point in continuing parsing.

    Briefly tested with simple ruleset of
    -A INPUT --limit 1/s' --log
    plus jump to custom chains using 32bit ebtables binary.

    Reported-by:
    Signed-off-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Florian Westphal
     

09 Mar, 2018

2 commits

  • [ Upstream commit 0e5a82efda872c2469c210957d7d4161ef8f4391 ]

    When a VLAN is added on a port, a reference is taken on the
    corresponding master VLAN entry. If it does not already exist, then it
    is created and a reference taken.

    However, in the second case a reference is not really taken when
    CONFIG_REFCOUNT_FULL is enabled as refcount_inc() is replaced by
    refcount_inc_not_zero().

    Fix this by using refcount_set() on a newly created master VLAN entry.

    Fixes: 251277598596 ("net, bridge: convert net_bridge_vlan.refcnt from atomic_t to refcount_t")
    Signed-off-by: Ido Schimmel
    Acked-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Ido Schimmel
     
  • [ Upstream commit 1b12580af1d0677c3c3a19e35bfe5d59b03f737f ]

    Now br_sysfs_if file flush doesn't have attr show. To read it will
    cause kernel panic after users chmod u+r this file.

    Xiong found this issue when running the commands:

    ip link add br0 type bridge
    ip link add type veth
    ip link set veth0 master br0
    chmod u+r /sys/devices/virtual/net/veth0/brport/flush
    timeout 3 cat /sys/devices/virtual/net/veth0/brport/flush

    kernel crashed with NULL a pointer dereference call trace.

    This patch is to fix it by return -EINVAL when brport_attr->show
    is null, just the same as the check for brport_attr->store in
    brport_store().

    Fixes: 9cf637473c85 ("bridge: add sysfs hook to flush forwarding table")
    Reported-by: Xiong Zhou
    Signed-off-by: Xin Long
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     

03 Jan, 2018

1 commit

  • [ Upstream commit 84aeb437ab98a2bce3d4b2111c79723aedfceb33 ]

    The early call to br_stp_change_bridge_id in bridge's newlink can cause
    a memory leak if an error occurs during the newlink because the fdb
    entries are not cleaned up if a different lladdr was specified, also
    another minor issue is that it generates fdb notifications with
    ifindex = 0. Another unrelated memory leak is the bridge sysfs entries
    which get added on NETDEV_REGISTER event, but are not cleaned up in the
    newlink error path. To remove this special case the call to
    br_stp_change_bridge_id is done after netdev register and we cleanup the
    bridge on changelink error via br_dev_delete to plug all leaks.

    This patch makes netlink bridge destruction on newlink error the same as
    dellink and ioctl del which is necessary since at that point we have a
    fully initialized bridge device.

    To reproduce the issue:
    $ ip l add br0 address 00:11:22:33:44:55 type bridge group_fwd_mask 1
    RTNETLINK answers: Invalid argument

    $ rmmod bridge
    [ 1822.142525] =============================================================================
    [ 1822.143640] BUG bridge_fdb_cache (Tainted: G O ): Objects remaining in bridge_fdb_cache on __kmem_cache_shutdown()
    [ 1822.144821] -----------------------------------------------------------------------------

    [ 1822.145990] Disabling lock debugging due to kernel taint
    [ 1822.146732] INFO: Slab 0x0000000092a844b2 objects=32 used=2 fp=0x00000000fef011b0 flags=0x1ffff8000000100
    [ 1822.147700] CPU: 2 PID: 13584 Comm: rmmod Tainted: G B O 4.15.0-rc2+ #87
    [ 1822.148578] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.7.5-20140531_083030-gandalf 04/01/2014
    [ 1822.150008] Call Trace:
    [ 1822.150510] dump_stack+0x78/0xa9
    [ 1822.151156] slab_err+0xb1/0xd3
    [ 1822.151834] ? __kmalloc+0x1bb/0x1ce
    [ 1822.152546] __kmem_cache_shutdown+0x151/0x28b
    [ 1822.153395] shutdown_cache+0x13/0x144
    [ 1822.154126] kmem_cache_destroy+0x1c0/0x1fb
    [ 1822.154669] SyS_delete_module+0x194/0x244
    [ 1822.155199] ? trace_hardirqs_on_thunk+0x1a/0x1c
    [ 1822.155773] entry_SYSCALL_64_fastpath+0x23/0x9a
    [ 1822.156343] RIP: 0033:0x7f929bd38b17
    [ 1822.156859] RSP: 002b:00007ffd160e9a98 EFLAGS: 00000202 ORIG_RAX: 00000000000000b0
    [ 1822.157728] RAX: ffffffffffffffda RBX: 00005578316ba090 RCX: 00007f929bd38b17
    [ 1822.158422] RDX: 00007f929bd9ec60 RSI: 0000000000000800 RDI: 00005578316ba0f0
    [ 1822.159114] RBP: 0000000000000003 R08: 00007f929bff5f20 R09: 00007ffd160e8a11
    [ 1822.159808] R10: 00007ffd160e9860 R11: 0000000000000202 R12: 00007ffd160e8a80
    [ 1822.160513] R13: 0000000000000000 R14: 0000000000000000 R15: 00005578316ba090
    [ 1822.161278] INFO: Object 0x000000007645de29 @offset=0
    [ 1822.161666] INFO: Object 0x00000000d5df2ab5 @offset=128

    Fixes: 30313a3d5794 ("bridge: Handle IFLA_ADDRESS correctly when creating bridge device")
    Fixes: 5b8d5429daa0 ("bridge: netlink: register netdevice before executing changelink")
    Signed-off-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Nikolay Aleksandrov
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

22 Oct, 2017

1 commit

  • When vlan tunnels were introduced, vlan range errors got silently
    dropped and instead 0 was returned always. Restore the previous
    behaviour and return errors to user-space.

    Fixes: efa5356b0d97 ("bridge: per vlan dst_metadata netlink support")
    Signed-off-by: Nikolay Aleksandrov
    Acked-by: Roopa Prabhu
    Signed-off-by: David S. Miller

    Nikolay Aleksandrov
     

29 Sep, 2017

1 commit


06 Sep, 2017

1 commit


04 Sep, 2017

2 commits

  • This patch removes CONFIG_NETFILTER_DEBUG and _ASSERT() macros as they
    are no longer required. Replace _ASSERT() macros with WARN_ON().

    Signed-off-by: Varsha Rao
    Signed-off-by: Pablo Neira Ayuso

    Varsha Rao
     
  • Pablo Neira Ayuso says:

    ====================
    Netfilter updates for net-next

    The following patchset contains Netfilter updates for your net-next
    tree. Basically, updates to the conntrack core, enhancements for
    nf_tables, conversion of netfilter hooks from linked list to array to
    improve memory locality and asorted improvements for the Netfilter
    codebase. More specifically, they are:

    1) Add expection to hashes after timer initialization to prevent
    access from another CPU that walks on the hashes and calls
    del_timer(), from Florian Westphal.

    2) Don't update nf_tables chain counters from hot path, this is only
    used by the x_tables compatibility layer.

    3) Get rid of nested rcu_read_lock() calls from netfilter hook path.
    Hooks are always guaranteed to run from rcu read side, so remove
    nested rcu_read_lock() where possible. Patch from Taehee Yoo.

    4) nf_tables new ruleset generation notifications include PID and name
    of the process that has updated the ruleset, from Phil Sutter.

    5) Use skb_header_pointer() from nft_fib, so we can reuse this code from
    the nf_family netdev family. Patch from Pablo M. Bermudo.

    6) Add support for nft_fib in nf_tables netdev family, also from Pablo.

    7) Use deferrable workqueue for conntrack garbage collection, to reduce
    power consumption, from Patch from Subash Abhinov Kasiviswanathan.

    8) Add nf_ct_expect_iterate_net() helper and use it. From Florian
    Westphal.

    9) Call nf_ct_unconfirmed_destroy only from cttimeout, from Florian.

    10) Drop references on conntrack removal path when skbuffs has escaped via
    nfqueue, from Florian.

    11) Don't queue packets to nfqueue with dying conntrack, from Florian.

    12) Constify nf_hook_ops structure, from Florian.

    13) Remove neededlessly branch in nf_tables trace code, from Phil Sutter.

    14) Add nla_strdup(), from Phil Sutter.

    15) Rise nf_tables objects name size up to 255 chars, people want to use
    DNS names, so increase this according to what RFC 1035 specifies.
    Patch series from Phil Sutter.

    16) Kill nf_conntrack_default_on, it's broken. Default on conntrack hook
    registration on demand, suggested by Eric Dumazet, patch from Florian.

    17) Remove unused variables in compat_copy_entry_from_user both in
    ip_tables and arp_tables code. Patch from Taehee Yoo.

    18) Constify struct nf_conntrack_l4proto, from Julia Lawall.

    19) Constify nf_loginfo structure, also from Julia.

    20) Use a single rb root in connlimit, from Taehee Yoo.

    21) Remove unused netfilter_queue_init() prototype, from Taehee Yoo.

    22) Use audit_log() instead of open-coding it, from Geliang Tang.

    23) Allow to mangle tcp options via nft_exthdr, from Florian.

    24) Allow to fetch TCP MSS from nft_rt, from Florian. This includes
    a fix for a miscalculation of the minimal length.

    25) Simplify branch logic in h323 helper, from Nick Desaulniers.

    26) Calculate netlink attribute size for conntrack tuple at compile
    time, from Florian.

    27) Remove protocol name field from nf_conntrack_{l3,l4}proto structure.
    From Florian.

    28) Remove holes in nf_conntrack_l4proto structure, so it becomes
    smaller. From Florian.

    29) Get rid of print_tuple() indirection for /proc conntrack listing.
    Place all the code in net/netfilter/nf_conntrack_standalone.c.
    Patch from Florian.

    30) Do not built in print_conntrack() if CONFIG_NF_CONNTRACK_PROCFS is
    off. From Florian.

    31) Constify most nf_conntrack_{l3,l4}proto helper functions, from
    Florian.

    32) Fix broken indentation in ebtables extensions, from Colin Ian King.

    33) Fix several harmless sparse warning, from Florian.

    34) Convert netfilter hook infrastructure to use array for better memory
    locality, joint work done by Florian and Aaron Conole. Moreover, add
    some instrumentation to debug this.

    35) Batch nf_unregister_net_hooks() calls, to call synchronize_net once
    per batch, from Florian.

    36) Get rid of noisy logging in ICMPv6 conntrack helper, from Florian.

    37) Get rid of obsolete NFDEBUG() instrumentation, from Varsha Rao.

    38) Remove unused code in the generic protocol tracker, from Davide
    Caratti.

    I think I will have material for a second Netfilter batch in my queue if
    time allow to make it fit in this merge window.
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     

02 Sep, 2017

2 commits

  • Three cases of simple overlapping changes.

    Signed-off-by: David S. Miller

    David S. Miller
     
  • Commit 6bc506b4fb06 ("bridge: switchdev: Add forward mark support for
    stacked devices") added the 'offload_fwd_mark' bit to the skb in order
    to allow drivers to indicate to the bridge driver that they already
    forwarded the packet in L2.

    In case the bit is set, before transmitting the packet from each port,
    the port's mark is compared with the mark stored in the skb's control
    block. If both marks are equal, we know the packet arrived from a switch
    device that already forwarded the packet and it's not re-transmitted.

    However, if the packet is transmitted from the bridge device itself
    (e.g., br0), we should clear the 'offload_fwd_mark' bit as the mark
    stored in the skb's control block isn't valid.

    This scenario can happen in rare cases where a packet was trapped during
    L3 forwarding and forwarded by the kernel to a bridge device.

    Fixes: 6bc506b4fb06 ("bridge: switchdev: Add forward mark support for stacked devices")
    Signed-off-by: Ido Schimmel
    Reported-by: Yotam Gigi
    Tested-by: Yotam Gigi
    Reviewed-by: Jiri Pirko
    Acked-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller

    Ido Schimmel
     

01 Sep, 2017

1 commit

  • This extends bridge fdb table tracepoints to also cover
    learned fdb entries in the br_fdb_update path. Note that
    unlike other tracepoints I have moved this to when the fdb
    is modified because this is in the datapath and can generate
    a lot of noise in the trace output. br_fdb_update is also called
    from added_by_user context in the NTF_USE case which is already
    traced ..hence the !added_by_user check.

    Signed-off-by: Roopa Prabhu
    Acked-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller

    Roopa Prabhu
     

30 Aug, 2017

1 commit


29 Aug, 2017

2 commits

  • current switchdev drivers dont seem to support offloading fdb
    entries pointing to the bridge device which have fdb->dst
    not set to any port. This patch adds a NULL fdb->dst check in
    the switchdev notifier code.

    This patch fixes the below NULL ptr dereference:
    $bridge fdb add 00:02:00:00:00:33 dev br0 self

    [ 69.953374] BUG: unable to handle kernel NULL pointer dereference at
    0000000000000008
    [ 69.954044] IP: br_switchdev_fdb_notify+0x29/0x80
    [ 69.954044] PGD 66527067
    [ 69.954044] P4D 66527067
    [ 69.954044] PUD 7899c067
    [ 69.954044] PMD 0
    [ 69.954044]
    [ 69.954044] Oops: 0000 [#1] SMP
    [ 69.954044] Modules linked in:
    [ 69.954044] CPU: 1 PID: 3074 Comm: bridge Not tainted 4.13.0-rc6+ #1
    [ 69.954044] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
    BIOS rel-1.7.5.1-0-g8936dbb-20141113_115728-nilsson.home.kraxel.org
    04/01/2014
    [ 69.954044] task: ffff88007b827140 task.stack: ffffc90001564000
    [ 69.954044] RIP: 0010:br_switchdev_fdb_notify+0x29/0x80
    [ 69.954044] RSP: 0018:ffffc90001567918 EFLAGS: 00010246
    [ 69.954044] RAX: 0000000000000000 RBX: ffff8800795e0880 RCX:
    00000000000000c0
    [ 69.954044] RDX: ffffc90001567920 RSI: 000000000000001c RDI:
    ffff8800795d0600
    [ 69.954044] RBP: ffffc90001567938 R08: ffff8800795d0600 R09:
    0000000000000000
    [ 69.954044] R10: ffffc90001567a88 R11: ffff88007b849400 R12:
    ffff8800795e0880
    [ 69.954044] R13: ffff8800795d0600 R14: ffffffff81ef8880 R15:
    000000000000001c
    [ 69.954044] FS: 00007f93d3085700(0000) GS:ffff88007fd00000(0000)
    knlGS:0000000000000000
    [ 69.954044] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [ 69.954044] CR2: 0000000000000008 CR3: 0000000066551000 CR4:
    00000000000006e0
    [ 69.954044] Call Trace:
    [ 69.954044] fdb_notify+0x3f/0xf0
    [ 69.954044] __br_fdb_add.isra.12+0x1a7/0x370
    [ 69.954044] br_fdb_add+0x178/0x280
    [ 69.954044] rtnl_fdb_add+0x10a/0x200
    [ 69.954044] rtnetlink_rcv_msg+0x1b4/0x240
    [ 69.954044] ? skb_free_head+0x21/0x40
    [ 69.954044] ? rtnl_calcit.isra.18+0xf0/0xf0
    [ 69.954044] netlink_rcv_skb+0xed/0x120
    [ 69.954044] rtnetlink_rcv+0x15/0x20
    [ 69.954044] netlink_unicast+0x180/0x200
    [ 69.954044] netlink_sendmsg+0x291/0x370
    [ 69.954044] ___sys_sendmsg+0x180/0x2e0
    [ 69.954044] ? filemap_map_pages+0x2db/0x370
    [ 69.954044] ? do_wp_page+0x11d/0x420
    [ 69.954044] ? __handle_mm_fault+0x794/0xd80
    [ 69.954044] ? vma_link+0xcb/0xd0
    [ 69.954044] __sys_sendmsg+0x4c/0x90
    [ 69.954044] SyS_sendmsg+0x12/0x20
    [ 69.954044] do_syscall_64+0x63/0xe0
    [ 69.954044] entry_SYSCALL64_slow_path+0x25/0x25
    [ 69.954044] RIP: 0033:0x7f93d2bad690
    [ 69.954044] RSP: 002b:00007ffc7217a638 EFLAGS: 00000246 ORIG_RAX:
    000000000000002e
    [ 69.954044] RAX: ffffffffffffffda RBX: 00007ffc72182eac RCX:
    00007f93d2bad690
    [ 69.954044] RDX: 0000000000000000 RSI: 00007ffc7217a670 RDI:
    0000000000000003
    [ 69.954044] RBP: 0000000059a1f7f8 R08: 0000000000000006 R09:
    000000000000000a
    [ 69.954044] R10: 00007ffc7217a400 R11: 0000000000000246 R12:
    00007ffc7217a670
    [ 69.954044] R13: 00007ffc72182a98 R14: 00000000006114c0 R15:
    00007ffc72182aa0
    [ 69.954044] Code: 1f 00 66 66 66 66 90 55 48 89 e5 48 83 ec 20 f6 47
    20 04 74 0a 83 fe 1c 74 09 83 fe 1d 74 2c c9 66 90 c3 48 8b 47 10 48 8d
    55 e8 8b 70 08 0f b7 47 1e 48 83 c7 18 48 89 7d f0 bf 03 00 00 00
    [ 69.954044] RIP: br_switchdev_fdb_notify+0x29/0x80 RSP:
    ffffc90001567918
    [ 69.954044] CR2: 0000000000000008
    [ 69.954044] ---[ end trace 03e9eec4a82c238b ]---

    Fixes: 6b26b51b1d13 ("net: bridge: Add support for notifying devices about FDB add/del")
    Signed-off-by: Roopa Prabhu
    Signed-off-by: David S. Miller

    Roopa Prabhu
     
  • Make this const as it is only passed to a const argument of the function
    ebt_register_table.

    Signed-off-by: Bhumika Goyal
    Signed-off-by: David S. Miller

    Bhumika Goyal
     

28 Aug, 2017

1 commit

  • This converts the storage and layout of netfilter hook entries from a
    linked list to an array. After this commit, hook entries will be
    stored adjacent in memory. The next pointer is no longer required.

    The ops pointers are stored at the end of the array as they are only
    used in the register/unregister path and in the legacy br_netfilter code.

    nf_unregister_net_hooks() is slower than needed as it just calls
    nf_unregister_net_hook in a loop (i.e. at least n synchronize_net()
    calls), this will be addressed in followup patch.

    Test setup:
    - ixgbe 10gbit
    - netperf UDP_STREAM, 64 byte packets
    - 5 hooks: (raw + mangle prerouting, mangle+filter input, inet filter):
    empty mangle and raw prerouting, mangle and filter input hooks:
    353.9
    this patch:
    364.2

    Signed-off-by: Aaron Conole
    Signed-off-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso

    Aaron Conole
     

25 Aug, 2017

1 commit


19 Aug, 2017

1 commit


10 Aug, 2017

1 commit

  • This change allows us to later indicate to rtnetlink core that certain
    doit functions should be called without acquiring rtnl_mutex.

    This change should have no effect, we simply replace the last (now
    unused) calcit argument with the new flag.

    Signed-off-by: Florian Westphal
    Reviewed-by: Hannes Frederic Sowa
    Signed-off-by: David S. Miller

    Florian Westphal
     

08 Aug, 2017

1 commit


01 Aug, 2017

1 commit


14 Jul, 2017

1 commit

  • With 802.1ad support the vlan_ingress code started checking for vlan
    protocol mismatch which causes the current tag to be inserted and the
    bridge vlan protocol & pvid to be set. The vlan tag insertion changes
    the skb mac_header and thus the lookup mac dest pointer which was loaded
    prior to calling br_allowed_ingress in br_handle_frame_finish is VLAN_HLEN
    bytes off now, pointing to the last two bytes of the destination mac and
    the first four of the source mac causing lookups to always fail and
    broadcasting all such packets to all ports. Same thing happens for locally
    originated packets when passing via br_dev_xmit. So load the dest pointer
    after the vlan checks and possible skb change.

    Fixes: 8580e2117c06 ("bridge: Prepare for 802.1ad vlan filtering support")
    Reported-by: Anitha Narasimha Murthy
    Signed-off-by: Nikolay Aleksandrov
    Acked-by: Toshiaki Makita
    Signed-off-by: David S. Miller

    Nikolay Aleksandrov
     

12 Jul, 2017

1 commit

  • We currently get the following kmemleak report:
    unreferenced object 0xffff8800039d9820 (size 32):
    comm "softirq", pid 0, jiffies 4295212383 (age 792.416s)
    hex dump (first 32 bytes):
    00 0c e0 03 00 88 ff ff ff 02 00 00 00 00 00 00 ................
    00 00 00 01 ff 11 00 02 86 dd 00 00 ff ff ff ff ................
    backtrace:
    [] kmemleak_alloc+0x4a/0xa0
    [] kmem_cache_alloc_trace+0xb8/0x1c0
    [] __br_mdb_notify+0x2a3/0x300 [bridge]
    [] br_mdb_notify+0x6e/0x70 [bridge]
    [] br_multicast_add_group+0x109/0x150 [bridge]
    [] br_ip6_multicast_add_group+0x58/0x60 [bridge]
    [] br_multicast_rcv+0x1d5/0xdb0 [bridge]
    [] br_handle_frame_finish+0xcf/0x510 [bridge]
    [] br_nf_hook_thresh.part.27+0xb/0x10 [br_netfilter]
    [] br_nf_hook_thresh+0x48/0xb0 [br_netfilter]
    [] br_nf_pre_routing_finish_ipv6+0x109/0x1d0 [br_netfilter]
    [] br_nf_pre_routing_ipv6+0xd0/0x14c [br_netfilter]
    [] br_nf_pre_routing+0x197/0x3d0 [br_netfilter]
    [] nf_iterate+0x52/0x60
    [] nf_hook_slow+0x5c/0xb0
    [] br_handle_frame+0x1a4/0x2c0 [bridge]

    This happens when switchdev_port_obj_add() fails. This patch
    frees complete_info object in the fail path.

    Reviewed-by: Vallish Vaidyeshwara
    Signed-off-by: Eduardo Valentin
    Signed-off-by: David S. Miller

    Eduardo Valentin
     

06 Jul, 2017

1 commit

  • Pablo Neira Ayuso says:

    ====================
    Netfilter fixes for net

    The following patchset contains two Netfilter fixes for your net tree,
    they are:

    1) Fix memleak from netns release path of conntrack protocol trackers,
    patch from Liping Zhang.

    2) Uninitialized flags field in ebt_log, that results in unpredictable
    logging format in ebtables, also from Liping.
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     

05 Jul, 2017

1 commit


04 Jul, 2017

1 commit

  • current code silently ignores change of port in the request
    message. This patch makes sure the port is modified and
    notification is sent to userspace.

    Fixes: cf6b8e1eedff ("bridge: add API to notify bridge driver of learned FBD on offloaded device")
    Signed-off-by: Nikolay Aleksandrov
    Signed-off-by: Roopa Prabhu
    Signed-off-by: David S. Miller

    Nikolay Aleksandrov
     

01 Jul, 2017

1 commit

  • refcount_t type and corresponding API should be
    used instead of atomic_t when the variable is used as
    a reference counter. This allows to avoid accidental
    refcounter overflows that might lead to use-after-free
    situations.

    Signed-off-by: Elena Reshetova
    Signed-off-by: Hans Liljestrand
    Signed-off-by: Kees Cook
    Signed-off-by: David Windsor
    Signed-off-by: David S. Miller

    Reshetova, Elena
     

30 Jun, 2017

2 commits

  • Pablo Neira Ayuso says:

    ====================
    Netfilter updates for net-next

    The following patchset contains Netfilter updates for your net-next
    tree. This batch contains connection tracking updates for the cleanup
    iteration path, patches from Florian Westphal:

    X) Skip unconfirmed conntracks in nf_ct_iterate_cleanup_net(), just set
    dying bit to let the CPU release them.

    X) Add nf_ct_iterate_destroy() to be used on module removal, to kill
    conntrack from all namespace.

    X) Restart iteration on hashtable resizing, since both may occur at
    the same time.

    X) Use the new nf_ct_iterate_destroy() to remove conntrack with NAT
    mapping on module removal.

    X) Use nf_ct_iterate_destroy() to remove conntrack entries helper
    module removal, from Liping Zhang.

    X) Use nf_ct_iterate_cleanup_net() to remove the timeout extension
    if user requests this, also from Liping.

    X) Add net_ns_barrier() and use it from FTP helper, so make sure
    no concurrent namespace removal happens at the same time while
    the helper module is being removed.

    X) Use NFPROTO_MAX in layer 3 conntrack protocol array, to reduce
    module size. Same thing in nf_tables.

    Updates for the nf_tables infrastructure:

    X) Prepare usage of the extended ACK reporting infrastructure for
    nf_tables.

    X) Remove unnecessary forward declaration in nf_tables hash set.

    X) Skip set size estimation if number of element is not specified.

    X) Changes to accomodate a (faster) unresizable hash set implementation,
    for anonymous sets and dynamic size fixed sets with no timeouts.

    X) Faster lookup function for unresizable hash table for 2 and 4
    bytes key.

    And, finally, a bunch of asorted small updates and cleanups:

    X) Do not hold reference to netdev from ipt_CLUSTER, instead subscribe
    to device events and look up for index from the packet path, this
    is fixing an issue that is present since the very beginning, patch
    from Xin Long.

    X) Use nf_register_net_hook() in ipt_CLUSTER, from Florian Westphal.

    X) Use ebt_invalid_target() whenever possible in the ebtables tree,
    from Gao Feng.

    X) Calm down compilation warning in nf_dup infrastructure, patch from
    stephen hemminger.

    X) Statify functions in nftables rt expression, also from stephen.

    X) Update Makefile to use canonical method to specify nf_tables-objs.
    From Jike Song.

    X) Use nf_conntrack_helpers_register() in amanda and H323.

    X) Space cleanup for ctnetlink, from linzhang.
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     
  • attribute_groups are not supposed to change at runtime. All functions
    working with attribute_groups provided by work with const
    attribute_group. So mark the non-const structs as const.

    File size before:
    text data bss dec hex filename
    2645 896 0 3541 dd5 net/bridge/br_sysfs_br.o

    File size After adding 'const':
    text data bss dec hex filename
    2701 832 0 3533 dcd net/bridge/br_sysfs_br.o

    Signed-off-by: Arvind Yadav
    Signed-off-by: David S. Miller

    Arvind Yadav