1. 08 4月, 2020 2 次提交
  2. 06 4月, 2020 5 次提交
    • A
      netfilter: ipset: Pass lockdep expression to RCU lists · b135fc08
      Amol Grover 提交于
      ip_set_type_list is traversed using list_for_each_entry_rcu
      outside an RCU read-side critical section but under the protection
      of ip_set_type_mutex.
      
      Hence, add corresponding lockdep expression to silence false-positive
      warnings, and harden RCU lists.
      Signed-off-by: NAmol Grover <frextrite@gmail.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      b135fc08
    • E
      netfilter: nf_tables: do not leave dangling pointer in nf_tables_set_alloc_name · 7fb6f78d
      Eric Dumazet 提交于
      If nf_tables_set_alloc_name() frees set->name, we better
      clear set->name to avoid a future use-after-free or invalid-free.
      
      BUG: KASAN: double-free or invalid-free in nf_tables_newset+0x1ed6/0x2560 net/netfilter/nf_tables_api.c:4148
      
      CPU: 0 PID: 28233 Comm: syz-executor.0 Not tainted 5.6.0-syzkaller #0
      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+0x188/0x20d lib/dump_stack.c:118
       print_address_description.constprop.0.cold+0xd3/0x315 mm/kasan/report.c:374
       kasan_report_invalid_free+0x61/0xa0 mm/kasan/report.c:468
       __kasan_slab_free+0x129/0x140 mm/kasan/common.c:455
       __cache_free mm/slab.c:3426 [inline]
       kfree+0x109/0x2b0 mm/slab.c:3757
       nf_tables_newset+0x1ed6/0x2560 net/netfilter/nf_tables_api.c:4148
       nfnetlink_rcv_batch+0x83a/0x1610 net/netfilter/nfnetlink.c:433
       nfnetlink_rcv_skb_batch net/netfilter/nfnetlink.c:543 [inline]
       nfnetlink_rcv+0x3af/0x420 net/netfilter/nfnetlink.c:561
       netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
       netlink_unicast+0x537/0x740 net/netlink/af_netlink.c:1329
       netlink_sendmsg+0x882/0xe10 net/netlink/af_netlink.c:1918
       sock_sendmsg_nosec net/socket.c:652 [inline]
       sock_sendmsg+0xcf/0x120 net/socket.c:672
       ____sys_sendmsg+0x6b9/0x7d0 net/socket.c:2345
       ___sys_sendmsg+0x100/0x170 net/socket.c:2399
       __sys_sendmsg+0xec/0x1b0 net/socket.c:2432
       do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:294
       entry_SYSCALL_64_after_hwframe+0x49/0xbe
      RIP: 0033:0x45c849
      Code: ad b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 7b b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00
      RSP: 002b:00007fe5ca21dc78 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
      RAX: ffffffffffffffda RBX: 00007fe5ca21e6d4 RCX: 000000000045c849
      RDX: 0000000000000000 RSI: 0000000020000c40 RDI: 0000000000000003
      RBP: 000000000076bf00 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
      R13: 000000000000095b R14: 00000000004cc0e9 R15: 000000000076bf0c
      
      Allocated by task 28233:
       save_stack+0x1b/0x80 mm/kasan/common.c:72
       set_track mm/kasan/common.c:80 [inline]
       __kasan_kmalloc mm/kasan/common.c:515 [inline]
       __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:488
       __do_kmalloc mm/slab.c:3656 [inline]
       __kmalloc_track_caller+0x159/0x790 mm/slab.c:3671
       kvasprintf+0xb5/0x150 lib/kasprintf.c:25
       kasprintf+0xbb/0xf0 lib/kasprintf.c:59
       nf_tables_set_alloc_name net/netfilter/nf_tables_api.c:3536 [inline]
       nf_tables_newset+0x1543/0x2560 net/netfilter/nf_tables_api.c:4088
       nfnetlink_rcv_batch+0x83a/0x1610 net/netfilter/nfnetlink.c:433
       nfnetlink_rcv_skb_batch net/netfilter/nfnetlink.c:543 [inline]
       nfnetlink_rcv+0x3af/0x420 net/netfilter/nfnetlink.c:561
       netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
       netlink_unicast+0x537/0x740 net/netlink/af_netlink.c:1329
       netlink_sendmsg+0x882/0xe10 net/netlink/af_netlink.c:1918
       sock_sendmsg_nosec net/socket.c:652 [inline]
       sock_sendmsg+0xcf/0x120 net/socket.c:672
       ____sys_sendmsg+0x6b9/0x7d0 net/socket.c:2345
       ___sys_sendmsg+0x100/0x170 net/socket.c:2399
       __sys_sendmsg+0xec/0x1b0 net/socket.c:2432
       do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:294
       entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
      Freed by task 28233:
       save_stack+0x1b/0x80 mm/kasan/common.c:72
       set_track mm/kasan/common.c:80 [inline]
       kasan_set_free_info mm/kasan/common.c:337 [inline]
       __kasan_slab_free+0xf7/0x140 mm/kasan/common.c:476
       __cache_free mm/slab.c:3426 [inline]
       kfree+0x109/0x2b0 mm/slab.c:3757
       nf_tables_set_alloc_name net/netfilter/nf_tables_api.c:3544 [inline]
       nf_tables_newset+0x1f73/0x2560 net/netfilter/nf_tables_api.c:4088
       nfnetlink_rcv_batch+0x83a/0x1610 net/netfilter/nfnetlink.c:433
       nfnetlink_rcv_skb_batch net/netfilter/nfnetlink.c:543 [inline]
       nfnetlink_rcv+0x3af/0x420 net/netfilter/nfnetlink.c:561
       netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
       netlink_unicast+0x537/0x740 net/netlink/af_netlink.c:1329
       netlink_sendmsg+0x882/0xe10 net/netlink/af_netlink.c:1918
       sock_sendmsg_nosec net/socket.c:652 [inline]
       sock_sendmsg+0xcf/0x120 net/socket.c:672
       ____sys_sendmsg+0x6b9/0x7d0 net/socket.c:2345
       ___sys_sendmsg+0x100/0x170 net/socket.c:2399
       __sys_sendmsg+0xec/0x1b0 net/socket.c:2432
       do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:294
       entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
      The buggy address belongs to the object at ffff8880a6032d00
       which belongs to the cache kmalloc-32 of size 32
      The buggy address is located 0 bytes inside of
       32-byte region [ffff8880a6032d00, ffff8880a6032d20)
      The buggy address belongs to the page:
      page:ffffea0002980c80 refcount:1 mapcount:0 mapping:ffff8880aa0001c0 index:0xffff8880a6032fc1
      flags: 0xfffe0000000200(slab)
      raw: 00fffe0000000200 ffffea0002a3be88 ffffea00029b1908 ffff8880aa0001c0
      raw: ffff8880a6032fc1 ffff8880a6032000 000000010000003e 0000000000000000
      page dumped because: kasan: bad access detected
      
      Fixes: 65038428 ("netfilter: nf_tables: allow to specify stateful expression in set definition")
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Reported-by: Nsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      7fb6f78d
    • M
      netfilter: xt_IDLETIMER: target v1 - match Android layout · bc9fe614
      Maciej Żenczykowski 提交于
      Android has long had an extension to IDLETIMER to send netlink
      messages to userspace, see:
        https://android.googlesource.com/kernel/common/+/refs/heads/android-mainline/include/uapi/linux/netfilter/xt_IDLETIMER.h#42
      Note: this is idletimer target rev 1, there is no rev 0 in
      the Android common kernel sources, see registration at:
        https://android.googlesource.com/kernel/common/+/refs/heads/android-mainline/net/netfilter/xt_IDLETIMER.c#483
      
      When we compare that to upstream's new idletimer target rev 1:
        https://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git/tree/include/uapi/linux/netfilter/xt_IDLETIMER.h#n46
      
      We immediately notice that these two rev 1 structs are the
      same size and layout, and that while timer_type and send_nl_msg
      are differently named and serve a different purpose, they're
      at the same offset.
      
      This makes them impossible to tell apart - and thus one cannot
      know in a mixed Android/vanilla environment whether one means
      timer_type or send_nl_msg.
      
      Since this is iptables/netfilter uapi it introduces a problem
      between iptables (vanilla vs Android) userspace and kernel
      (vanilla vs Android) if the two don't match each other.
      
      Additionally when at some point in the future Android picks up
      5.7+ it's not at all clear how to resolve the resulting merge
      conflict.
      
      Furthermore, since upgrading the kernel on old Android phones
      is pretty much impossible there does not seem to be an easy way
      out of this predicament.
      
      The only thing I've been able to come up with is some super
      disgusting kernel version >= 5.7 check in the iptables binary
      to flip between different struct layouts.
      
      By adding a dummy field to the vanilla Linux kernel header file
      we can force the two structs to be compatible with each other.
      
      Long term I think I would like to deprecate send_nl_msg out of
      Android entirely, but I haven't quite been able to figure out
      exactly how we depend on it.  It seems to be very similar to
      sysfs notifications but with some extra info.
      
      Currently it's actually always enabled whenever Android uses
      the IDLETIMER target, so we could also probably entirely
      remove it from the uapi in favour of just always enabling it,
      but again we can't upgrade old kernels already in the field.
      
      (Also note that this doesn't change the structure's size,
      as it is simply fitting into the pre-existing padding, and
      that since 5.7 hasn't been released yet, there's still time
      to make this uapi visible change)
      
      Cc: Manoj Basapathi <manojbm@codeaurora.org>
      Cc: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
      Signed-off-by: NMaciej Żenczykowski <maze@google.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      bc9fe614
    • P
      netfilter: nf_tables: do not update stateful expressions if lookup is inverted · a26c1e49
      Pablo Neira Ayuso 提交于
      Initialize set lookup matching element to NULL. Otherwise, the
      NFT_LOOKUP_F_INV flag reverses the matching logic and it leads to
      deference an uninitialized pointer to the matching element. Make sure
      element data area and stateful expression are accessed if there is a
      matching set element.
      
      This patch undoes 24791b9a ("netfilter: nft_set_bitmap: initialize set
      element extension in lookups") which is not required anymore.
      
      Fixes: 339706bc ("netfilter: nft_lookup: update element stateful expression")
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      a26c1e49
    • S
      netfilter: nft_set_rbtree: Drop spurious condition for overlap detection on insertion · 72239f27
      Stefano Brivio 提交于
      Case a1. for overlap detection in __nft_rbtree_insert() is not a valid
      one: start-after-start is not needed to detect any type of interval
      overlap and it actually results in a false positive if, while
      descending the tree, this is the only step we hit after starting from
      the root.
      
      This introduced a regression, as reported by Pablo, in Python tests
      cases ip/ip.t and ip/numgen.t:
      
        ip/ip.t: ERROR: line 124: add rule ip test-ip4 input ip hdrlength vmap { 0-4 : drop, 5 : accept, 6 : continue } counter: This rule should not have failed.
        ip/numgen.t: ERROR: line 7: add rule ip test-ip4 pre dnat to numgen inc mod 10 map { 0-5 : 192.168.10.100, 6-9 : 192.168.20.200}: This rule should not have failed.
      
      Drop case a1. and renumber others, so that they are a bit clearer. In
      order for these diagrams to be readily understandable, a bigger rework
      is probably needed, such as an ASCII art of the actual rbtree (instead
      of a flattened version).
      
      Shell script test sets/0044interval_overlap_0 should cover all
      possible cases for false negatives, so I consider that test case still
      sufficient after this change.
      
      v2: Fix comments for cases a3. and b3.
      Reported-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Fixes: 7c84d414 ("netfilter: nft_set_rbtree: Detect partial overlaps on insertion")
      Signed-off-by: NStefano Brivio <sbrivio@redhat.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      72239f27
  3. 04 4月, 2020 5 次提交
    • C
      net: dsa: mt7530: fix null pointer dereferencing in port5 setup · 0452800f
      Chuanhong Guo 提交于
      The 2nd gmac of mediatek soc ethernet may not be connected to a PHY
      and a phy-handle isn't always available.
      Unfortunately, mt7530 dsa driver assumes that the 2nd gmac is always
      connected to switch port 5 and setup mt7530 according to phy address
      of 2nd gmac node, causing null pointer dereferencing when phy-handle
      isn't defined in dts.
      This commit fix this setup code by checking return value of
      of_parse_phandle before using it.
      
      Fixes: 38f790a8 ("net: dsa: mt7530: Add support for port 5")
      Signed-off-by: NChuanhong Guo <gch981213@gmail.com>
      Reviewed-by: NVivien Didelot <vivien.didelot@gmail.com>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Tested-by: NRené van Dorst <opensource@vdorst.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0452800f
    • G
      mptcp: add some missing pr_fmt defines · c85adced
      Geliang Tang 提交于
      Some of the mptcp logs didn't print out the format string:
      
      [  185.651493] DSS
      [  185.651494] data_fin=0 dsn64=0 use_map=0 ack64=1 use_ack=1
      [  185.651494] data_ack=13792750332298763796
      [  185.651495] MPTCP: msk=00000000c4b81cfc ssk=000000009743af53 data_avail=0 skb=0000000063dc595d
      [  185.651495] MPTCP: msk=00000000c4b81cfc ssk=000000009743af53 status=0
      [  185.651495] MPTCP: msk ack_seq=9bbc894565aa2f9a subflow ack_seq=9bbc894565aa2f9a
      [  185.651496] MPTCP: msk=00000000c4b81cfc ssk=000000009743af53 data_avail=1 skb=0000000012e809e1
      
      So this patch added these missing pr_fmt defines. Then we can get the same
      format string "MPTCP" in all mptcp logs like this:
      
      [  142.795829] MPTCP: DSS
      [  142.795829] MPTCP: data_fin=0 dsn64=0 use_map=0 ack64=1 use_ack=1
      [  142.795829] MPTCP: data_ack=8089704603109242421
      [  142.795830] MPTCP: msk=00000000133a24e0 ssk=000000002e508c64 data_avail=0 skb=00000000d5f230df
      [  142.795830] MPTCP: msk=00000000133a24e0 ssk=000000002e508c64 status=0
      [  142.795831] MPTCP: msk ack_seq=66790290f1199d9b subflow ack_seq=66790290f1199d9b
      [  142.795831] MPTCP: msk=00000000133a24e0 ssk=000000002e508c64 data_avail=1 skb=00000000de5aca2e
      Signed-off-by: NGeliang Tang <geliangtang@gmail.com>
      Reviewed-by: NMatthieu Baerts <matthieu.baerts@tessares.net>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      c85adced
    • O
      net: phy: micrel: kszphy_resume(): add delay after genphy_resume() before accessing PHY registers · 6110dff7
      Oleksij Rempel 提交于
      After the power-down bit is cleared, the chip internally triggers a
      global reset. According to the KSZ9031 documentation, we have to wait at
      least 1ms for the reset to finish.
      
      If the chip is accessed during reset, read will return 0xffff, while
      write will be ignored. Depending on the system performance and MDIO bus
      speed, we may or may not run in to this issue.
      
      This bug was discovered on an iMX6QP system with KSZ9031 PHY and
      attached PHY interrupt line. If IRQ was used, the link status update was
      lost. In polling mode, the link status update was always correct.
      
      The investigation showed, that during a read-modify-write access, the
      read returned 0xffff (while the chip was still in reset) and
      corresponding write hit the chip _after_ reset and triggered (due to the
      0xffff) another reset in an undocumented bit (register 0x1f, bit 1),
      resulting in the next write being lost due to the new reset cycle.
      
      This patch fixes the issue by adding a 1...2 ms sleep after the
      genphy_resume().
      
      Fixes: 836384d2 ("net: phy: micrel: Add specific suspend")
      Signed-off-by: NOleksij Rempel <o.rempel@pengutronix.de>
      Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      6110dff7
    • C
      net_sched: fix a missing refcnt in tcindex_init() · a8eab6d3
      Cong Wang 提交于
      The initial refcnt of struct tcindex_data should be 1,
      it is clear that I forgot to set it to 1 in tcindex_init().
      This leads to a dec-after-zero warning.
      
      Reported-by: syzbot+8325e509a1bf83ec741d@syzkaller.appspotmail.com
      Fixes: 304e0242 ("net_sched: add a temporary refcnt for struct tcindex_data")
      Cc: Jamal Hadi Salim <jhs@mojatatu.com>
      Cc: Jiri Pirko <jiri@resnulli.us>
      Cc: Paul E. McKenney <paulmck@kernel.org>
      Signed-off-by: NCong Wang <xiyou.wangcong@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a8eab6d3
    • J
      net: stmmac: dwmac1000: fix out-of-bounds mac address reg setting · 3e1221ac
      Jisheng Zhang 提交于
      Commit 9463c445 ("net: stmmac: dwmac1000: Clear unused address
      entries") cleared the unused mac address entries, but introduced an
      out-of bounds mac address register programming bug -- After setting
      the secondary unicast mac addresses, the "reg" value has reached
      netdev_uc_count() + 1, thus we should only clear address entries
      if (addr < perfect_addr_number)
      
      Fixes: 9463c445 ("net: stmmac: dwmac1000: Clear unused address entries")
      Signed-off-by: NJisheng Zhang <Jisheng.Zhang@synaptics.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3e1221ac
  4. 03 4月, 2020 5 次提交
  5. 02 4月, 2020 22 次提交
  6. 01 4月, 2020 1 次提交