1. 13 Mar, 2019 5 commits
    • Florian Fainelli's avatar
      MAINTAINERS: GENET & SYSTEMPORT: Add internal Broadcom list · 63b6c974
      Florian Fainelli authored
      There is a patchwork instance behind bcm-kernel-feedback-list that is
      helpful to track submissions, add this list for the Broadcom GENET and
      SYSTEMPORT drivers.
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      63b6c974
    • Eric Dumazet's avatar
      l2tp: fix infoleak in l2tp_ip6_recvmsg() · 163d1c3d
      Eric Dumazet authored
      Back in 2013 Hannes took care of most of such leaks in commit
      bceaa902 ("inet: prevent leakage of uninitialized memory to user in recv syscalls")
      
      But the bug in l2tp_ip6_recvmsg() has not been fixed.
      
      syzbot report :
      
      BUG: KMSAN: kernel-infoleak in _copy_to_user+0x16b/0x1f0 lib/usercopy.c:32
      CPU: 1 PID: 10996 Comm: syz-executor362 Not tainted 5.0.0+ #11
      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+0x173/0x1d0 lib/dump_stack.c:113
       kmsan_report+0x12e/0x2a0 mm/kmsan/kmsan.c:600
       kmsan_internal_check_memory+0x9f4/0xb10 mm/kmsan/kmsan.c:694
       kmsan_copy_to_user+0xab/0xc0 mm/kmsan/kmsan_hooks.c:601
       _copy_to_user+0x16b/0x1f0 lib/usercopy.c:32
       copy_to_user include/linux/uaccess.h:174 [inline]
       move_addr_to_user+0x311/0x570 net/socket.c:227
       ___sys_recvmsg+0xb65/0x1310 net/socket.c:2283
       do_recvmmsg+0x646/0x10c0 net/socket.c:2390
       __sys_recvmmsg net/socket.c:2469 [inline]
       __do_sys_recvmmsg net/socket.c:2492 [inline]
       __se_sys_recvmmsg+0x1d1/0x350 net/socket.c:2485
       __x64_sys_recvmmsg+0x62/0x80 net/socket.c:2485
       do_syscall_64+0xbc/0xf0 arch/x86/entry/common.c:291
       entry_SYSCALL_64_after_hwframe+0x63/0xe7
      RIP: 0033:0x445819
      Code: e8 6c b6 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 00 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 2b 12 fc ff c3 66 2e 0f 1f 84 00 00 00 00
      RSP: 002b:00007f64453eddb8 EFLAGS: 00000246 ORIG_RAX: 000000000000012b
      RAX: ffffffffffffffda RBX: 00000000006dac28 RCX: 0000000000445819
      RDX: 0000000000000005 RSI: 0000000020002f80 RDI: 0000000000000003
      RBP: 00000000006dac20 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006dac2c
      R13: 00007ffeba8f87af R14: 00007f64453ee9c0 R15: 20c49ba5e353f7cf
      
      Local variable description: ----addr@___sys_recvmsg
      Variable was created at:
       ___sys_recvmsg+0xf6/0x1310 net/socket.c:2244
       do_recvmmsg+0x646/0x10c0 net/socket.c:2390
      
      Bytes 0-31 of 32 are uninitialized
      Memory access of size 32 starts at ffff8880ae62fbb0
      Data copied to user address 0000000020000000
      
      Fixes: a32e0eec ("l2tp: introduce L2TPv3 IP encapsulation support for IPv6")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      163d1c3d
    • Vakul Garg's avatar
      net/tls: Inform user space about send buffer availability · 4504ab0e
      Vakul Garg authored
      A previous fix ("tls: Fix write space handling") assumed that
      user space application gets informed about the socket send buffer
      availability when tls_push_sg() gets called. Inside tls_push_sg(), in
      case do_tcp_sendpages() returns 0, the function returns without calling
      ctx->sk_write_space. Further, the new function tls_sw_write_space()
      did not invoke ctx->sk_write_space. This leads to situation that user
      space application encounters a lockup always waiting for socket send
      buffer to become available.
      
      Rather than call ctx->sk_write_space from tls_push_sg(), it should be
      called from tls_write_space. So whenever tcp stack invokes
      sk->sk_write_space after freeing socket send buffer, we always declare
      the same to user space by the way of invoking ctx->sk_write_space.
      
      Fixes: 7463d3a2 ("tls: Fix write space handling")
      Signed-off-by: default avatarVakul Garg <vakul.garg@nxp.com>
      Reviewed-by: default avatarBoris Pismenny <borisp@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4504ab0e
    • Zhike Wang's avatar
      net_sched: return correct value for *notify* functions · 5b5f99b1
      Zhike Wang authored
      It is confusing to directly use return value of netlink_send()/
      netlink_unicast() as the return value of *notify*, as it may be not
      error at all.
      
      Example: in tc_del_tfilter(), after calling tfilter_del_notify(), it will
      goto errout if (err). However, the netlink_send()/netlink_unicast() will
      return positive value even for successful case. So it may not call
      tcf_chain_tp_remove() and so on to clean up the resource, as a result,
      resource is leaked.
      
      It may be easier to only check the return value of tfilter_del_nofiy(),
      but it is more clean to correct all related functions.
      Co-developed-by: default avatarZengmo Gao <gaozengmo@jd.com>
      Signed-off-by: default avatarZhike Wang <wangzhike@jd.com>
      Acked-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5b5f99b1
    • Bryan Whitehead's avatar
      lan743x: Fix TX Stall Issue · deb6bfab
      Bryan Whitehead authored
      It has been observed that tx queue may stall while downloading
      from certain web sites (example www.speedtest.net)
      
      The cause has been tracked down to a corner case where
      the tx interrupt vector was disabled automatically, but
      was not re enabled later.
      
      The lan743x has two mechanisms to enable/disable individual
      interrupts. Interrupts can be enabled/disabled by individual
      source, and they can also be enabled/disabled by individual
      vector which has been mapped to the source. Both must be
      enabled for interrupts to work properly.
      
      The TX code path, primarily uses the interrupt enable/disable of
      the TX source bit, while leaving the vector enabled all the time.
      
      However, while investigating this issue it was noticed that
      the driver requested the use of the vector auto clear feature.
      
      The test above revealed a case where the vector enable was
      cleared unintentionally.
      
      This patch fixes the issue by deleting the lines that request
      the vector auto clear feature to be used.
      
      Fixes: 23f0703c ("lan743x: Add main source files for new lan743x driver")
      Signed-off-by: default avatarBryan Whitehead <Bryan.Whitehead@microchip.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      deb6bfab
  2. 12 Mar, 2019 13 commits
    • David S. Miller's avatar
      Merge branch 'mlx4-fixes' · 4d09d8d8
      David S. Miller authored
      Tariq Toukan says:
      
      ====================
      mlx4_core misc fixes
      
      This patchset by Jack contains misc fixes to the mlx4 Core driver.
      
      Patch 1 fixes a use-after-free situation by marking (nullifying) the pointer,
        please queue for -stable >= v4.0.
      Patch 2 adds a missing lock acquire and release in SRIOV command interface,
        please queue for -stable >= v4.9.
      Patch 3 avoids calling roundup_pow_of_two when argument is zero,
        please queue for -stable >= v3.3.
      
      Series generated against net commit:
      a3b1933d Merge tag 'mlx5-fixes-2019-03-11' of
      git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4d09d8d8
    • Jack Morgenstein's avatar
      net/mlx4_core: Fix qp mtt size calculation · 8511a653
      Jack Morgenstein authored
      Calculation of qp mtt size (in function mlx4_RST2INIT_wrapper)
      ultimately depends on function roundup_pow_of_two.
      
      If the amount of memory required by the QP is less than one page,
      roundup_pow_of_two is called with argument zero.  In this case, the
      roundup_pow_of_two result is undefined.
      
      Calling roundup_pow_of_two with a zero argument resulted in the
      following stack trace:
      
      UBSAN: Undefined behaviour in ./include/linux/log2.h:61:13
      shift exponent 64 is too large for 64-bit type 'long unsigned int'
      CPU: 4 PID: 26939 Comm: rping Tainted: G OE 4.19.0-rc1
      Hardware name: Supermicro X9DR3-F/X9DR3-F, BIOS 3.2a 07/09/2015
      Call Trace:
      dump_stack+0x9a/0xeb
      ubsan_epilogue+0x9/0x7c
      __ubsan_handle_shift_out_of_bounds+0x254/0x29d
      ? __ubsan_handle_load_invalid_value+0x180/0x180
      ? debug_show_all_locks+0x310/0x310
      ? sched_clock+0x5/0x10
      ? sched_clock+0x5/0x10
      ? sched_clock_cpu+0x18/0x260
      ? find_held_lock+0x35/0x1e0
      ? mlx4_RST2INIT_QP_wrapper+0xfb1/0x1440 [mlx4_core]
      mlx4_RST2INIT_QP_wrapper+0xfb1/0x1440 [mlx4_core]
      
      Fix this by explicitly testing for zero, and returning one if the
      argument is zero (assuming that the next higher power of 2 in this case
      should be one).
      
      Fixes: c82e9aa0 ("mlx4_core: resource tracking for HCA resources used by guests")
      Signed-off-by: default avatarJack Morgenstein <jackm@dev.mellanox.co.il>
      Signed-off-by: default avatarTariq Toukan <tariqt@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8511a653
    • Jack Morgenstein's avatar
      net/mlx4_core: Fix locking in SRIOV mode when switching between events and polling · c07d2792
      Jack Morgenstein authored
      In procedures mlx4_cmd_use_events() and mlx4_cmd_use_polling(), we need to
      guarantee that there are no FW commands in progress on the comm channel
      (for VFs) or wrapped FW commands (on the PF) when SRIOV is active.
      
      We do this by also taking the slave_cmd_mutex when SRIOV is active.
      
      This is especially important when switching from event to polling, since we
      free the command-context array during the switch.  If there are FW commands
      in progress (e.g., waiting for a completion event), the completion event
      handler will access freed memory.
      
      Since the decision to use comm_wait or comm_poll is taken before grabbing
      the event_sem/poll_sem in mlx4_comm_cmd_wait/poll, we must take the
      slave_cmd_mutex as well (to guarantee that the decision to use events or
      polling and the call to the appropriate cmd function are atomic).
      
      Fixes: a7e1f049 ("net/mlx4_core: Fix deadlock when switching between polling and event fw commands")
      Signed-off-by: default avatarJack Morgenstein <jackm@dev.mellanox.co.il>
      Signed-off-by: default avatarTariq Toukan <tariqt@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c07d2792
    • Jack Morgenstein's avatar
      net/mlx4_core: Fix reset flow when in command polling mode · e15ce4b8
      Jack Morgenstein authored
      As part of unloading a device, the driver switches from
      FW command event mode to FW command polling mode.
      
      Part of switching over to polling mode is freeing the command context array
      memory (unfortunately, currently, without NULLing the command context array
      pointer).
      
      The reset flow calls "complete" to complete all outstanding fw commands
      (if we are in event mode). The check for event vs. polling mode here
      is to test if the command context array pointer is NULL.
      
      If the reset flow is activated after the switch to polling mode, it will
      attempt (incorrectly) to complete all the commands in the context array --
      because the pointer was not NULLed when the driver switched over to polling
      mode.
      
      As a result, we have a use-after-free situation, which results in a
      kernel crash.
      
      For example:
      BUG: unable to handle kernel NULL pointer dereference at           (null)
      IP: [<ffffffff876c4a8e>] __wake_up_common+0x2e/0x90
      PGD 0
      Oops: 0000 [#1] SMP
      Modules linked in: netconsole nfsv3 nfs_acl nfs lockd grace ...
      CPU: 2 PID: 940 Comm: kworker/2:3 Kdump: loaded Not tainted 3.10.0-862.el7.x86_64 #1
      Hardware name: Microsoft Corporation Virtual Machine/Virtual Machine, BIOS 090006  04/28/2016
      Workqueue: events hv_eject_device_work [pci_hyperv]
      task: ffff8d1734ca0fd0 ti: ffff8d17354bc000 task.ti: ffff8d17354bc000
      RIP: 0010:[<ffffffff876c4a8e>]  [<ffffffff876c4a8e>] __wake_up_common+0x2e/0x90
      RSP: 0018:ffff8d17354bfa38  EFLAGS: 00010082
      RAX: 0000000000000000 RBX: ffff8d17362d42c8 RCX: 0000000000000000
      RDX: 0000000000000001 RSI: 0000000000000003 RDI: ffff8d17362d42c8
      RBP: ffff8d17354bfa70 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000298 R11: ffff8d173610e000 R12: ffff8d17362d42d0
      R13: 0000000000000246 R14: 0000000000000000 R15: 0000000000000003
      FS:  0000000000000000(0000) GS:ffff8d1802680000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000000000000000 CR3: 00000000f16d8000 CR4: 00000000001406e0
      Call Trace:
       [<ffffffff876c7adc>] complete+0x3c/0x50
       [<ffffffffc04242f0>] mlx4_cmd_wake_completions+0x70/0x90 [mlx4_core]
       [<ffffffffc041e7b1>] mlx4_enter_error_state+0xe1/0x380 [mlx4_core]
       [<ffffffffc041fa4b>] mlx4_comm_cmd+0x29b/0x360 [mlx4_core]
       [<ffffffffc041ff51>] __mlx4_cmd+0x441/0x920 [mlx4_core]
       [<ffffffff877f62b1>] ? __slab_free+0x81/0x2f0
       [<ffffffff87951384>] ? __radix_tree_lookup+0x84/0xf0
       [<ffffffffc043a8eb>] mlx4_free_mtt_range+0x5b/0xb0 [mlx4_core]
       [<ffffffffc043a957>] mlx4_mtt_cleanup+0x17/0x20 [mlx4_core]
       [<ffffffffc04272c7>] mlx4_free_eq+0xa7/0x1c0 [mlx4_core]
       [<ffffffffc042803e>] mlx4_cleanup_eq_table+0xde/0x130 [mlx4_core]
       [<ffffffffc0433e08>] mlx4_unload_one+0x118/0x300 [mlx4_core]
       [<ffffffffc0434191>] mlx4_remove_one+0x91/0x1f0 [mlx4_core]
      
      The fix is to set the command context array pointer to NULL after freeing
      the array.
      
      Fixes: f5aef5aa ("net/mlx4_core: Activate reset flow upon fatal command cases")
      Signed-off-by: default avatarJack Morgenstein <jackm@dev.mellanox.co.il>
      Signed-off-by: default avatarTariq Toukan <tariqt@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e15ce4b8
    • David S. Miller's avatar
      Merge branch 'mlxsw-Various-fixes' · c7fce569
      David S. Miller authored
      Ido Schimmel says:
      
      ====================
      mlxsw: Various fixes
      
      Patch #1 fixes the recently introduced QSFP thermal zones to correctly
      work with split ports, where several ports are mapped to the same
      module.
      
      Patch #2 initializes the base MAC in the minimal driver. The driver is
      using the base MAC as its parent ID and without initializing it, it is
      reported as all zeroes to user space.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c7fce569
    • Jiri Pirko's avatar
      mlxsw: minimal: Initialize base_mac · 426aa1fc
      Jiri Pirko authored
      Currently base_mac is not initialized which causes wrong reporting of
      zeroed parent_id to userspace. Fix this by initializing base_mac
      properly.
      
      Fixes: c100e47c ("mlxsw: minimal: Add ethtool support")
      Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      426aa1fc
    • Vadim Pasternak's avatar
      mlxsw: core: Prevent duplication during QSFP module initialization · 6bab45b4
      Vadim Pasternak authored
      Verify during thermal initialization if QSFP module's entry is already
      configured in order to prevent duplication.
      Such scenario could happen in case two switch drivers (PCI and I2C
      based) coexist and if after boot, splitting configuration is applied
      for some ports and then I2C based driver is re-probed.
      In such case after reboot same QSFP module, associated with split will
      be discovered by I2C based driver few times, and it will cause a crash.
      
      It could happen for example on system equipped with BMC (Baseboard
      Management Controller), running I2C based driver, when the next steps
      are performed:
      - System boot
      - Host side configures port spilt.
      - BMC side is rebooted.
      
      Fixes: 6a79507c ("mlxsw: core: Extend thermal module with per QSFP module thermal zones")
      Signed-off-by: default avatarVadim Pasternak <vadimp@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6bab45b4
    • Kangjie Lu's avatar
      net: dwmac-sun8i: fix a missing check of of_get_phy_mode · 4ec850e5
      Kangjie Lu authored
      of_get_phy_mode may fail and return a negative error code;
      the fix checks the return value of of_get_phy_mode and
      returns -EINVAL of it fails.
      Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
      Acked-by: default avatarMaxime Ripard <maxime.ripard@bootlin.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4ec850e5
    • Kangjie Lu's avatar
      net: sh_eth: fix a missing check of of_get_phy_mode · 035a14e7
      Kangjie Lu authored
      of_get_phy_mode may fail and return a negative error code;
      the fix checks the return value of of_get_phy_mode and
      returns NULL of it fails.
      
      Fixes: b356e978 ("sh_eth: add device tree support")
      Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
      Reviewed-by: default avatarSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
      Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Tested-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      035a14e7
    • Kangjie Lu's avatar
      net: 8390: fix potential NULL pointer dereferences · c7cbc3e9
      Kangjie Lu authored
      In case ioremap fails, the fix releases resources and returns
      to avoid NULL pointer dereferences.
      Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c7cbc3e9
    • Kangjie Lu's avatar
      net: fujitsu: fix a potential NULL pointer dereference · 9f4d6358
      Kangjie Lu authored
      In case ioremap fails, the fix releases the pcmcia window and
      returns -ENOMEM to avoid the NULL pointer dereference.
      Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9f4d6358
    • Kangjie Lu's avatar
      net: qlogic: fix a potential NULL pointer dereference · eb32cfcd
      Kangjie Lu authored
      In case create_singlethread_workqueue fails, the fix returns
      -ENOMEM to avoid NULL pointer dereference.
      Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      eb32cfcd
    • Kangjie Lu's avatar
      isdn: hfcpci: fix potential NULL pointer dereference · 10010493
      Kangjie Lu authored
      In case ioremap fails, the fix releases resources and returns.
      The following printk is for logging purpose and thus is
      preserved.
      Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      10010493
  3. 11 Mar, 2019 22 commits
    • David S. Miller's avatar
      Merge tag 'mlx5-fixes-2019-03-11' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux · a3b1933d
      David S. Miller authored
      Saeed Mahameed says:
      
      ====================
      Mellanox, mlx5 fixes 2019-03-11
      
      For -stable v5.0:
      ('net/mlx5e: Fix access to non-existing receive queue')
      ('net/mlx5e: Properly get the PF number phys port name ndo')
      ('net/mlx5: Fix multiple updates of steering rules in parallel')
      ('net/mlx5: Avoid panic when setting vport mac, getting vport config')
      ('net/mlx5: Avoid panic when setting vport rate')
      ('net/mlx5e: IPoIB, Fix RX checksum statistics update')
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a3b1933d
    • xiaofeis's avatar
      Documentation: devicetree: add a new optional property for port mac address · c6873d18
      xiaofeis authored
      Add documentation for a new optional property local-mac-address which
      is described in ethernet.txt.
      Signed-off-by: default avatarxiaofeis <xiaofeis@codeaurora.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c6873d18
    • Kangjie Lu's avatar
      net: rocker: fix a potential NULL pointer dereference · 5c149314
      Kangjie Lu authored
      In case kzalloc fails, the fix releases resources and returns
      NOTIFY_BAD to avoid NULL pointer dereference.
      Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5c149314
    • Kangjie Lu's avatar
      net: qlge: fix a potential NULL pointer dereference · 4280b730
      Kangjie Lu authored
      In case alloc_ordered_workqueue fails, the fix returns
      -ENOMEM to avoid NULL pointer dereference.
      Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4280b730
    • David S. Miller's avatar
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf · ab0891f5
      David S. Miller authored
      Pablo Neira Ayuso says:
      
      ====================
      Netfilter fixes for net
      
      The following patchset contains Netfilter fixes for your net tree:
      
      1) Fix list corruption in device notifier in the masquerade
         infrastructure, from Florian Westphal.
      
      2) Fix double-free of sets and use-after-free when deleting elements.
      
      3) Don't bogusly return EBUSY when removing a set after flush command.
      
      4) Use-after-free in dynamically allocate operations.
      
      5) Don't report a new ruleset generation to userspace if transaction
         list is empty, this invalidates the userspace cache innecessarily.
         From Florian Westphal.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ab0891f5
    • Eric Dumazet's avatar
      net/x25: reset state in x25_connect() · ee74d0bd
      Eric Dumazet authored
      In case x25_connect() fails and frees the socket neighbour,
      we also need to undo the change done to x25->state.
      
      Before my last bug fix, we had use-after-free so this
      patch fixes a latent bug.
      
      syzbot report :
      
      kasan: CONFIG_KASAN_INLINE enabled
      kasan: GPF could be caused by NULL-ptr deref or user memory access
      general protection fault: 0000 [#1] PREEMPT SMP KASAN
      CPU: 1 PID: 16137 Comm: syz-executor.1 Not tainted 5.0.0+ #117
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      RIP: 0010:x25_write_internal+0x1e8/0xdf0 net/x25/x25_subr.c:173
      Code: 00 40 88 b5 e0 fe ff ff 0f 85 01 0b 00 00 48 8b 8b 80 04 00 00 48 ba 00 00 00 00 00 fc ff df 48 8d 79 1c 48 89 fe 48 c1 ee 03 <0f> b6 34 16 48 89 fa 83 e2 07 83 c2 03 40 38 f2 7c 09 40 84 f6 0f
      RSP: 0018:ffff888076717a08 EFLAGS: 00010207
      RAX: ffff88805f2f2292 RBX: ffff8880a0ae6000 RCX: 0000000000000000
      kobject: 'loop5' (0000000018d0d0ee): kobject_uevent_env
      RDX: dffffc0000000000 RSI: 0000000000000003 RDI: 000000000000001c
      RBP: ffff888076717b40 R08: ffff8880950e0580 R09: ffffed100be5e46d
      R10: ffffed100be5e46c R11: ffff88805f2f2363 R12: ffff888065579840
      kobject: 'loop5' (0000000018d0d0ee): fill_kobj_path: path = '/devices/virtual/block/loop5'
      R13: 1ffff1100ece2f47 R14: 0000000000000013 R15: 0000000000000013
      FS:  00007fb88cf43700(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007f9a42a41028 CR3: 0000000087a67000 CR4: 00000000001406e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       x25_release+0xd0/0x340 net/x25/af_x25.c:658
       __sock_release+0xd3/0x2b0 net/socket.c:579
       sock_close+0x1b/0x30 net/socket.c:1162
       __fput+0x2df/0x8d0 fs/file_table.c:278
       ____fput+0x16/0x20 fs/file_table.c:309
       task_work_run+0x14a/0x1c0 kernel/task_work.c:113
       get_signal+0x1961/0x1d50 kernel/signal.c:2388
       do_signal+0x87/0x1940 arch/x86/kernel/signal.c:816
       exit_to_usermode_loop+0x244/0x2c0 arch/x86/entry/common.c:162
       prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline]
       syscall_return_slowpath arch/x86/entry/common.c:268 [inline]
       do_syscall_64+0x52d/0x610 arch/x86/entry/common.c:293
       entry_SYSCALL_64_after_hwframe+0x49/0xbe
      RIP: 0033:0x457f29
      Code: ad b8 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 b8 fb ff c3 66 2e 0f 1f 84 00 00 00 00
      RSP: 002b:00007fb88cf42c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002a
      RAX: fffffffffffffe00 RBX: 0000000000000003 RCX: 0000000000457f29
      RDX: 0000000000000012 RSI: 0000000020000080 RDI: 0000000000000004
      RBP: 000000000073bf00 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 00007fb88cf436d4
      R13: 00000000004be462 R14: 00000000004cec98 R15: 00000000ffffffff
      Modules linked in:
      
      Fixes: 95d6ebd5 ("net/x25: fix use-after-free in x25_device_event()")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: andrew hendry <andrew.hendry@gmail.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ee74d0bd
    • Christoph Paasch's avatar
      tcp: Don't access TCP_SKB_CB before initializing it · f2feaefd
      Christoph Paasch authored
      Since commit eeea10b8 ("tcp: add
      tcp_v4_fill_cb()/tcp_v4_restore_cb()"), tcp_vX_fill_cb is only called
      after tcp_filter(). That means, TCP_SKB_CB(skb)->end_seq still points to
      the IP-part of the cb.
      
      We thus should not mock with it, as this can trigger bugs (thanks
      syzkaller):
      [   12.349396] ==================================================================
      [   12.350188] BUG: KASAN: slab-out-of-bounds in ip6_datagram_recv_specific_ctl+0x19b3/0x1a20
      [   12.351035] Read of size 1 at addr ffff88006adbc208 by task test_ip6_datagr/1799
      
      Setting end_seq is actually no more necessary in tcp_filter as it gets
      initialized later on in tcp_vX_fill_cb.
      
      Cc: Eric Dumazet <edumazet@google.com>
      Fixes: eeea10b8 ("tcp: add tcp_v4_fill_cb()/tcp_v4_restore_cb()")
      Signed-off-by: default avatarChristoph Paasch <cpaasch@apple.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f2feaefd
    • Kangjie Lu's avatar
      net: thunder: fix a potential NULL pointer dereference · 0b31d98d
      Kangjie Lu authored
      In case alloc_ordered_workqueue fails, the fix reports the error
      and returns -ENOMEM.
      Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0b31d98d
    • Kangjie Lu's avatar
      net: lio_core: fix two NULL pointer dereferences · 41af8b3a
      Kangjie Lu authored
      In case octeon_alloc_soft_command fails, the fix reports the
      error and returns to avoid NULL pointer dereferences.
      Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      41af8b3a
    • Bryan Whitehead's avatar
      lan743x: Fix RX Kernel Panic · dd9d9f59
      Bryan Whitehead authored
      It has been noticed that running the speed test at
      www.speedtest.net occasionally causes a kernel panic.
      
      Investigation revealed that under this test RX buffer allocation
      sometimes fails and returns NULL. But the lan743x driver did
      not handle this case.
      
      This patch fixes this issue by attempting to allocate a buffer
      before sending the new rx packet to the OS. If the allocation
      fails then the new rx packet is dropped and the existing buffer
      is reused in the DMA ring.
      
      Updates for v2:
          Additional 2 locations where allocation was not checked,
              has been changed to reuse existing buffer.
      
      Fixes: 23f0703c ("lan743x: Add main source files for new lan743x driver")
      Signed-off-by: default avatarBryan Whitehead <Bryan.Whitehead@microchip.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      dd9d9f59
    • Florian Westphal's avatar
      netfilter: nf_tables: return immediately on empty commit · b8b27498
      Florian Westphal authored
      When running 'nft flush ruleset' while no rules exist, we will increment
      the generation counter and announce a new genid to userspace, yet
      nothing had changed in the first place.
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      b8b27498
    • Kangjie Lu's avatar
      net: liquidio: fix a NULL pointer dereference · fe543b2f
      Kangjie Lu authored
      In case octeon_alloc_soft_command fails, the fix reports the
      error and returns to avoid NULL pointer dereference.
      Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      fe543b2f
    • Tonghao Zhang's avatar
      net/mlx5: Avoid panic when setting vport rate · 24319258
      Tonghao Zhang authored
      If we try to set VFs rate on a VF (not PF) net device, the kernel
      will be crash. The commands are show as below:
      
      $ echo 2 > /sys/class/net/$MLX_PF0/device/sriov_numvfs
      $ ip link set $MLX_VF0 vf 0 max_tx_rate 2 min_tx_rate 1
      
      If not applied the first patch ("net/mlx5: Avoid panic when setting
      vport mac, getting vport config"), the command:
      
      $ ip link set $MLX_VF0 vf 0 rate 100
      
      can also crash the kernel.
      
      [ 1650.006388] RIP: 0010:mlx5_eswitch_set_vport_rate+0x1f/0x260 [mlx5_core]
      [ 1650.007092]  do_setlink+0x982/0xd20
      [ 1650.007129]  __rtnl_newlink+0x528/0x7d0
      [ 1650.007374]  rtnl_newlink+0x43/0x60
      [ 1650.007407]  rtnetlink_rcv_msg+0x2a2/0x320
      [ 1650.007484]  netlink_rcv_skb+0xcb/0x100
      [ 1650.007519]  netlink_unicast+0x17f/0x230
      [ 1650.007554]  netlink_sendmsg+0x2d2/0x3d0
      [ 1650.007592]  sock_sendmsg+0x36/0x50
      [ 1650.007625]  ___sys_sendmsg+0x280/0x2a0
      [ 1650.007963]  __sys_sendmsg+0x58/0xa0
      [ 1650.007998]  do_syscall_64+0x5b/0x180
      [ 1650.009438]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Fixes: c9497c98 ("net/mlx5: Add support for setting VF min rate")
      Cc: Mohamad Haj Yahia <mohamad@mellanox.com>
      Signed-off-by: default avatarTonghao Zhang <xiangxia.m.yue@gmail.com>
      Reviewed-by: default avatarRoi Dayan <roid@mellanox.com>
      Acked-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
      24319258
    • Tonghao Zhang's avatar
      net/mlx5: Avoid panic when setting vport mac, getting vport config · 6e77c413
      Tonghao Zhang authored
      If we try to set VFs mac address on a VF (not PF) net device,
      the kernel will be crash. The commands are show as below:
      
      $ echo 2 > /sys/class/net/$MLX_PF0/device/sriov_numvfs
      $ ip link set $MLX_VF0 vf 0 mac 00:11:22:33:44:00
      
      [exception RIP: mlx5_eswitch_set_vport_mac+41]
      [ffffb8b7079e3688] do_setlink at ffffffff8f67f85b
      [ffffb8b7079e37a8] __rtnl_newlink at ffffffff8f683778
      [ffffb8b7079e3b68] rtnl_newlink at ffffffff8f683a63
      [ffffb8b7079e3b90] rtnetlink_rcv_msg at ffffffff8f67d812
      [ffffb8b7079e3c10] netlink_rcv_skb at ffffffff8f6b88ab
      [ffffb8b7079e3c60] netlink_unicast at ffffffff8f6b808f
      [ffffb8b7079e3ca0] netlink_sendmsg at ffffffff8f6b8412
      [ffffb8b7079e3d18] sock_sendmsg at ffffffff8f6452f6
      [ffffb8b7079e3d30] ___sys_sendmsg at ffffffff8f645860
      [ffffb8b7079e3eb0] __sys_sendmsg at ffffffff8f647a38
      [ffffb8b7079e3f38] do_syscall_64 at ffffffff8f00401b
      [ffffb8b7079e3f50] entry_SYSCALL_64_after_hwframe at ffffffff8f80008c
      
      and
      
      [exception RIP: mlx5_eswitch_get_vport_config+12]
      [ffffa70607e57678] mlx5e_get_vf_config at ffffffffc03c7f8f [mlx5_core]
      [ffffa70607e57688] do_setlink at ffffffffbc67fa59
      [ffffa70607e577a8] __rtnl_newlink at ffffffffbc683778
      [ffffa70607e57b68] rtnl_newlink at ffffffffbc683a63
      [ffffa70607e57b90] rtnetlink_rcv_msg at ffffffffbc67d812
      [ffffa70607e57c10] netlink_rcv_skb at ffffffffbc6b88ab
      [ffffa70607e57c60] netlink_unicast at ffffffffbc6b808f
      [ffffa70607e57ca0] netlink_sendmsg at ffffffffbc6b8412
      [ffffa70607e57d18] sock_sendmsg at ffffffffbc6452f6
      [ffffa70607e57d30] ___sys_sendmsg at ffffffffbc645860
      [ffffa70607e57eb0] __sys_sendmsg at ffffffffbc647a38
      [ffffa70607e57f38] do_syscall_64 at ffffffffbc00401b
      [ffffa70607e57f50] entry_SYSCALL_64_after_hwframe at ffffffffbc80008c
      
      Fixes: a8d70a05 ("net/mlx5: E-Switch, Disallow vlan/spoofcheck setup if not being esw manager")
      Cc: Eli Cohen <eli@mellanox.com>
      Signed-off-by: default avatarTonghao Zhang <xiangxia.m.yue@gmail.com>
      Reviewed-by: default avatarRoi Dayan <roid@mellanox.com>
      Acked-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
      6e77c413
    • Tariq Toukan's avatar
      net/mlx5e: Fix access to non-existing receive queue · c475e11e
      Tariq Toukan authored
      In case number of channels is changed while interface is down,
      RSS indirection table is mistakenly not modified accordingly,
      causing access to out-of-range non-existing object.
      
      Fix by updating the RSS indireciton table also in the early
      return flow of interface down.
      
      Fixes: fb35c534 ("net/mlx5e: Fix NULL pointer derefernce in set channels error flow")
      Fixes: bbeb53b8 ("net/mlx5e: Move RSS params to a dedicated struct")
      Reported-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
      Tested-by: default avatarMaria Pasechnik <mariap@mellanox.com>
      Signed-off-by: default avatarTariq Toukan <tariqt@mellanox.com>
      Reviewed-by: default avatarEran Ben Elisha <eranbe@mellanox.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
      c475e11e
    • Feras Daoud's avatar
      net/mlx5e: IPoIB, Fix RX checksum statistics update · 3d6f3cdf
      Feras Daoud authored
      Update the RX checksum only if the feature is enabled.
      
      Fixes: 9d6bd752 ("net/mlx5e: IPoIB, RX handler")
      Signed-off-by: default avatarFeras Daoud <ferasda@mellanox.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
      3d6f3cdf
    • Roi Dayan's avatar
      net/mlx5: Remove redundant lag function to get pf num · 6ffb6303
      Roi Dayan authored
      The function is not being used.
      Signed-off-by: default avatarRoi Dayan <roid@mellanox.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
      6ffb6303
    • Roi Dayan's avatar
      net/mlx5e: Properly get the PF number phys port name ndo · 5b33eba9
      Roi Dayan authored
      Currently, we fail to retrieve the PF number in some cases (e.g
      single ported cards, lag capability), this further results in a
      call trace issued by the rtnetlink code, since the error value
      is not -EOPNOTSUPP. Change the implementation to be independent
      from the lag code and function properly on both two ports and
      single ported cards.
      
      Call Trace:
      
      [  194.525057] mlx5_core 0000:82:00.0: mlx5_lag_get_pf_num:605:(pid 837): no lag device, can't get pf num
      [  194.525804] WARNING: CPU: 7 PID: 837 at net/core/rtnetlink.c:3457 rtmsg_ifinfo_build_skb+0x131/0x160
      [  194.529952] CPU: 7 PID: 837 Comm: kworker/7:3 Tainted: G        W  O      5.0.0-rc7+ #3
      [  194.531307] Workqueue: events linkwatch_event
      [  194.531697] RIP: 0010:rtmsg_ifinfo_build_skb+0x131/0x160
      [  194.545007] Call Trace:
      [  194.545406]  rtmsg_ifinfo_event.part.29+0x1b/0xb0
      [  194.545810]  rtmsg_ifinfo+0x51/0x80
      [  194.546209]  netdev_state_change+0xc7/0x110
      [  194.546608]  ? dev_valid_name+0x1b0/0x1b0
      [  194.547010]  ? __local_bh_enable_ip+0xef/0x1d0
      [  194.547411]  ? lockdep_hardirqs_on+0x3ea/0x560
      [  194.547811]  ? linkwatch_do_dev+0x9b/0x100
      [  194.548207]  linkwatch_do_dev+0x9b/0x100
      [  194.548605]  __linkwatch_run_queue+0x244/0x430
      [  194.549014]  ? linkwatch_schedule_work+0x100/0x100
      [  194.549412]  ? lock_acquire+0x10f/0x2d0
      [  194.549816]  linkwatch_event+0x3f/0x50
      [  194.550212]  process_one_work+0x7d3/0x1460
      
      Fixes: c12ecc23 ("net/mlx5e: Move to use common phys port names for vport representors")
      Signed-off-by: default avatarRoi Dayan <roid@mellanox.com>
      Acked-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
      5b33eba9
    • Eli Britstein's avatar
      net/mlx5: Consolidate update FTE for all removal changes · 718ce4d6
      Eli Britstein authored
      With commit a18e879d ("net/mlx5e: Annul encap action ordering
      requirement") and a use-case of e-switch remote mirroring, the
      incremental/stepped FTE removal process done by the fs core got us to
      illegal transient states and FW errors:
      
      SET_FLOW_TABLE_ENTRY(0x936) op_mod(0x0) failed, status bad
      parameter(0x3), syndrome (0x9c2e40)
      
      To avoid that and improve FTE removal performance, aggregate the FTE's
      updates that should be applied. Remove the FTE if it is empty, or apply
      one FW update command with the aggregated updates.
      
      Fixes: a18e879d ("net/mlx5e: Annul encap action ordering requirement")
      Signed-off-by: default avatarEli Britstein <elibr@mellanox.com>
      Reviewed-by: default avatarMaor Gottlieb <maorg@mellanox.com>
      Reviewed-by: default avatarMark Bloch <markb@mellanox.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
      718ce4d6
    • Eli Britstein's avatar
      net/mlx5: Add a locked flag to node removal functions · 476d61b7
      Eli Britstein authored
      Add a locked flag to the node removal functions to signal if the
      parent is already locked from the caller function or not as a pre-step
      towards outside lock. Currently always use false with no functional
      change.
      Signed-off-by: default avatarEli Britstein <elibr@mellanox.com>
      Reviewed-by: default avatarMaor Gottlieb <maorg@mellanox.com>
      Reviewed-by: default avatarMark Bloch <markb@mellanox.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
      476d61b7
    • Eli Britstein's avatar
      net/mlx5: Add modify FTE helper function · e7aafc8f
      Eli Britstein authored
      Add modify FTE helper function and use it when deleting a rule, as a
      pre-step towards consolidated FTE modification, with no functional
      change.
      Signed-off-by: default avatarEli Britstein <elibr@mellanox.com>
      Reviewed-by: default avatarMaor Gottlieb <maorg@mellanox.com>
      Reviewed-by: default avatarMark Bloch <markb@mellanox.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
      e7aafc8f
    • Eli Britstein's avatar
      net/mlx5: Fix multiple updates of steering rules in parallel · 6237634d
      Eli Britstein authored
      There might be a condition where the fte found is not active yet. In
      this case we should not use it, but continue to search for another, or
      allocate a new one.
      
      Fixes: bd71b08e ("net/mlx5: Support multiple updates of steering rules in parallel")
      Signed-off-by: default avatarEli Britstein <elibr@mellanox.com>
      Reviewed-by: default avatarMaor Gottlieb <maorg@mellanox.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
      6237634d