Skip to content
  1. Jun 30, 2021
    • Andrew Lunn's avatar
      usb: core: hub: Disable autosuspend for Cypress CY7C65632 · f0a3391d
      Andrew Lunn authored
      commit a7d8d1c7 upstream.
      
      The Cypress CY7C65632 appears to have an issue with auto suspend and
      detecting devices, not too dissimilar to the SMSC 5534B hub. It is
      easiest to reproduce by connecting multiple mass storage devices to
      the hub at the same time. On a Lenovo Yoga, around 1 in 3 attempts
      result in the devices not being detected. It is however possible to
      make them appear using lsusb -v.
      
      Disabling autosuspend for this hub resolves the issue.
      
      Fixes: 1208f9e1
      
       ("USB: hub: Fix the broken detection of USB3 device in SMSC hub")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Link: https://lore.kernel.org/r/20210614155524.2228800-1-andrew@lunn.ch
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f0a3391d
    • Pavel Skripkin's avatar
      can: mcba_usb: fix memory leak in mcba_usb · a115198c
      Pavel Skripkin authored
      commit 91c02557 upstream.
      
      Syzbot reported memory leak in SocketCAN driver for Microchip CAN BUS
      Analyzer Tool. The problem was in unfreed usb_coherent.
      
      In mcba_usb_start() 20 coherent buffers are allocated and there is
      nothing, that frees them:
      
      1) In callback function the urb is resubmitted and that's all
      2) In disconnect function urbs are simply killed, but URB_FREE_BUFFER
         is not set (see mcba_usb_start) and this flag cannot be used with
         coherent buffers.
      
      Fail log:
      | [ 1354.053291][ T8413] mcba_usb 1-1:0.0 can0: device disconnected
      | [ 1367.059384][ T8420] kmemleak: 20 new suspected memory leaks (see /sys/kernel/debug/kmem)
      
      So, all allocated buffers should be freed with usb_free_coherent()
      explicitly
      
      NOTE:
      The same pattern for allocating and freeing coherent buffers
      is used in drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
      
      Fixes: 51f3baad
      
       ("can: mcba_usb: Add support for Microchip CAN BUS Analyzer")
      Link: https://lore.kernel.org/r/20210609215833.30393-1-paskripkin@gmail.com
      Cc: linux-stable <stable@vger.kernel.org>
      Reported-and-tested-by: default avatar <syzbot+57281c762a3922e14dfe@syzkaller.appspotmail.com>
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a115198c
    • Norbert Slusarek's avatar
      can: bcm: fix infoleak in struct bcm_msg_head · 8899857d
      Norbert Slusarek authored
      commit 5e87ddbe upstream.
      
      On 64-bit systems, struct bcm_msg_head has an added padding of 4 bytes between
      struct members count and ival1. Even though all struct members are initialized,
      the 4-byte hole will contain data from the kernel stack. This patch zeroes out
      struct bcm_msg_head before usage, preventing infoleaks to userspace.
      
      Fixes: ffd980f9
      
       ("[CAN]: Add broadcast manager (bcm) protocol")
      Link: https://lore.kernel.org/r/trinity-7c1b2e82-e34f-4885-8060-2cd7a13769ce-1623532166177@3c-app-gmx-bs52
      Cc: linux-stable <stable@vger.kernel.org>
      Signed-off-by: default avatarNorbert Slusarek <nslusarek@gmx.net>
      Acked-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8899857d
    • Riwen Lu's avatar
      hwmon: (scpi-hwmon) shows the negative temperature properly · e6a1d16e
      Riwen Lu authored
      [ Upstream commit 78d13552
      
       ]
      
      The scpi hwmon shows the sub-zero temperature in an unsigned integer,
      which would confuse the users when the machine works in low temperature
      environment. This shows the sub-zero temperature in an signed value and
      users can get it properly from sensors.
      
      Signed-off-by: default avatarRiwen Lu <luriwen@kylinos.cn>
      Tested-by: default avatarXin Chen <chenxin@kylinos.cn>
      Link: https://lore.kernel.org/r/20210604030959.736379-1-luriwen@kylinos.cn
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e6a1d16e
    • Chen Li's avatar
      radeon: use memcpy_to/fromio for UVD fw upload · 8bc97e82
      Chen Li authored
      [ Upstream commit ab8363d3 ]
      
      I met a gpu addr bug recently and the kernel log
      tells me the pc is memcpy/memset and link register is
      radeon_uvd_resume.
      
      As we know, in some architectures, optimized memcpy/memset
      may not work well on device memory. Trival memcpy_toio/memset_io
      can fix this problem.
      
      BTW, amdgpu has already done it in:
      commit ba0b2275
      
       ("drm/amdgpu: use memcpy_to/fromio for UVD fw upload"),
      that's why it has no this issue on the same gpu and platform.
      
      Signed-off-by: default avatarChen Li <chenli@uniontech.com>
      Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8bc97e82
    • Sergio Paracuellos's avatar
      pinctrl: ralink: rt2880: avoid to error in calls is pin is already enabled · 349f4b6c
      Sergio Paracuellos authored
      [ Upstream commit eb367d87
      
       ]
      
      In 'rt2880_pmx_group_enable' driver is printing an error and returning
      -EBUSY if a pin has been already enabled. This begets anoying messages
      in the caller when this happens like the following:
      
      rt2880-pinmux pinctrl: pcie is already enabled
      mt7621-pci 1e140000.pcie: Error applying setting, reverse things back
      
      To avoid this just print the already enabled message in the pinctrl
      driver and return 0 instead to not confuse the user with a real
      bad problem.
      
      Signed-off-by: default avatarSergio Paracuellos <sergio.paracuellos@gmail.com>
      Link: https://lore.kernel.org/r/20210604055337.20407-1-sergio.paracuellos@gmail.com
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      349f4b6c
    • Jack Yu's avatar
      ASoC: rt5659: Fix the lost powers for the HDA header · d8c93d34
      Jack Yu authored
      [ Upstream commit 6308c44e
      
       ]
      
      The power of "LDO2", "MICBIAS1" and "Mic Det Power" were powered off after
      the DAPM widgets were added, and these powers were set by the JD settings
      "RT5659_JD_HDA_HEADER" in the probe function. In the codec probe function,
      these powers were ignored to prevent them controlled by DAPM.
      
      Signed-off-by: default avatarOder Chiou <oder_chiou@realtek.com>
      Signed-off-by: default avatarJack Yu <jack.yu@realtek.com>
      Message-Id: <15fced51977b458798ca4eebf03dafb9@realtek.com>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d8c93d34
    • Pavel Skripkin's avatar
      net: ethernet: fix potential use-after-free in ec_bhf_remove · 02609168
      Pavel Skripkin authored
      [ Upstream commit 9cca0c2d ]
      
      static void ec_bhf_remove(struct pci_dev *dev)
      {
      ...
      	struct ec_bhf_priv *priv = netdev_priv(net_dev);
      
      	unregister_netdev(net_dev);
      	free_netdev(net_dev);
      
      	pci_iounmap(dev, priv->dma_io);
      	pci_iounmap(dev, priv->io);
      ...
      }
      
      priv is netdev private data, but it is used
      after free_netdev(). It can cause use-after-free when accessing priv
      pointer. So, fix it by moving free_netdev() after pci_iounmap()
      calls.
      
      Fixes: 6af55ff5
      
       ("Driver for Beckhoff CX5020 EtherCAT master module.")
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      02609168
    • Toke Høiland-Jørgensen's avatar
      icmp: don't send out ICMP messages with a source address of 0.0.0.0 · 3bf50dc8
      Toke Høiland-Jørgensen authored
      [ Upstream commit 32182747 ]
      
      When constructing ICMP response messages, the kernel will try to pick a
      suitable source address for the outgoing packet. However, if no IPv4
      addresses are configured on the system at all, this will fail and we end up
      producing an ICMP message with a source address of 0.0.0.0. This can happen
      on a box routing IPv4 traffic via v6 nexthops, for instance.
      
      Since 0.0.0.0 is not generally routable on the internet, there's a good
      chance that such ICMP messages will never make it back to the sender of the
      original packet that the ICMP message was sent in response to. This, in
      turn, can create connectivity and PMTUd problems for senders. Fortunately,
      RFC7600 reserves a dummy address to be used as a source for ICMP
      messages (192.0.0.8/32), so let's teach the kernel to substitute that
      address as a last resort if the regular source address selection procedure
      fails.
      
      Below is a quick example reproducing this issue with network namespaces:
      
      ip netns add ns0
      ip l add type veth peer netns ns0
      ip l set dev veth0 up
      ip a add 10.0.0.1/24 dev veth0
      ip a add fc00:dead:cafe:42::1/64 dev veth0
      ip r add 10.1.0.0/24 via inet6 fc00:dead:cafe:42::2
      ip -n ns0 l set dev veth0 up
      ip -n ns0 a add fc00:dead:cafe:42::2/64 dev veth0
      ip -n ns0 r add 10.0.0.0/24 via inet6 fc00:dead:cafe:42::1
      ip netns exec ns0 sysctl -w net.ipv4.icmp_ratelimit=0
      ip netns exec ns0 sysctl -w net.ipv4.ip_forward=1
      tcpdump -tpni veth0 -c 2 icmp &
      ping -w 1 10.1.0.1 > /dev/null
      tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
      listening on veth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
      IP 10.0.0.1 > 10.1.0.1: ICMP echo request, id 29, seq 1, length 64
      IP 0.0.0.0 > 10.0.0.1: ICMP net 10.1.0.1 unreachable, length 92
      2 packets captured
      2 packets received by filter
      0 packets dropped by kernel
      
      With this patch the above capture changes to:
      IP 10.0.0.1 > 10.1.0.1: ICMP echo request, id 31127, seq 1, length 64
      IP 192.0.0.8 > 10.0.0.1: ICMP net 10.1.0.1 unreachable, length 92
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Reported-by: default avatarJuliusz Chroboczek <jch@irif.fr>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3bf50dc8
    • Linyu Yuan's avatar
      net: cdc_eem: fix tx fixup skb leak · f4e6a7f1
      Linyu Yuan authored
      [ Upstream commit c3b26fdf ]
      
      when usbnet transmit a skb, eem fixup it in eem_tx_fixup(),
      if skb_copy_expand() failed, it return NULL,
      usbnet_start_xmit() will have no chance to free original skb.
      
      fix it by free orginal skb in eem_tx_fixup() first,
      then check skb clone status, if failed, return NULL to usbnet.
      
      Fixes: 9f722c09
      
       ("usbnet: CDC EEM support (v5)")
      Signed-off-by: default avatarLinyu Yuan <linyyuan@codeaurora.org>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f4e6a7f1
    • Pavel Skripkin's avatar
      net: hamradio: fix memory leak in mkiss_close · c16c4716
      Pavel Skripkin authored
      [ Upstream commit 7edcc682 ]
      
      My local syzbot instance hit memory leak in
      mkiss_open()[1]. The problem was in missing
      free_netdev() in mkiss_close().
      
      In mkiss_open() netdevice is allocated and then
      registered, but in mkiss_close() netdevice was
      only unregistered, but not freed.
      
      Fail log:
      
      BUG: memory leak
      unreferenced object 0xffff8880281ba000 (size 4096):
        comm "syz-executor.1", pid 11443, jiffies 4295046091 (age 17.660s)
        hex dump (first 32 bytes):
          61 78 30 00 00 00 00 00 00 00 00 00 00 00 00 00  ax0.............
          00 27 fa 2a 80 88 ff ff 00 00 00 00 00 00 00 00  .'.*............
        backtrace:
          [<ffffffff81a27201>] kvmalloc_node+0x61/0xf0
          [<ffffffff8706e7e8>] alloc_netdev_mqs+0x98/0xe80
          [<ffffffff84e64192>] mkiss_open+0xb2/0x6f0 [1]
          [<ffffffff842355db>] tty_ldisc_open+0x9b/0x110
          [<ffffffff84236488>] tty_set_ldisc+0x2e8/0x670
          [<ffffffff8421f7f3>] tty_ioctl+0xda3/0x1440
          [<ffffffff81c9f273>] __x64_sys_ioctl+0x193/0x200
          [<ffffffff8911263a>] do_syscall_64+0x3a/0xb0
          [<ffffffff89200068>] entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      BUG: memory leak
      unreferenced object 0xffff8880141a9a00 (size 96):
        comm "syz-executor.1", pid 11443, jiffies 4295046091 (age 17.660s)
        hex dump (first 32 bytes):
          e8 a2 1b 28 80 88 ff ff e8 a2 1b 28 80 88 ff ff  ...(.......(....
          98 92 9c aa b0 40 02 00 00 00 00 00 00 00 00 00  .....@..........
        backtrace:
          [<ffffffff8709f68b>] __hw_addr_create_ex+0x5b/0x310
          [<ffffffff8709fb38>] __hw_addr_add_ex+0x1f8/0x2b0
          [<ffffffff870a0c7b>] dev_addr_init+0x10b/0x1f0
          [<ffffffff8706e88b>] alloc_netdev_mqs+0x13b/0xe80
          [<ffffffff84e64192>] mkiss_open+0xb2/0x6f0 [1]
          [<ffffffff842355db>] tty_ldisc_open+0x9b/0x110
          [<ffffffff84236488>] tty_set_ldisc+0x2e8/0x670
          [<ffffffff8421f7f3>] tty_ioctl+0xda3/0x1440
          [<ffffffff81c9f273>] __x64_sys_ioctl+0x193/0x200
          [<ffffffff8911263a>] do_syscall_64+0x3a/0xb0
          [<ffffffff89200068>] entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      BUG: memory leak
      unreferenced object 0xffff8880219bfc00 (size 512):
        comm "syz-executor.1", pid 11443, jiffies 4295046091 (age 17.660s)
        hex dump (first 32 bytes):
          00 a0 1b 28 80 88 ff ff 80 8f b1 8d ff ff ff ff  ...(............
          80 8f b1 8d ff ff ff ff 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<ffffffff81a27201>] kvmalloc_node+0x61/0xf0
          [<ffffffff8706eec7>] alloc_netdev_mqs+0x777/0xe80
          [<ffffffff84e64192>] mkiss_open+0xb2/0x6f0 [1]
          [<ffffffff842355db>] tty_ldisc_open+0x9b/0x110
          [<ffffffff84236488>] tty_set_ldisc+0x2e8/0x670
          [<ffffffff8421f7f3>] tty_ioctl+0xda3/0x1440
          [<ffffffff81c9f273>] __x64_sys_ioctl+0x193/0x200
          [<ffffffff8911263a>] do_syscall_64+0x3a/0xb0
          [<ffffffff89200068>] entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      BUG: memory leak
      unreferenced object 0xffff888029b2b200 (size 256):
        comm "syz-executor.1", pid 11443, jiffies 4295046091 (age 17.660s)
        hex dump (first 32 bytes):
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<ffffffff81a27201>] kvmalloc_node+0x61/0xf0
          [<ffffffff8706f062>] alloc_netdev_mqs+0x912/0xe80
          [<ffffffff84e64192>] mkiss_open+0xb2/0x6f0 [1]
          [<ffffffff842355db>] tty_ldisc_open+0x9b/0x110
          [<ffffffff84236488>] tty_set_ldisc+0x2e8/0x670
          [<ffffffff8421f7f3>] tty_ioctl+0xda3/0x1440
          [<ffffffff81c9f273>] __x64_sys_ioctl+0x193/0x200
          [<ffffffff8911263a>] do_syscall_64+0x3a/0xb0
          [<ffffffff89200068>] entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      Fixes: 815f62bf
      
       ("[PATCH] SMP rewrite of mkiss")
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c16c4716
    • Christophe JAILLET's avatar
      be2net: Fix an error handling path in 'be_probe()' · d6b97359
      Christophe JAILLET authored
      [ Upstream commit c19c8c0e ]
      
      If an error occurs after a 'pci_enable_pcie_error_reporting()' call, it
      must be undone by a corresponding 'pci_disable_pcie_error_reporting()'
      call, as already done in the remove function.
      
      Fixes: d6b6d987
      
       ("be2net: use PCIe AER capability")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Acked-by: default avatarSomnath Kotur <somnath.kotur@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d6b97359
    • Eric Dumazet's avatar
      net/af_unix: fix a data-race in unix_dgram_sendmsg / unix_release_sock · 0693d384
      Eric Dumazet authored
      [ Upstream commit a494bd64 ]
      
      While unix_may_send(sk, osk) is called while osk is locked, it appears
      unix_release_sock() can overwrite unix_peer() after this lock has been
      released, making KCSAN unhappy.
      
      Changing unix_release_sock() to access/change unix_peer()
      before lock is released should fix this issue.
      
      BUG: KCSAN: data-race in unix_dgram_sendmsg / unix_release_sock
      
      write to 0xffff88810465a338 of 8 bytes by task 20852 on cpu 1:
       unix_release_sock+0x4ed/0x6e0 net/unix/af_unix.c:558
       unix_release+0x2f/0x50 net/unix/af_unix.c:859
       __sock_release net/socket.c:599 [inline]
       sock_close+0x6c/0x150 net/socket.c:1258
       __fput+0x25b/0x4e0 fs/file_table.c:280
       ____fput+0x11/0x20 fs/file_table.c:313
       task_work_run+0xae/0x130 kernel/task_work.c:164
       tracehook_notify_resume include/linux/tracehook.h:189 [inline]
       exit_to_user_mode_loop kernel/entry/common.c:175 [inline]
       exit_to_user_mode_prepare+0x156/0x190 kernel/entry/common.c:209
       __syscall_exit_to_user_mode_work kernel/entry/common.c:291 [inline]
       syscall_exit_to_user_mode+0x20/0x40 kernel/entry/common.c:302
       do_syscall_64+0x56/0x90 arch/x86/entry/common.c:57
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      read to 0xffff88810465a338 of 8 bytes by task 20888 on cpu 0:
       unix_may_send net/unix/af_unix.c:189 [inline]
       unix_dgram_sendmsg+0x923/0x1610 net/unix/af_unix.c:1712
       sock_sendmsg_nosec net/socket.c:654 [inline]
       sock_sendmsg net/socket.c:674 [inline]
       ____sys_sendmsg+0x360/0x4d0 net/socket.c:2350
       ___sys_sendmsg net/socket.c:2404 [inline]
       __sys_sendmmsg+0x315/0x4b0 net/socket.c:2490
       __do_sys_sendmmsg net/socket.c:2519 [inline]
       __se_sys_sendmmsg net/socket.c:2516 [inline]
       __x64_sys_sendmmsg+0x53/0x60 net/socket.c:2516
       do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      value changed: 0xffff888167905400 -> 0x0000000000000000
      
      Reported by Kernel Concurrency Sanitizer on:
      CPU: 0 PID: 20888 Comm: syz-executor.0 Not tainted 5.13.0-rc5-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      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>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0693d384
    • Chengyang Fan's avatar
      net: ipv4: fix memory leak in ip_mc_add1_src · 1e28018b
      Chengyang Fan authored
      [ Upstream commit d8e29730 ]
      
      BUG: memory leak
      unreferenced object 0xffff888101bc4c00 (size 32):
        comm "syz-executor527", pid 360, jiffies 4294807421 (age 19.329s)
        hex dump (first 32 bytes):
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
          01 00 00 00 00 00 00 00 ac 14 14 bb 00 00 02 00 ................
        backtrace:
          [<00000000f17c5244>] kmalloc include/linux/slab.h:558 [inline]
          [<00000000f17c5244>] kzalloc include/linux/slab.h:688 [inline]
          [<00000000f17c5244>] ip_mc_add1_src net/ipv4/igmp.c:1971 [inline]
          [<00000000f17c5244>] ip_mc_add_src+0x95f/0xdb0 net/ipv4/igmp.c:2095
          [<000000001cb99709>] ip_mc_source+0x84c/0xea0 net/ipv4/igmp.c:2416
          [<0000000052cf19ed>] do_ip_setsockopt net/ipv4/ip_sockglue.c:1294 [inline]
          [<0000000052cf19ed>] ip_setsockopt+0x114b/0x30c0 net/ipv4/ip_sockglue.c:1423
          [<00000000477edfbc>] raw_setsockopt+0x13d/0x170 net/ipv4/raw.c:857
          [<00000000e75ca9bb>] __sys_setsockopt+0x158/0x270 net/socket.c:2117
          [<00000000bdb993a8>] __do_sys_setsockopt net/socket.c:2128 [inline]
          [<00000000bdb993a8>] __se_sys_setsockopt net/socket.c:2125 [inline]
          [<00000000bdb993a8>] __x64_sys_setsockopt+0xba/0x150 net/socket.c:2125
          [<000000006a1ffdbd>] do_syscall_64+0x40/0x80 arch/x86/entry/common.c:47
          [<00000000b11467c4>] entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      In commit 24803f38 ("igmp: do not remove igmp souce list info when set
      link down"), the ip_mc_clear_src() in ip_mc_destroy_dev() was removed,
      because it was also called in igmpv3_clear_delrec().
      
      Rough callgraph:
      
      inetdev_destroy
      -> ip_mc_destroy_dev
           -> igmpv3_clear_delrec
              -> ip_mc_clear_src
      -> RCU_INIT_POINTER(dev->ip_ptr, NULL)
      
      However, ip_mc_clear_src() called in igmpv3_clear_delrec() doesn't
      release in_dev->mc_list->sources. And RCU_INIT_POINTER() assigns the
      NULL to dev->ip_ptr. As a result, in_dev cannot be obtained through
      inetdev_by_index() and then in_dev->mc_list->sources cannot be released
      by ip_mc_del1_src() in the sock_close. Rough call sequence goes like:
      
      sock_close
      -> __sock_release
         -> inet_release
            -> ip_mc_drop_socket
               -> inetdev_by_index
               -> ip_mc_leave_src
                  -> ip_mc_del_src
                     -> ip_mc_del1_src
      
      So we still need to call ip_mc_clear_src() in ip_mc_destroy_dev() to free
      in_dev->mc_list->sources.
      
      Fixes: 24803f38
      
       ("igmp: do not remove igmp souce list info ...")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarChengyang Fan <cy.fan@huawei.com>
      Acked-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1e28018b
    • Joakim Zhang's avatar
      net: fec_ptp: fix issue caused by refactor the fec_devtype · d9326579
      Joakim Zhang authored
      [ Upstream commit d2376564 ]
      
      Commit da722186 ("net: fec: set GPR bit on suspend by DT configuration.")
      refactor the fec_devtype, need adjust ptp driver accordingly.
      
      Fixes: da722186
      
       ("net: fec: set GPR bit on suspend by DT configuration.")
      Signed-off-by: default avatarJoakim Zhang <qiangqing.zhang@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d9326579
    • Dongliang Mu's avatar
      net: usb: fix possible use-after-free in smsc75xx_bind · 2fc8300c
      Dongliang Mu authored
      [ Upstream commit 56b786d8 ]
      
      The commit 46a8b29c ("net: usb: fix memory leak in smsc75xx_bind")
      fails to clean up the work scheduled in smsc75xx_reset->
      smsc75xx_set_multicast, which leads to use-after-free if the work is
      scheduled to start after the deallocation. In addition, this patch
      also removes a dangling pointer - dev->data[0].
      
      This patch calls cancel_work_sync to cancel the scheduled work and set
      the dangling pointer to NULL.
      
      Fixes: 46a8b29c
      
       ("net: usb: fix memory leak in smsc75xx_bind")
      Signed-off-by: default avatarDongliang Mu <mudongliangabcd@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2fc8300c
    • Maciej Żenczykowski's avatar
      net: cdc_ncm: switch to eth%d interface naming · 13dbc21c
      Maciej Żenczykowski authored
      [ Upstream commit c1a3d406 ]
      
      This is meant to make the host side cdc_ncm interface consistently
      named just like the older CDC protocols: cdc_ether & cdc_ecm
      (and even rndis_host), which all use 'FLAG_ETHER | FLAG_POINTTOPOINT'.
      
      include/linux/usb/usbnet.h:
        #define FLAG_ETHER	0x0020		/* maybe use "eth%d" names */
        #define FLAG_WLAN	0x0080		/* use "wlan%d" names */
        #define FLAG_WWAN	0x0400		/* use "wwan%d" names */
        #define FLAG_POINTTOPOINT 0x1000	/* possibly use "usb%d" names */
      
      drivers/net/usb/usbnet.c @ line 1711:
        strcpy (net->name, "usb%d");
        ...
        // heuristic:  "usb%d" for links we know are two-host,
        // else "eth%d" when there's reasonable doubt.  userspace
        // can rename the link if it knows better.
        if ((dev->driver_info->flags & FLAG_ETHER) != 0 &&
            ((dev->driver_info->flags & FLAG_POINTTOPOINT) == 0 ||
             (net->dev_addr [0] & 0x02) == 0))
                strcpy (net->name, "eth%d");
        /* WLAN devices should always be named "wlan%d" */
        if ((dev->driver_info->flags & FLAG_WLAN) != 0)
                strcpy(net->name, "wlan%d");
        /* WWAN devices should always be named "wwan%d" */
        if ((dev->driver_info->flags & FLAG_WWAN) != 0)
                strcpy(net->name, "wwan%d");
      
      So by using ETHER | POINTTOPOINT the interface naming is
      either usb%d or eth%d based on the global uniqueness of the
      mac address of the device.
      
      Without this 2.5gbps ethernet dongles which all seem to use the cdc_ncm
      driver end up being called usb%d instead of eth%d even though they're
      definitely not two-host.  (All 1gbps & 5gbps ethernet usb dongles I've
      tested don't hit this problem due to use of different drivers, primarily
      r8152 and aqc111)
      
      Fixes tag is based purely on git blame, and is really just here to make
      sure this hits LTS branches newer than v4.5.
      
      Cc: Lorenzo Colitti <lorenzo@google.com>
      Fixes: 4d06dd53
      
       ("cdc_ncm: do not call usbnet_link_change from cdc_ncm_bind")
      Signed-off-by: default avatarMaciej Żenczykowski <maze@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      13dbc21c
    • Jakub Kicinski's avatar
      ptp: improve max_adj check against unreasonable values · cee0a9c1
      Jakub Kicinski authored
      [ Upstream commit 475b92f9 ]
      
      Scaled PPM conversion to PPB may (on 64bit systems) result
      in a value larger than s32 can hold (freq/scaled_ppm is a long).
      This means the kernel will not correctly reject unreasonably
      high ->freq values (e.g. > 4294967295ppb, 281474976645 scaled PPM).
      
      The conversion is equivalent to a division by ~66 (65.536),
      so the value of ppb is always smaller than ppm, but not small
      enough to assume narrowing the type from long -> s32 is okay.
      
      Note that reasonable user space (e.g. ptp4l) will not use such
      high values, anyway, 4289046510ppb ~= 4.3x, so the fix is
      somewhat pedantic.
      
      Fixes: d39a7435 ("ptp: validate the requested frequency adjustment.")
      Fixes: d94ba80e
      
       ("ptp: Added a brand new class driver for ptp clocks.")
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cee0a9c1
    • Shalom Toledo's avatar
      ptp: ptp_clock: Publish scaled_ppm_to_ppb · b5200624
      Shalom Toledo authored
      [ Upstream commit 4368dada
      
       ]
      
      Publish scaled_ppm_to_ppb to allow drivers to use it.
      
      Signed-off-by: default avatarShalom Toledo <shalomt@mellanox.com>
      Reviewed-by: default avatarPetr Machata <petrm@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b5200624
    • Pavel Skripkin's avatar
      net: qrtr: fix OOB Read in qrtr_endpoint_post · f8111c0d
      Pavel Skripkin authored
      [ Upstream commit ad9d24c9 ]
      
      Syzbot reported slab-out-of-bounds Read in
      qrtr_endpoint_post. The problem was in wrong
      _size_ type:
      
      	if (len != ALIGN(size, 4) + hdrlen)
      		goto err;
      
      If size from qrtr_hdr is 4294967293 (0xfffffffd), the result of
      ALIGN(size, 4) will be 0. In case of len == hdrlen and size == 4294967293
      in header this check won't fail and
      
      	skb_put_data(skb, data + hdrlen, size);
      
      will read out of bound from data, which is hdrlen allocated block.
      
      Fixes: 194ccc88
      
       ("net: qrtr: Support decoding incoming v2 packets")
      Reported-and-tested-by: default avatar <syzbot+1917d778024161609247@syzkaller.appspotmail.com>
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f8111c0d
    • Christophe JAILLET's avatar
      netxen_nic: Fix an error handling path in 'netxen_nic_probe()' · dc9b4446
      Christophe JAILLET authored
      [ Upstream commit 49a10c7b ]
      
      If an error occurs after a 'pci_enable_pcie_error_reporting()' call, it
      must be undone by a corresponding 'pci_disable_pcie_error_reporting()'
      call, as already done in the remove function.
      
      Fixes: e87ad553
      
       ("netxen: support pci error handlers")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      dc9b4446
    • Christophe JAILLET's avatar
      qlcnic: Fix an error handling path in 'qlcnic_probe()' · ac2e10e2
      Christophe JAILLET authored
      [ Upstream commit cb337660 ]
      
      If an error occurs after a 'pci_enable_pcie_error_reporting()' call, it
      must be undone by a corresponding 'pci_disable_pcie_error_reporting()'
      call, as already done in the remove function.
      
      Fixes: 451724c8
      
       ("qlcnic: aer support")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ac2e10e2
    • Changbin Du's avatar
      net: make get_net_ns return error if NET_NS is disabled · 29174c88
      Changbin Du authored
      [ Upstream commit ea6932d7
      
       ]
      
      There is a panic in socket ioctl cmd SIOCGSKNS when NET_NS is not enabled.
      The reason is that nsfs tries to access ns->ops but the proc_ns_operations
      is not implemented in this case.
      
      [7.670023] Unable to handle kernel NULL pointer dereference at virtual address 00000010
      [7.670268] pgd = 32b54000
      [7.670544] [00000010] *pgd=00000000
      [7.671861] Internal error: Oops: 5 [#1] SMP ARM
      [7.672315] Modules linked in:
      [7.672918] CPU: 0 PID: 1 Comm: systemd Not tainted 5.13.0-rc3-00375-g6799d4f2da49 #16
      [7.673309] Hardware name: Generic DT based system
      [7.673642] PC is at nsfs_evict+0x24/0x30
      [7.674486] LR is at clear_inode+0x20/0x9c
      
      The same to tun SIOCGSKNS command.
      
      To fix this problem, we make get_net_ns() return -EINVAL when NET_NS is
      disabled. Meanwhile move it to right place net/core/net_namespace.c.
      
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Fixes: c62cce2c
      
       ("net: add an ioctl to get a socket network namespace")
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Christian Brauner <christian.brauner@ubuntu.com>
      Suggested-by: default avatarJakub Kicinski <kuba@kernel.org>
      Acked-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      29174c88
    • Pedro Tammela's avatar
      net: add documentation to socket.c · 137e2b34
      Pedro Tammela authored
      [ Upstream commit 8a3c245c
      
       ]
      
      Adds missing sphinx documentation to the
      socket.c's functions. Also fixes some whitespaces.
      
      I also changed the style of older documentation as an
      effort to have an uniform documentation style.
      
      Signed-off-by: default avatarPedro Tammela <pctammela@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      137e2b34
    • Jisheng Zhang's avatar
      net: stmmac: dwmac1000: Fix extended MAC address registers definition · 8a8ea7f1
      Jisheng Zhang authored
      [ Upstream commit 1adb20f0 ]
      
      The register starts from 0x800 is the 16th MAC address register rather
      than the first one.
      
      Fixes: cffb13f4
      
       ("stmmac: extend mac addr reg and fix perfect filering")
      Signed-off-by: default avatarJisheng Zhang <Jisheng.Zhang@synaptics.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8a8ea7f1
    • Christophe JAILLET's avatar
      alx: Fix an error handling path in 'alx_probe()' · a2750410
      Christophe JAILLET authored
      [ Upstream commit 33e38144 ]
      
      If an error occurs after a 'pci_enable_pcie_error_reporting()' call, it
      must be undone by a corresponding 'pci_disable_pcie_error_reporting()'
      call, as already done in the remove function.
      
      Fixes: ab69bde6
      
       ("alx: add a simple AR816x/AR817x device driver")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a2750410
    • Maxim Mikityanskiy's avatar
      sch_cake: Fix out of bounds when parsing TCP options and header · 595897ef
      Maxim Mikityanskiy authored
      [ Upstream commit ba91c49d ]
      
      The TCP option parser in cake qdisc (cake_get_tcpopt and
      cake_tcph_may_drop) could read one byte out of bounds. When the length
      is 1, the execution flow gets into the loop, reads one byte of the
      opcode, and if the opcode is neither TCPOPT_EOL nor TCPOPT_NOP, it reads
      one more byte, which exceeds the length of 1.
      
      This fix is inspired by commit 9609dad2 ("ipv4: tcp_input: fix stack
      out of bounds when parsing TCP options.").
      
      v2 changes:
      
      Added doff validation in cake_get_tcphdr to avoid parsing garbage as TCP
      header. Although it wasn't strictly an out-of-bounds access (memory was
      allocated), garbage values could be read where CAKE expected the TCP
      header if doff was smaller than 5.
      
      Cc: Young Xiao <92siuyang@gmail.com>
      Fixes: 8b713881
      
       ("sch_cake: Add optional ACK filter")
      Signed-off-by: default avatarMaxim Mikityanskiy <maximmi@nvidia.com>
      Acked-by: default avatarToke Høiland-Jørgensen <toke@toke.dk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      595897ef
    • Maxim Mikityanskiy's avatar
      netfilter: synproxy: Fix out of bounds when parsing TCP options · 7d9a9a1a
      Maxim Mikityanskiy authored
      [ Upstream commit 5fc177ab ]
      
      The TCP option parser in synproxy (synproxy_parse_options) could read
      one byte out of bounds. When the length is 1, the execution flow gets
      into the loop, reads one byte of the opcode, and if the opcode is
      neither TCPOPT_EOL nor TCPOPT_NOP, it reads one more byte, which exceeds
      the length of 1.
      
      This fix is inspired by commit 9609dad2 ("ipv4: tcp_input: fix stack
      out of bounds when parsing TCP options.").
      
      v2 changes:
      
      Added an early return when length < 0 to avoid calling
      skb_header_pointer with negative length.
      
      Cc: Young Xiao <92siuyang@gmail.com>
      Fixes: 48b1de4c
      
       ("netfilter: add SYNPROXY core/target")
      Signed-off-by: default avatarMaxim Mikityanskiy <maximmi@nvidia.com>
      Reviewed-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7d9a9a1a
    • Aya Levin's avatar
      net/mlx5e: Block offload of outer header csum for UDP tunnels · 0facea51
      Aya Levin authored
      [ Upstream commit 6d6727dd ]
      
      The device is able to offload either the outer header csum or inner
      header csum. The driver utilizes the inner csum offload. Hence, block
      setting of tx-udp_tnl-csum-segmentation and set it to off[fixed].
      
      Fixes: b49663c8
      
       ("net/mlx5e: Add support for UDP tunnel segmentation with outer checksum offload")
      Signed-off-by: default avatarAya Levin <ayal@nvidia.com>
      Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0facea51
    • Huy Nguyen's avatar
      net/mlx5e: Remove dependency in IPsec initialization flows · aec707a0
      Huy Nguyen authored
      [ Upstream commit 8ad893e5 ]
      
      Currently, IPsec feature is disabled because mlx5e_build_nic_netdev
      is required to be called after mlx5e_ipsec_init. This requirement is
      invalid as mlx5e_build_nic_netdev and mlx5e_ipsec_init initialize
      independent resources.
      
      Remove ipsec pointer check in mlx5e_build_nic_netdev so that the
      two functions can be called at any order.
      
      Fixes: 547eede0
      
       ("net/mlx5e: IPSec, Innova IPSec offload infrastructure")
      Signed-off-by: default avatarHuy Nguyen <huyn@nvidia.com>
      Reviewed-by: default avatarRaed Salem <raeds@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      aec707a0
    • Ido Schimmel's avatar
      rtnetlink: Fix regression in bridge VLAN configuration · ba14e0b4
      Ido Schimmel authored
      [ Upstream commit d2e381c4 ]
      
      Cited commit started returning errors when notification info is not
      filled by the bridge driver, resulting in the following regression:
      
       # ip link add name br1 type bridge vlan_filtering 1
       # bridge vlan add dev br1 vid 555 self pvid untagged
       RTNETLINK answers: Invalid argument
      
      As long as the bridge driver does not fill notification info for the
      bridge device itself, an empty notification should not be considered as
      an error. This is explained in commit 59ccaaaa ("bridge: dont send
      notification when skb->len == 0 in rtnl_bridge_notify").
      
      Fix by removing the error and add a comment to avoid future bugs.
      
      Fixes: a8db57c1
      
       ("rtnetlink: Fix missing error code in rtnl_bridge_notify()")
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: default avatarNikolay Aleksandrov <nikolay@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ba14e0b4
    • Paolo Abeni's avatar
      udp: fix race between close() and udp_abort() · 2f734480
      Paolo Abeni authored
      [ Upstream commit a8b897c7
      
       ]
      
      Kaustubh reported and diagnosed a panic in udp_lib_lookup().
      The root cause is udp_abort() racing with close(). Both
      racing functions acquire the socket lock, but udp{v6}_destroy_sock()
      release it before performing destructive actions.
      
      We can't easily extend the socket lock scope to avoid the race,
      instead use the SOCK_DEAD flag to prevent udp_abort from doing
      any action when the critical race happens.
      
      Diagnosed-and-tested-by: default avatarKaustubh Pandey <kapandey@codeaurora.org>
      Fixes: 5d77dca8
      
       ("net: diag: support SOCK_DESTROY for UDP sockets")
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2f734480
    • Pavel Skripkin's avatar
      net: rds: fix memory leak in rds_recvmsg · 06b7cb01
      Pavel Skripkin authored
      [ Upstream commit 49bfcbfd ]
      
      Syzbot reported memory leak in rds. The problem
      was in unputted refcount in case of error.
      
      int rds_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
      		int msg_flags)
      {
      ...
      
      	if (!rds_next_incoming(rs, &inc)) {
      		...
      	}
      
      After this "if" inc refcount incremented and
      
      	if (rds_cmsg_recv(inc, msg, rs)) {
      		ret = -EFAULT;
      		goto out;
      	}
      ...
      out:
      	return ret;
      }
      
      in case of rds_cmsg_recv() fail the refcount won't be
      decremented. And it's easy to see from ftrace log, that
      rds_inc_addref() don't have rds_inc_put() pair in
      rds_recvmsg() after rds_cmsg_recv()
      
       1)               |  rds_recvmsg() {
       1)   3.721 us    |    rds_inc_addref();
       1)   3.853 us    |    rds_message_inc_copy_to_user();
       1) + 10.395 us   |    rds_cmsg_recv();
       1) + 34.260 us   |  }
      
      Fixes: bdbe6fbc
      
       ("RDS: recv.c")
      Reported-and-tested-by: default avatar <syzbot+5134cdf021c4ed5aaa5f@syzkaller.appspotmail.com>
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Reviewed-by: default avatarHåkon Bugge <haakon.bugge@oracle.com>
      Acked-by: default avatarSantosh Shilimkar <santosh.shilimkar@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      06b7cb01
    • Nanyong Sun's avatar
      net: ipv4: fix memory leak in netlbl_cipsov4_add_std · 53408581
      Nanyong Sun authored
      [ Upstream commit d612c3f3 ]
      
      Reported by syzkaller:
      BUG: memory leak
      unreferenced object 0xffff888105df7000 (size 64):
      comm "syz-executor842", pid 360, jiffies 4294824824 (age 22.546s)
      hex dump (first 32 bytes):
      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
      backtrace:
      [<00000000e67ed558>] kmalloc include/linux/slab.h:590 [inline]
      [<00000000e67ed558>] kzalloc include/linux/slab.h:720 [inline]
      [<00000000e67ed558>] netlbl_cipsov4_add_std net/netlabel/netlabel_cipso_v4.c:145 [inline]
      [<00000000e67ed558>] netlbl_cipsov4_add+0x390/0x2340 net/netlabel/netlabel_cipso_v4.c:416
      [<0000000006040154>] genl_family_rcv_msg_doit.isra.0+0x20e/0x320 net/netlink/genetlink.c:739
      [<00000000204d7a1c>] genl_family_rcv_msg net/netlink/genetlink.c:783 [inline]
      [<00000000204d7a1c>] genl_rcv_msg+0x2bf/0x4f0 net/netlink/genetlink.c:800
      [<00000000c0d6a995>] netlink_rcv_skb+0x134/0x3d0 net/netlink/af_netlink.c:2504
      [<00000000d78b9d2c>] genl_rcv+0x24/0x40 net/netlink/genetlink.c:811
      [<000000009733081b>] netlink_unicast_kernel net/netlink/af_netlink.c:1314 [inline]
      [<000000009733081b>] netlink_unicast+0x4a0/0x6a0 net/netlink/af_netlink.c:1340
      [<00000000d5fd43b8>] netlink_sendmsg+0x789/0xc70 net/netlink/af_netlink.c:1929
      [<000000000a2d1e40>] sock_sendmsg_nosec net/socket.c:654 [inline]
      [<000000000a2d1e40>] sock_sendmsg+0x139/0x170 net/socket.c:674
      [<00000000321d1969>] ____sys_sendmsg+0x658/0x7d0 net/socket.c:2350
      [<00000000964e16bc>] ___sys_sendmsg+0xf8/0x170 net/socket.c:2404
      [<000000001615e288>] __sys_sendmsg+0xd3/0x190 net/socket.c:2433
      [<000000004ee8b6a5>] do_syscall_64+0x37/0x90 arch/x86/entry/common.c:47
      [<00000000171c7cee>] entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      The memory of doi_def->map.std pointing is allocated in
      netlbl_cipsov4_add_std, but no place has freed it. It should be
      freed in cipso_v4_doi_free which frees the cipso DOI resource.
      
      Fixes: 96cb8e33
      
       ("[NetLabel]: CIPSOv4 and Unlabeled packet integration")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarNanyong Sun <sunnanyong@huawei.com>
      Acked-by: default avatarPaul Moore <paul@paul-moore.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      53408581
    • Sven Eckelmann's avatar
      batman-adv: Avoid WARN_ON timing related checks · e8e9d296
      Sven Eckelmann authored
      [ Upstream commit 9f460ae3
      
       ]
      
      The soft/batadv interface for a queued OGM can be changed during the time
      the OGM was queued for transmission and when the OGM is actually
      transmitted by the worker.
      
      But WARN_ON must be used to denote kernel bugs and not to print simple
      warnings. A warning can simply be printed using pr_warn.
      
      Reported-by: default avatarTetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
      Reported-by: default avatar <syzbot+c0b807de416427ff3dd1@syzkaller.appspotmail.com>
      Fixes: ef0a937f
      
       ("batman-adv: consider outgoing interface in OGM sending")
      Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
      Signed-off-by: default avatarSimon Wunderlich <sw@simonwunderlich.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e8e9d296
    • yangerkun's avatar
      mm/memory-failure: make sure wait for page writeback in memory_failure · 6d210d54
      yangerkun authored
      [ Upstream commit e8675d29 ]
      
      Our syzkaller trigger the "BUG_ON(!list_empty(&inode->i_wb_list))" in
      clear_inode:
      
        kernel BUG at fs/inode.c:519!
        Internal error: Oops - BUG: 0 [#1] SMP
        Modules linked in:
        Process syz-executor.0 (pid: 249, stack limit = 0x00000000a12409d7)
        CPU: 1 PID: 249 Comm: syz-executor.0 Not tainted 4.19.95
        Hardware name: linux,dummy-virt (DT)
        pstate: 80000005 (Nzcv daif -PAN -UAO)
        pc : clear_inode+0x280/0x2a8
        lr : clear_inode+0x280/0x2a8
        Call trace:
          clear_inode+0x280/0x2a8
          ext4_clear_inode+0x38/0xe8
          ext4_free_inode+0x130/0xc68
          ext4_evict_inode+0xb20/0xcb8
          evict+0x1a8/0x3c0
          iput+0x344/0x460
          do_unlinkat+0x260/0x410
          __arm64_sys_unlinkat+0x6c/0xc0
          el0_svc_common+0xdc/0x3b0
          el0_svc_handler+0xf8/0x160
          el0_svc+0x10/0x218
        Kernel panic - not syncing: Fatal exception
      
      A crash dump of this problem show that someone called __munlock_pagevec
      to clear page LRU without lock_page: do_mmap -> mmap_region -> do_munmap
      -> munlock_vma_pages_range -> __munlock_pagevec.
      
      As a result memory_failure will call identify_page_state without
      wait_on_page_writeback.  And after truncate_error_page clear the mapping
      of this page.  end_page_writeback won't call sb_clear_inode_writeback to
      clear inode->i_wb_list.  That will trigger BUG_ON in clear_inode!
      
      Fix it by checking PageWriteback too to help determine should we skip
      wait_on_page_writeback.
      
      Link: https://lkml.kernel.org/r/20210604084705.3729204-1-yangerkun@huawei.com
      Fixes: 0bc1f8b0
      
       ("hwpoison: fix the handling path of the victimized page frame that belong to non-LRU")
      Signed-off-by: default avataryangerkun <yangerkun@huawei.com>
      Acked-by: default avatarNaoya Horiguchi <naoya.horiguchi@nec.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Theodore Ts'o <tytso@mit.edu>
      Cc: Oscar Salvador <osalvador@suse.de>
      Cc: Yu Kuai <yukuai3@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6d210d54
    • Dan Carpenter's avatar
      afs: Fix an IS_ERR() vs NULL check · 6b907d1a
      Dan Carpenter authored
      [ Upstream commit a33d6266 ]
      
      The proc_symlink() function returns NULL on error, it doesn't return
      error pointers.
      
      Fixes: 5b86d4ff
      
       ("afs: Implement network namespacing")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: linux-afs@lists.infradead.org
      Link: https://lore.kernel.org/r/YLjMRKX40pTrJvgf@mwanda/
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6b907d1a
    • Yang Yingliang's avatar
      dmaengine: stedma40: add missing iounmap() on error in d40_probe() · 53f0b1ff
      Yang Yingliang authored
      [ Upstream commit fffdaba4 ]
      
      Add the missing iounmap() before return from d40_probe()
      in the error handling case.
      
      Fixes: 8d318a50
      
       ("DMAENGINE: Support for ST-Ericssons DMA40 block v3")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Link: https://lore.kernel.org/r/20210518141108.1324127-1-yangyingliang@huawei.com
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      53f0b1ff
    • Randy Dunlap's avatar
      dmaengine: QCOM_HIDMA_MGMT depends on HAS_IOMEM · c74f6097
      Randy Dunlap authored
      [ Upstream commit 0cfbb589 ]
      
      When CONFIG_HAS_IOMEM is not set/enabled, certain iomap() family
      functions [including ioremap(), devm_ioremap(), etc.] are not
      available.
      Drivers that use these functions should depend on HAS_IOMEM so that
      they do not cause build errors.
      
      Rectifies these build errors:
      s390-linux-ld: drivers/dma/qcom/hidma_mgmt.o: in function `hidma_mgmt_probe':
      hidma_mgmt.c:(.text+0x780): undefined reference to `devm_ioremap_resource'
      s390-linux-ld: drivers/dma/qcom/hidma_mgmt.o: in function `hidma_mgmt_init':
      hidma_mgmt.c:(.init.text+0x126): undefined reference to `of_address_to_resource'
      s390-linux-ld: hidma_mgmt.c:(.init.text+0x16e): undefined reference to `of_address_to_resource'
      
      Fixes: 67a2003e
      
       ("dmaengine: add Qualcomm Technologies HIDMA channel driver")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Cc: Sinan Kaya <okaya@codeaurora.org>
      Cc: Vinod Koul <vkoul@kernel.org>
      Cc: dmaengine@vger.kernel.org
      Link: https://lore.kernel.org/r/20210522021313.16405-3-rdunlap@infradead.org
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c74f6097
    • Randy Dunlap's avatar
      dmaengine: ALTERA_MSGDMA depends on HAS_IOMEM · df1f5fc7
      Randy Dunlap authored
      [ Upstream commit 253697b9 ]
      
      When CONFIG_HAS_IOMEM is not set/enabled, certain iomap() family
      functions [including ioremap(), devm_ioremap(), etc.] are not
      available.
      Drivers that use these functions should depend on HAS_IOMEM so that
      they do not cause build errors.
      
      Repairs this build error:
      s390-linux-ld: drivers/dma/altera-msgdma.o: in function `request_and_map':
      altera-msgdma.c:(.text+0x14b0): undefined reference to `devm_ioremap'
      
      Fixes: a85c6f1b
      
       ("dmaengine: Add driver for Altera / Intel mSGDMA IP core")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Cc: Stefan Roese <sr@denx.de>
      Cc: Vinod Koul <vkoul@kernel.org>
      Cc: dmaengine@vger.kernel.org
      Reviewed-by: default avatarStefan Roese <sr@denx.de>
      Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de
      Link: https://lore.kernel.org/r/20210522021313.16405-2-rdunlap@infradead.org
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      df1f5fc7