1. 30 Jun, 2020 40 commits
    • Tang Bin's avatar
      usb: host: ehci-exynos: Fix error check in exynos_ehci_probe() · 6119a89a
      Tang Bin authored
      commit 44ed240d upstream.
      
      If the function platform_get_irq() failed, the negative value
      returned will not be detected here. So fix error handling in
      exynos_ehci_probe(). And when get irq failed, the function
      platform_get_irq() logs an error message, so remove redundant
      message here.
      
      Fixes: 1bcc5aa8 ("USB: Add initial S5P EHCI driver")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarZhang Shengju <zhangshengju@cmss.chinamobile.com>
      Signed-off-by: default avatarTang Bin <tangbin@cmss.chinamobile.com>
      Link: https://lore.kernel.org/r/20200602114708.28620-1-tangbin@cmss.chinamobile.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6119a89a
    • Longfang Liu's avatar
      USB: ehci: reopen solution for Synopsys HC bug · 469adc4c
      Longfang Liu authored
      commit 1ddcb71a upstream.
      
      A Synopsys USB2.0 core used in Huawei Kunpeng920 SoC has a bug which
      might cause the host controller not issuing ping.
      
      Bug description:
      After indicating an Interrupt on Async Advance, the software uses the
      doorbell mechanism to delete the Next Link queue head of the last
      executed queue head. At this time, the host controller still references
      the removed queue head(the queue head is NULL). NULL reference causes
      the host controller to lose the USB device.
      
      Solution:
      After deleting the Next Link queue head, when has_synopsys_hc_bug set
      to 1,the software can write one of the valid queue head addresses to
      the ASYNCLISTADDR register to allow the host controller to get
      the valid queue head. in order to solve that problem, this patch set
      the flag for Huawei Kunpeng920
      
      There are detailed instructions and solutions in this patch:
      commit 2f7ac6c1 ("USB: ehci: add workaround for Synopsys HC bug")
      Signed-off-by: default avatarLongfang Liu <liulongfang@huawei.com>
      Cc: stable <stable@vger.kernel.org>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Link: https://lore.kernel.org/r/1591588019-44284-1-git-send-email-liulongfang@huawei.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      469adc4c
    • Tomasz Meresiński's avatar
      usb: add USB_QUIRK_DELAY_INIT for Logitech C922 · 4813288a
      Tomasz Meresiński authored
      commit 5d802192 upstream.
      
      The Logitech C922, just like other Logitech webcams,
      needs the USB_QUIRK_DELAY_INIT or it will randomly
      not respond after device connection
      Signed-off-by: default avatarTomasz Meresiński <tomasz@meresinski.eu>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200603203347.7792-1-tomasz@meresinski.euSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4813288a
    • Minas Harutyunyan's avatar
      usb: dwc2: Postponed gadget registration to the udc class driver · aedf21cf
      Minas Harutyunyan authored
      commit 207324a3 upstream.
      
      During dwc2 driver probe, after gadget registration to the udc class
      driver, if exist any builtin function driver it immediately bound to
      dwc2 and after init host side (dwc2_hcd_init()) stucked in host mode.
      Patch postpone gadget registration after host side initialization done.
      
      Fixes: 117777b2 ("usb: dwc2: Move gadget probe function into platform code")
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Tested-by: default avatarMarek Vasut <marex@denx.de>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarMinas Harutyunyan <hminas@synopsys.com>
      Link: https://lore.kernel.org/r/f21cb38fecc72a230b86155d94c7e60c9cb66f58.1591690938.git.hminas@synopsys.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      aedf21cf
    • Chuhong Yuan's avatar
      USB: ohci-sm501: Add missed iounmap() in remove · b680168b
      Chuhong Yuan authored
      commit 07c112fb upstream.
      
      This driver misses calling iounmap() in remove to undo the ioremap()
      called in probe.
      Add the missed call to fix it.
      
      Fixes: f54aab6e ("usb: ohci-sm501 driver")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarChuhong Yuan <hslester96@gmail.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Link: https://lore.kernel.org/r/20200610024844.3628408-1-hslester96@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b680168b
    • Taehee Yoo's avatar
      net: core: reduce recursion limit value · 6aa66b71
      Taehee Yoo authored
      [ Upstream commit fb7861d1 ]
      
      In the current code, ->ndo_start_xmit() can be executed recursively only
      10 times because of stack memory.
      But, in the case of the vxlan, 10 recursion limit value results in
      a stack overflow.
      In the current code, the nested interface is limited by 8 depth.
      There is no critical reason that the recursion limitation value should
      be 10.
      So, it would be good to be the same value with the limitation value of
      nesting interface depth.
      
      Test commands:
          ip link add vxlan10 type vxlan vni 10 dstport 4789 srcport 4789 4789
          ip link set vxlan10 up
          ip a a 192.168.10.1/24 dev vxlan10
          ip n a 192.168.10.2 dev vxlan10 lladdr fc:22:33:44:55:66 nud permanent
      
          for i in {9..0}
          do
              let A=$i+1
      	ip link add vxlan$i type vxlan vni $i dstport 4789 srcport 4789 4789
      	ip link set vxlan$i up
      	ip a a 192.168.$i.1/24 dev vxlan$i
      	ip n a 192.168.$i.2 dev vxlan$i lladdr fc:22:33:44:55:66 nud permanent
      	bridge fdb add fc:22:33:44:55:66 dev vxlan$A dst 192.168.$i.2 self
          done
          hping3 192.168.10.2 -2 -d 60000
      
      Splat looks like:
      [  103.814237][ T1127] =============================================================================
      [  103.871955][ T1127] BUG kmalloc-2k (Tainted: G    B            ): Padding overwritten. 0x00000000897a2e4f-0x000
      [  103.873187][ T1127] -----------------------------------------------------------------------------
      [  103.873187][ T1127]
      [  103.874252][ T1127] INFO: Slab 0x000000005cccc724 objects=5 used=5 fp=0x0000000000000000 flags=0x10000000001020
      [  103.881323][ T1127] CPU: 3 PID: 1127 Comm: hping3 Tainted: G    B             5.7.0+ #575
      [  103.882131][ T1127] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
      [  103.883006][ T1127] Call Trace:
      [  103.883324][ T1127]  dump_stack+0x96/0xdb
      [  103.883716][ T1127]  slab_err+0xad/0xd0
      [  103.884106][ T1127]  ? _raw_spin_unlock+0x1f/0x30
      [  103.884620][ T1127]  ? get_partial_node.isra.78+0x140/0x360
      [  103.885214][ T1127]  slab_pad_check.part.53+0xf7/0x160
      [  103.885769][ T1127]  ? pskb_expand_head+0x110/0xe10
      [  103.886316][ T1127]  check_slab+0x97/0xb0
      [  103.886763][ T1127]  alloc_debug_processing+0x84/0x1a0
      [  103.887308][ T1127]  ___slab_alloc+0x5a5/0x630
      [  103.887765][ T1127]  ? pskb_expand_head+0x110/0xe10
      [  103.888265][ T1127]  ? lock_downgrade+0x730/0x730
      [  103.888762][ T1127]  ? pskb_expand_head+0x110/0xe10
      [  103.889244][ T1127]  ? __slab_alloc+0x3e/0x80
      [  103.889675][ T1127]  __slab_alloc+0x3e/0x80
      [  103.890108][ T1127]  __kmalloc_node_track_caller+0xc7/0x420
      [ ... ]
      
      Fixes: 11a766ce ("net: Increase xmit RECURSION_LIMIT to 10.")
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6aa66b71
    • Tariq Toukan's avatar
      net: Do not clear the sock TX queue in sk_set_socket() · 67321215
      Tariq Toukan authored
      [ Upstream commit 41b14fb8 ]
      
      Clearing the sock TX queue in sk_set_socket() might cause unexpected
      out-of-order transmit when called from sock_orphan(), as outstanding
      packets can pick a different TX queue and bypass the ones already queued.
      
      This is undesired in general. More specifically, it breaks the in-order
      scheduling property guarantee for device-offloaded TLS sockets.
      
      Remove the call to sk_tx_queue_clear() in sk_set_socket(), and add it
      explicitly only where needed.
      
      Fixes: e022f0b4 ("net: Introduce sk_tx_queue_mapping")
      Signed-off-by: default avatarTariq Toukan <tariqt@mellanox.com>
      Reviewed-by: default avatarBoris Pismenny <borisp@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      67321215
    • guodeqing's avatar
      net: Fix the arp error in some cases · 6ac341ce
      guodeqing authored
      [ Upstream commit 5eea3a63 ]
      
      ie.,
      $ ifconfig eth0 6.6.6.6 netmask 255.255.255.0
      
      $ ip rule add from 6.6.6.6 table 6666
      
      $ ip route add 9.9.9.9 via 6.6.6.6
      
      $ ping -I 6.6.6.6 9.9.9.9
      PING 9.9.9.9 (9.9.9.9) from 6.6.6.6 : 56(84) bytes of data.
      
      3 packets transmitted, 0 received, 100% packet loss, time 2079ms
      
      $ arp
      Address     HWtype  HWaddress           Flags Mask            Iface
      6.6.6.6             (incomplete)                              eth0
      
      The arp request address is error, this is because fib_table_lookup in
      fib_check_nh lookup the destnation 9.9.9.9 nexthop, the scope of
      the fib result is RT_SCOPE_LINK,the correct scope is RT_SCOPE_HOST.
      Here I add a check of whether this is RT_TABLE_MAIN to solve this problem.
      
      Fixes: 3bfd8472 ("net: Use passed in table for nexthop lookups")
      Signed-off-by: default avatarguodeqing <geffrey.guo@huawei.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6ac341ce
    • Marcelo Ricardo Leitner's avatar
      sctp: Don't advertise IPv4 addresses if ipv6only is set on the socket · 5030f668
      Marcelo Ricardo Leitner authored
      [ Upstream commit 471e39df ]
      
      If a socket is set ipv6only, it will still send IPv4 addresses in the
      INIT and INIT_ACK packets. This potentially misleads the peer into using
      them, which then would cause association termination.
      
      The fix is to not add IPv4 addresses to ipv6only sockets.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Reported-by: default avatarCorey Minyard <cminyard@mvista.com>
      Signed-off-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Tested-by: default avatarCorey Minyard <cminyard@mvista.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5030f668
    • Eric Dumazet's avatar
      tcp: grow window for OOO packets only for SACK flows · 05cc8235
      Eric Dumazet authored
      [ Upstream commit 66205121 ]
      
      Back in 2013, we made a change that broke fast retransmit
      for non SACK flows.
      
      Indeed, for these flows, a sender needs to receive three duplicate
      ACK before starting fast retransmit. Sending ACK with different
      receive window do not count.
      
      Even if enabling SACK is strongly recommended these days,
      there still are some cases where it has to be disabled.
      
      Not increasing the window seems better than having to
      rely on RTO.
      
      After the fix, following packetdrill test gives :
      
      // Initialize connection
          0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
         +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
         +0 bind(3, ..., ...) = 0
         +0 listen(3, 1) = 0
      
         +0 < S 0:0(0) win 32792 <mss 1000,nop,wscale 7>
         +0 > S. 0:0(0) ack 1 <mss 1460,nop,wscale 8>
         +0 < . 1:1(0) ack 1 win 514
      
         +0 accept(3, ..., ...) = 4
      
         +0 < . 1:1001(1000) ack 1 win 514
      // Quick ack
         +0 > . 1:1(0) ack 1001 win 264
      
         +0 < . 2001:3001(1000) ack 1 win 514
      // DUPACK : Normally we should not change the window
         +0 > . 1:1(0) ack 1001 win 264
      
         +0 < . 3001:4001(1000) ack 1 win 514
      // DUPACK : Normally we should not change the window
         +0 > . 1:1(0) ack 1001 win 264
      
         +0 < . 4001:5001(1000) ack 1 win 514
      // DUPACK : Normally we should not change the window
          +0 > . 1:1(0) ack 1001 win 264
      
         +0 < . 1001:2001(1000) ack 1 win 514
      // Hole is repaired.
         +0 > . 1:1(0) ack 5001 win 272
      
      Fixes: 4e4f1fc2 ("tcp: properly increase rcv_ssthresh for ofo packets")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarVenkat Venkatsubra <venkat.x.venkatsubra@oracle.com>
      Acked-by: default avatarNeal Cardwell <ncardwell@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      05cc8235
    • Taehee Yoo's avatar
      ip6_gre: fix use-after-free in ip6gre_tunnel_lookup() · 743475d9
      Taehee Yoo authored
      [ Upstream commit dafabb65 ]
      
      In the datapath, the ip6gre_tunnel_lookup() is used and it internally uses
      fallback tunnel device pointer, which is fb_tunnel_dev.
      This pointer variable should be set to NULL when a fb interface is deleted.
      But there is no routine to set fb_tunnel_dev pointer to NULL.
      So, this pointer will be still used after interface is deleted and
      it eventually results in the use-after-free problem.
      
      Test commands:
          ip netns add A
          ip netns add B
          ip link add eth0 type veth peer name eth1
          ip link set eth0 netns A
          ip link set eth1 netns B
      
          ip netns exec A ip link set lo up
          ip netns exec A ip link set eth0 up
          ip netns exec A ip link add ip6gre1 type ip6gre local fc:0::1 \
      	    remote fc:0::2
          ip netns exec A ip -6 a a fc:100::1/64 dev ip6gre1
          ip netns exec A ip link set ip6gre1 up
          ip netns exec A ip -6 a a fc:0::1/64 dev eth0
          ip netns exec A ip link set ip6gre0 up
      
          ip netns exec B ip link set lo up
          ip netns exec B ip link set eth1 up
          ip netns exec B ip link add ip6gre1 type ip6gre local fc:0::2 \
      	    remote fc:0::1
          ip netns exec B ip -6 a a fc:100::2/64 dev ip6gre1
          ip netns exec B ip link set ip6gre1 up
          ip netns exec B ip -6 a a fc:0::2/64 dev eth1
          ip netns exec B ip link set ip6gre0 up
          ip netns exec A ping fc:100::2 -s 60000 &
          ip netns del B
      
      Splat looks like:
      [   73.087285][    C1] BUG: KASAN: use-after-free in ip6gre_tunnel_lookup+0x1064/0x13f0 [ip6_gre]
      [   73.088361][    C1] Read of size 4 at addr ffff888040559218 by task ping/1429
      [   73.089317][    C1]
      [   73.089638][    C1] CPU: 1 PID: 1429 Comm: ping Not tainted 5.7.0+ #602
      [   73.090531][    C1] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
      [   73.091725][    C1] Call Trace:
      [   73.092160][    C1]  <IRQ>
      [   73.092556][    C1]  dump_stack+0x96/0xdb
      [   73.093122][    C1]  print_address_description.constprop.6+0x2cc/0x450
      [   73.094016][    C1]  ? ip6gre_tunnel_lookup+0x1064/0x13f0 [ip6_gre]
      [   73.094894][    C1]  ? ip6gre_tunnel_lookup+0x1064/0x13f0 [ip6_gre]
      [   73.095767][    C1]  ? ip6gre_tunnel_lookup+0x1064/0x13f0 [ip6_gre]
      [   73.096619][    C1]  kasan_report+0x154/0x190
      [   73.097209][    C1]  ? ip6gre_tunnel_lookup+0x1064/0x13f0 [ip6_gre]
      [   73.097989][    C1]  ip6gre_tunnel_lookup+0x1064/0x13f0 [ip6_gre]
      [   73.098750][    C1]  ? gre_del_protocol+0x60/0x60 [gre]
      [   73.099500][    C1]  gre_rcv+0x1c5/0x1450 [ip6_gre]
      [   73.100199][    C1]  ? ip6gre_header+0xf00/0xf00 [ip6_gre]
      [   73.100985][    C1]  ? rcu_read_lock_sched_held+0xc0/0xc0
      [   73.101830][    C1]  ? ip6_input_finish+0x5/0xf0
      [   73.102483][    C1]  ip6_protocol_deliver_rcu+0xcbb/0x1510
      [   73.103296][    C1]  ip6_input_finish+0x5b/0xf0
      [   73.103920][    C1]  ip6_input+0xcd/0x2c0
      [   73.104473][    C1]  ? ip6_input_finish+0xf0/0xf0
      [   73.105115][    C1]  ? rcu_read_lock_held+0x90/0xa0
      [   73.105783][    C1]  ? rcu_read_lock_sched_held+0xc0/0xc0
      [   73.106548][    C1]  ipv6_rcv+0x1f1/0x300
      [ ... ]
      Suggested-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
      Fixes: c12b395a ("gre: Support GRE over IPv6")
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      743475d9
    • Neal Cardwell's avatar
      tcp_cubic: fix spurious HYSTART_DELAY exit upon drop in min RTT · 98d3884b
      Neal Cardwell authored
      [ Upstream commit b344579c ]
      
      Mirja Kuehlewind reported a bug in Linux TCP CUBIC Hystart, where
      Hystart HYSTART_DELAY mechanism can exit Slow Start spuriously on an
      ACK when the minimum rtt of a connection goes down. From inspection it
      is clear from the existing code that this could happen in an example
      like the following:
      
      o The first 8 RTT samples in a round trip are 150ms, resulting in a
        curr_rtt of 150ms and a delay_min of 150ms.
      
      o The 9th RTT sample is 100ms. The curr_rtt does not change after the
        first 8 samples, so curr_rtt remains 150ms. But delay_min can be
        lowered at any time, so delay_min falls to 100ms. The code executes
        the HYSTART_DELAY comparison between curr_rtt of 150ms and delay_min
        of 100ms, and the curr_rtt is declared far enough above delay_min to
        force a (spurious) exit of Slow start.
      
      The fix here is simple: allow every RTT sample in a round trip to
      lower the curr_rtt.
      
      Fixes: ae27e98a ("[TCP] CUBIC v2.3")
      Reported-by: default avatarMirja Kuehlewind <mirja.kuehlewind@ericsson.com>
      Signed-off-by: default avatarNeal Cardwell <ncardwell@google.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Acked-by: default avatarSoheil Hassas Yeganeh <soheil@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      98d3884b
    • Taehee Yoo's avatar
      ip_tunnel: fix use-after-free in ip_tunnel_lookup() · ae1c468b
      Taehee Yoo authored
      [ Upstream commit ba61539c ]
      
      In the datapath, the ip_tunnel_lookup() is used and it internally uses
      fallback tunnel device pointer, which is fb_tunnel_dev.
      This pointer variable should be set to NULL when a fb interface is deleted.
      But there is no routine to set fb_tunnel_dev pointer to NULL.
      So, this pointer will be still used after interface is deleted and
      it eventually results in the use-after-free problem.
      
      Test commands:
          ip netns add A
          ip netns add B
          ip link add eth0 type veth peer name eth1
          ip link set eth0 netns A
          ip link set eth1 netns B
      
          ip netns exec A ip link set lo up
          ip netns exec A ip link set eth0 up
          ip netns exec A ip link add gre1 type gre local 10.0.0.1 \
      	    remote 10.0.0.2
          ip netns exec A ip link set gre1 up
          ip netns exec A ip a a 10.0.100.1/24 dev gre1
          ip netns exec A ip a a 10.0.0.1/24 dev eth0
      
          ip netns exec B ip link set lo up
          ip netns exec B ip link set eth1 up
          ip netns exec B ip link add gre1 type gre local 10.0.0.2 \
      	    remote 10.0.0.1
          ip netns exec B ip link set gre1 up
          ip netns exec B ip a a 10.0.100.2/24 dev gre1
          ip netns exec B ip a a 10.0.0.2/24 dev eth1
          ip netns exec A hping3 10.0.100.2 -2 --flood -d 60000 &
          ip netns del B
      
      Splat looks like:
      [   77.793450][    C3] ==================================================================
      [   77.794702][    C3] BUG: KASAN: use-after-free in ip_tunnel_lookup+0xcc4/0xf30
      [   77.795573][    C3] Read of size 4 at addr ffff888060bd9c84 by task hping3/2905
      [   77.796398][    C3]
      [   77.796664][    C3] CPU: 3 PID: 2905 Comm: hping3 Not tainted 5.8.0-rc1+ #616
      [   77.797474][    C3] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
      [   77.798453][    C3] Call Trace:
      [   77.798815][    C3]  <IRQ>
      [   77.799142][    C3]  dump_stack+0x9d/0xdb
      [   77.799605][    C3]  print_address_description.constprop.7+0x2cc/0x450
      [   77.800365][    C3]  ? ip_tunnel_lookup+0xcc4/0xf30
      [   77.800908][    C3]  ? ip_tunnel_lookup+0xcc4/0xf30
      [   77.801517][    C3]  ? ip_tunnel_lookup+0xcc4/0xf30
      [   77.802145][    C3]  kasan_report+0x154/0x190
      [   77.802821][    C3]  ? ip_tunnel_lookup+0xcc4/0xf30
      [   77.803503][    C3]  ip_tunnel_lookup+0xcc4/0xf30
      [   77.804165][    C3]  __ipgre_rcv+0x1ab/0xaa0 [ip_gre]
      [   77.804862][    C3]  ? rcu_read_lock_sched_held+0xc0/0xc0
      [   77.805621][    C3]  gre_rcv+0x304/0x1910 [ip_gre]
      [   77.806293][    C3]  ? lock_acquire+0x1a9/0x870
      [   77.806925][    C3]  ? gre_rcv+0xfe/0x354 [gre]
      [   77.807559][    C3]  ? erspan_xmit+0x2e60/0x2e60 [ip_gre]
      [   77.808305][    C3]  ? rcu_read_lock_sched_held+0xc0/0xc0
      [   77.809032][    C3]  ? rcu_read_lock_held+0x90/0xa0
      [   77.809713][    C3]  gre_rcv+0x1b8/0x354 [gre]
      [ ... ]
      Suggested-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
      Fixes: c5441932 ("GRE: Refactor GRE tunneling code.")
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ae1c468b
    • David Christensen's avatar
      tg3: driver sleeps indefinitely when EEH errors exceed eeh_max_freezes · b6e5086c
      David Christensen authored
      [ Upstream commit 3a2656a2 ]
      
      The driver function tg3_io_error_detected() calls napi_disable twice,
      without an intervening napi_enable, when the number of EEH errors exceeds
      eeh_max_freezes, resulting in an indefinite sleep while holding rtnl_lock.
      
      Add check for pcierr_recovery which skips code already executed for the
      "Frozen" state.
      Signed-off-by: default avatarDavid Christensen <drc@linux.vnet.ibm.com>
      Reviewed-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b6e5086c
    • David Howells's avatar
      rxrpc: Fix notification call on completion of discarded calls · 5e43d1cb
      David Howells authored
      [ Upstream commit 0041cd5a ]
      
      When preallocated service calls are being discarded, they're passed to
      ->discard_new_call() to have the caller clean up any attached higher-layer
      preallocated pieces before being marked completed.  However, the act of
      marking them completed now invokes the call's notification function - which
      causes a problem because that function might assume that the previously
      freed pieces of memory are still there.
      
      Fix this by setting a dummy notification function on the socket after
      calling ->discard_new_call().
      
      This results in the following kasan message when the kafs module is
      removed.
      
      ==================================================================
      BUG: KASAN: use-after-free in afs_wake_up_async_call+0x6aa/0x770 fs/afs/rxrpc.c:707
      Write of size 1 at addr ffff8880946c39e4 by task kworker/u4:1/21
      
      CPU: 0 PID: 21 Comm: kworker/u4:1 Not tainted 5.8.0-rc1-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Workqueue: netns cleanup_net
      Call Trace:
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0x18f/0x20d lib/dump_stack.c:118
       print_address_description.constprop.0.cold+0xd3/0x413 mm/kasan/report.c:383
       __kasan_report mm/kasan/report.c:513 [inline]
       kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530
       afs_wake_up_async_call+0x6aa/0x770 fs/afs/rxrpc.c:707
       rxrpc_notify_socket+0x1db/0x5d0 net/rxrpc/recvmsg.c:40
       __rxrpc_set_call_completion.part.0+0x172/0x410 net/rxrpc/recvmsg.c:76
       __rxrpc_call_completed net/rxrpc/recvmsg.c:112 [inline]
       rxrpc_call_completed+0xca/0xf0 net/rxrpc/recvmsg.c:111
       rxrpc_discard_prealloc+0x781/0xab0 net/rxrpc/call_accept.c:233
       rxrpc_listen+0x147/0x360 net/rxrpc/af_rxrpc.c:245
       afs_close_socket+0x95/0x320 fs/afs/rxrpc.c:110
       afs_net_exit+0x1bc/0x310 fs/afs/main.c:155
       ops_exit_list.isra.0+0xa8/0x150 net/core/net_namespace.c:186
       cleanup_net+0x511/0xa50 net/core/net_namespace.c:603
       process_one_work+0x965/0x1690 kernel/workqueue.c:2269
       worker_thread+0x96/0xe10 kernel/workqueue.c:2415
       kthread+0x3b5/0x4a0 kernel/kthread.c:291
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293
      
      Allocated by task 6820:
       save_stack+0x1b/0x40 mm/kasan/common.c:48
       set_track mm/kasan/common.c:56 [inline]
       __kasan_kmalloc mm/kasan/common.c:494 [inline]
       __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:467
       kmem_cache_alloc_trace+0x153/0x7d0 mm/slab.c:3551
       kmalloc include/linux/slab.h:555 [inline]
       kzalloc include/linux/slab.h:669 [inline]
       afs_alloc_call+0x55/0x630 fs/afs/rxrpc.c:141
       afs_charge_preallocation+0xe9/0x2d0 fs/afs/rxrpc.c:757
       afs_open_socket+0x292/0x360 fs/afs/rxrpc.c:92
       afs_net_init+0xa6c/0xe30 fs/afs/main.c:125
       ops_init+0xaf/0x420 net/core/net_namespace.c:151
       setup_net+0x2de/0x860 net/core/net_namespace.c:341
       copy_net_ns+0x293/0x590 net/core/net_namespace.c:482
       create_new_namespaces+0x3fb/0xb30 kernel/nsproxy.c:110
       unshare_nsproxy_namespaces+0xbd/0x1f0 kernel/nsproxy.c:231
       ksys_unshare+0x43d/0x8e0 kernel/fork.c:2983
       __do_sys_unshare kernel/fork.c:3051 [inline]
       __se_sys_unshare kernel/fork.c:3049 [inline]
       __x64_sys_unshare+0x2d/0x40 kernel/fork.c:3049
       do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:359
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Freed by task 21:
       save_stack+0x1b/0x40 mm/kasan/common.c:48
       set_track mm/kasan/common.c:56 [inline]
       kasan_set_free_info mm/kasan/common.c:316 [inline]
       __kasan_slab_free+0xf7/0x140 mm/kasan/common.c:455
       __cache_free mm/slab.c:3426 [inline]
       kfree+0x109/0x2b0 mm/slab.c:3757
       afs_put_call+0x585/0xa40 fs/afs/rxrpc.c:190
       rxrpc_discard_prealloc+0x764/0xab0 net/rxrpc/call_accept.c:230
       rxrpc_listen+0x147/0x360 net/rxrpc/af_rxrpc.c:245
       afs_close_socket+0x95/0x320 fs/afs/rxrpc.c:110
       afs_net_exit+0x1bc/0x310 fs/afs/main.c:155
       ops_exit_list.isra.0+0xa8/0x150 net/core/net_namespace.c:186
       cleanup_net+0x511/0xa50 net/core/net_namespace.c:603
       process_one_work+0x965/0x1690 kernel/workqueue.c:2269
       worker_thread+0x96/0xe10 kernel/workqueue.c:2415
       kthread+0x3b5/0x4a0 kernel/kthread.c:291
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293
      
      The buggy address belongs to the object at ffff8880946c3800
       which belongs to the cache kmalloc-1k of size 1024
      The buggy address is located 484 bytes inside of
       1024-byte region [ffff8880946c3800, ffff8880946c3c00)
      The buggy address belongs to the page:
      page:ffffea000251b0c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0
      flags: 0xfffe0000000200(slab)
      raw: 00fffe0000000200 ffffea0002546508 ffffea00024fa248 ffff8880aa000c40
      raw: 0000000000000000 ffff8880946c3000 0000000100000002 0000000000000000
      page dumped because: kasan: bad access detected
      
      Memory state around the buggy address:
       ffff8880946c3880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
       ffff8880946c3900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      >ffff8880946c3980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                             ^
       ffff8880946c3a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
       ffff8880946c3a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      ==================================================================
      
      Reported-by: syzbot+d3eccef36ddbd02713e9@syzkaller.appspotmail.com
      Fixes: 5ac0d622 ("rxrpc: Fix missing notification")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5e43d1cb
    • Aditya Pakki's avatar
      rocker: fix incorrect error handling in dma_rings_init · 31dc2044
      Aditya Pakki authored
      [ Upstream commit 58d0c864 ]
      
      In rocker_dma_rings_init, the goto blocks in case of errors
      caused by the functions rocker_dma_cmd_ring_waits_alloc() and
      rocker_dma_ring_create() are incorrect. The patch fixes the
      order consistent with cleanup in rocker_dma_rings_fini().
      Signed-off-by: default avatarAditya Pakki <pakki001@umn.edu>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      31dc2044
    • Jeremy Kerr's avatar
      net: usb: ax88179_178a: fix packet alignment padding · 6c8b6312
      Jeremy Kerr authored
      [ Upstream commit e869e7a1 ]
      
      Using a AX88179 device (0b95:1790), I see two bytes of appended data on
      every RX packet. For example, this 48-byte ping, using 0xff as a
      payload byte:
      
        04:20:22.528472 IP 192.168.1.1 > 192.168.1.2: ICMP echo request, id 2447, seq 1, length 64
      	0x0000:  000a cd35 ea50 000a cd35 ea4f 0800 4500
      	0x0010:  0054 c116 4000 4001 f63e c0a8 0101 c0a8
      	0x0020:  0102 0800 b633 098f 0001 87ea cd5e 0000
      	0x0030:  0000 dcf2 0600 0000 0000 ffff ffff ffff
      	0x0040:  ffff ffff ffff ffff ffff ffff ffff ffff
      	0x0050:  ffff ffff ffff ffff ffff ffff ffff ffff
      	0x0060:  ffff 961f
      
      Those last two bytes - 96 1f - aren't part of the original packet.
      
      In the ax88179 RX path, the usbnet rx_fixup function trims a 2-byte
      'alignment pseudo header' from the start of the packet, and sets the
      length from a per-packet field populated by hardware. It looks like that
      length field *includes* the 2-byte header; the current driver assumes
      that it's excluded.
      
      This change trims the 2-byte alignment header after we've set the packet
      length, so the resulting packet length is correct. While we're moving
      the comment around, this also fixes the spelling of 'pseudo'.
      Signed-off-by: default avatarJeremy Kerr <jk@ozlabs.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6c8b6312
    • Yang Yingliang's avatar
      net: fix memleak in register_netdevice() · 40b56938
      Yang Yingliang authored
      [ Upstream commit 814152a8 ]
      
      I got a memleak report when doing some fuzz test:
      
      unreferenced object 0xffff888112584000 (size 13599):
        comm "ip", pid 3048, jiffies 4294911734 (age 343.491s)
        hex dump (first 32 bytes):
          74 61 70 30 00 00 00 00 00 00 00 00 00 00 00 00  tap0............
          00 ee d9 19 81 88 ff ff 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<000000002f60ba65>] __kmalloc_node+0x309/0x3a0
          [<0000000075b211ec>] kvmalloc_node+0x7f/0xc0
          [<00000000d3a97396>] alloc_netdev_mqs+0x76/0xfc0
          [<00000000609c3655>] __tun_chr_ioctl+0x1456/0x3d70
          [<000000001127ca24>] ksys_ioctl+0xe5/0x130
          [<00000000b7d5e66a>] __x64_sys_ioctl+0x6f/0xb0
          [<00000000e1023498>] do_syscall_64+0x56/0xa0
          [<000000009ec0eb12>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
      unreferenced object 0xffff888111845cc0 (size 8):
        comm "ip", pid 3048, jiffies 4294911734 (age 343.491s)
        hex dump (first 8 bytes):
          74 61 70 30 00 88 ff ff                          tap0....
        backtrace:
          [<000000004c159777>] kstrdup+0x35/0x70
          [<00000000d8b496ad>] kstrdup_const+0x3d/0x50
          [<00000000494e884a>] kvasprintf_const+0xf1/0x180
          [<0000000097880a2b>] kobject_set_name_vargs+0x56/0x140
          [<000000008fbdfc7b>] dev_set_name+0xab/0xe0
          [<000000005b99e3b4>] netdev_register_kobject+0xc0/0x390
          [<00000000602704fe>] register_netdevice+0xb61/0x1250
          [<000000002b7ca244>] __tun_chr_ioctl+0x1cd1/0x3d70
          [<000000001127ca24>] ksys_ioctl+0xe5/0x130
          [<00000000b7d5e66a>] __x64_sys_ioctl+0x6f/0xb0
          [<00000000e1023498>] do_syscall_64+0x56/0xa0
          [<000000009ec0eb12>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
      unreferenced object 0xffff88811886d800 (size 512):
        comm "ip", pid 3048, jiffies 4294911734 (age 343.491s)
        hex dump (first 32 bytes):
          00 00 00 00 ad 4e ad de ff ff ff ff 00 00 00 00  .....N..........
          ff ff ff ff ff ff ff ff c0 66 3d a3 ff ff ff ff  .........f=.....
        backtrace:
          [<0000000050315800>] device_add+0x61e/0x1950
          [<0000000021008dfb>] netdev_register_kobject+0x17e/0x390
          [<00000000602704fe>] register_netdevice+0xb61/0x1250
          [<000000002b7ca244>] __tun_chr_ioctl+0x1cd1/0x3d70
          [<000000001127ca24>] ksys_ioctl+0xe5/0x130
          [<00000000b7d5e66a>] __x64_sys_ioctl+0x6f/0xb0
          [<00000000e1023498>] do_syscall_64+0x56/0xa0
          [<000000009ec0eb12>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      If call_netdevice_notifiers() failed, then rollback_registered()
      calls netdev_unregister_kobject() which holds the kobject. The
      reference cannot be put because the netdev won't be add to todo
      list, so it will leads a memleak, we need put the reference to
      avoid memleak.
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      40b56938
    • Wang Hai's avatar
      mld: fix memory leak in ipv6_mc_destroy_dev() · d2c7abe7
      Wang Hai authored
      [ Upstream commit ea2fce88 ]
      
      Commit a84d0164 ("mld: fix memory leak in mld_del_delrec()") fixed
      the memory leak of MLD, but missing the ipv6_mc_destroy_dev() path, in
      which mca_sources are leaked after ma_put().
      
      Using ip6_mc_clear_src() to take care of the missing free.
      
      BUG: memory leak
      unreferenced object 0xffff8881113d3180 (size 64):
        comm "syz-executor071", pid 389, jiffies 4294887985 (age 17.943s)
        hex dump (first 32 bytes):
          00 00 00 00 00 00 00 00 ff 02 00 00 00 00 00 00  ................
          00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<000000002cbc483c>] kmalloc include/linux/slab.h:555 [inline]
          [<000000002cbc483c>] kzalloc include/linux/slab.h:669 [inline]
          [<000000002cbc483c>] ip6_mc_add1_src net/ipv6/mcast.c:2237 [inline]
          [<000000002cbc483c>] ip6_mc_add_src+0x7f5/0xbb0 net/ipv6/mcast.c:2357
          [<0000000058b8b1ff>] ip6_mc_source+0xe0c/0x1530 net/ipv6/mcast.c:449
          [<000000000bfc4fb5>] do_ipv6_setsockopt.isra.12+0x1b2c/0x3b30 net/ipv6/ipv6_sockglue.c:754
          [<00000000e4e7a722>] ipv6_setsockopt+0xda/0x150 net/ipv6/ipv6_sockglue.c:950
          [<0000000029260d9a>] rawv6_setsockopt+0x45/0x100 net/ipv6/raw.c:1081
          [<000000005c1b46f9>] __sys_setsockopt+0x131/0x210 net/socket.c:2132
          [<000000008491f7db>] __do_sys_setsockopt net/socket.c:2148 [inline]
          [<000000008491f7db>] __se_sys_setsockopt net/socket.c:2145 [inline]
          [<000000008491f7db>] __x64_sys_setsockopt+0xba/0x150 net/socket.c:2145
          [<00000000c7bc11c5>] do_syscall_64+0xa1/0x530 arch/x86/entry/common.c:295
          [<000000005fb7a3f3>] entry_SYSCALL_64_after_hwframe+0x49/0xb3
      
      Fixes: 1666d49e ("mld: do not remove mld souce list info when set link down")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
      Acked-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d2c7abe7
    • Al Viro's avatar
      fix a braino in "sparc32: fix register window handling in genregs32_[gs]et()" · 307fa7af
      Al Viro authored
      [ Upstream commit 9d964e1b ]
      
      lost npc in PTRACE_SETREGSET, breaking PTRACE_SETREGS as well
      
      Fixes: cf51e129 "sparc32: fix register window handling in genregs32_[gs]et()"
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      307fa7af
    • Valentin Longchamp's avatar
      net: sched: export __netdev_watchdog_up() · 02630590
      Valentin Longchamp authored
      [ Upstream commit 1a3db27a ]
      
      Since the quiesce/activate rework, __netdev_watchdog_up() is directly
      called in the ucc_geth driver.
      
      Unfortunately, this function is not available for modules and thus
      ucc_geth cannot be built as a module anymore. Fix it by exporting
      __netdev_watchdog_up().
      
      Since the commit introducing the regression was backported to stable
      branches, this one should ideally be as well.
      
      Fixes: 79dde73c ("net/ethernet/freescale: rework quiesce/activate for ucc_geth")
      Signed-off-by: default avatarValentin Longchamp <valentin@longchamp.me>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      02630590
    • Ridge Kennedy's avatar
      l2tp: Allow duplicate session creation with UDP · cb6f92ed
      Ridge Kennedy authored
      commit 0d0d9a38 upstream.
      
      In the past it was possible to create multiple L2TPv3 sessions with the
      same session id as long as the sessions belonged to different tunnels.
      The resulting sessions had issues when used with IP encapsulated tunnels,
      but worked fine with UDP encapsulated ones. Some applications began to
      rely on this behaviour to avoid having to negotiate unique session ids.
      
      Some time ago a change was made to require session ids to be unique across
      all tunnels, breaking the applications making use of this "feature".
      
      This change relaxes the duplicate session id check to allow duplicates
      if both of the colliding sessions belong to UDP encapsulated tunnels.
      
      Fixes: dbdbc73b ("l2tp: fix duplicate session creation")
      Signed-off-by: default avatarRidge Kennedy <ridge.kennedy@alliedtelesis.co.nz>
      Acked-by: default avatarJames Chapman <jchapman@katalix.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cb6f92ed
    • Martin Wilck's avatar
      scsi: scsi_devinfo: handle non-terminated strings · ec0bdc28
      Martin Wilck authored
      commit ba69ead9 upstream.
      
      devinfo->vendor and devinfo->model aren't necessarily
      zero-terminated.
      
      Fixes: b8018b97 "scsi_devinfo: fixup string compare"
      Signed-off-by: default avatarMartin Wilck <mwilck@suse.com>
      Reviewed-by: default avatarBart Van Assche <bart.vanassche@wdc.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ec0bdc28
    • Miquel Raynal's avatar
      mtd: rawnand: tmio: Fix the probe error path · b17fd5fb
      Miquel Raynal authored
      [ Upstream commit 75e9a330 ]
      
      nand_release() is supposed be called after MTD device registration.
      Here, only nand_scan() happened, so use nand_cleanup() instead.
      
      There is no real Fixes tag applying here as the use of nand_release()
      in this driver predates by far the introduction of nand_cleanup() in
      commit d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      which makes this change possible. However, pointing this commit as the
      culprit for backporting purposes makes sense even if this commit is not
      introducing any bug.
      
      Fixes: d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-57-miquel.raynal@bootlin.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      b17fd5fb
    • Miquel Raynal's avatar
      mtd: rawnand: mtk: Fix the probe error path · fb8233bc
      Miquel Raynal authored
      [ Upstream commit 8a82bbca ]
      
      nand_release() is supposed be called after MTD device registration.
      Here, only nand_scan() happened, so use nand_cleanup() instead.
      
      There is no real Fixes tag applying here as the use of nand_release()
      in this driver predates the introduction of nand_cleanup() in
      commit d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      which makes this change possible. However, pointing this commit as the
      culprit for backporting purposes makes sense even if this commit is not
      introducing any bug.
      
      Fixes: d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-28-miquel.raynal@bootlin.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      fb8233bc
    • Miquel Raynal's avatar
      mtd: rawnand: plat_nand: Fix the probe error path · f8183c76
      Miquel Raynal authored
      [ Upstream commit 5284024b ]
      
      nand_release() is supposed be called after MTD device registration.
      Here, only nand_scan() happened, so use nand_cleanup() instead.
      
      There is no real Fixes tag applying here as the use of nand_release()
      in this driver predates by far the introduction of nand_cleanup() in
      commit d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      which makes this change possible, hence pointing it as the commit to
      fix for backporting purposes, even if this commit is not introducing
      any bug.
      
      Fixes: d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-43-miquel.raynal@bootlin.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      f8183c76
    • Miquel Raynal's avatar
      mtd: rawnand: socrates: Fix the probe error path · 4f9c0479
      Miquel Raynal authored
      [ Upstream commit 9c6c2e5c ]
      
      nand_release() is supposed be called after MTD device registration.
      Here, only nand_scan() happened, so use nand_cleanup() instead.
      
      There is no real Fixes tag applying here as the use of nand_release()
      in this driver predates by far the introduction of nand_cleanup() in
      commit d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      which makes this change possible. However, pointing this commit as the
      culprit for backporting purposes makes sense even if this commit is not
      introducing any bug.
      
      Fixes: d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-51-miquel.raynal@bootlin.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      4f9c0479
    • Miquel Raynal's avatar
      mtd: rawnand: orion: Fix the probe error path · a2db51da
      Miquel Raynal authored
      [ Upstream commit be238fbf ]
      
      nand_release() is supposed be called after MTD device registration.
      Here, only nand_scan() happened, so use nand_cleanup() instead.
      
      There is no real Fixes tag applying here as the use of nand_release()
      in this driver predates by far the introduction of nand_cleanup() in
      commit d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      which makes this change possible. However, pointing this commit as the
      culprit for backporting purposes makes sense even if this commit is not
      introducing any bug.
      
      Fixes: d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-34-miquel.raynal@bootlin.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      a2db51da
    • Miquel Raynal's avatar
      mtd: rawnand: xway: Fix the probe error path · 9fc4e021
      Miquel Raynal authored
      [ Upstream commit 34531be5 ]
      
      nand_release() is supposed be called after MTD device registration.
      Here, only nand_scan() happened, so use nand_cleanup() instead.
      
      There is no real Fixes tag applying here as the use of nand_release()
      in this driver predates the introduction of nand_cleanup() in
      commit d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      which makes this change possible. However, pointing this commit as the
      culprit for backporting purposes makes sense even if this commit is not
      introducing any bug.
      
      Fixes: d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-61-miquel.raynal@bootlin.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      9fc4e021
    • Miquel Raynal's avatar
      mtd: rawnand: sharpsl: Fix the probe error path · 32125ccc
      Miquel Raynal authored
      [ Upstream commit 0f44b327 ]
      
      nand_release() is supposed be called after MTD device registration.
      Here, only nand_scan() happened, so use nand_cleanup() instead.
      
      There is no Fixes tag applying here as the use of nand_release()
      in this driver predates by far the introduction of nand_cleanup() in
      commit d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      which makes this change possible. However, pointing this commit as the
      culprit for backporting purposes makes sense.
      
      Fixes: d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-49-miquel.raynal@bootlin.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      32125ccc
    • Miquel Raynal's avatar
      mtd: rawnand: diskonchip: Fix the probe error path · ac133710
      Miquel Raynal authored
      [ Upstream commit c5be12e4 ]
      
      Not sure nand_cleanup() is the right function to call here but in any
      case it is not nand_release(). Indeed, even a comment says that
      calling nand_release() is a bit of a hack as there is no MTD device to
      unregister. So switch to nand_cleanup() for now and drop this
      comment.
      
      There is no Fixes tag applying here as the use of nand_release()
      in this driver predates by far the introduction of nand_cleanup() in
      commit d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      which makes this change possible. However, pointing this commit as the
      culprit for backporting purposes makes sense even if it did not intruce
      any bug.
      
      Fixes: d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-13-miquel.raynal@bootlin.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      ac133710
    • Boris Brezillon's avatar
      mtd: rawnand: Pass a nand_chip object to nand_release() · 66246910
      Boris Brezillon authored
      [ Upstream commit 59ac276f ]
      
      Let's make the raw NAND API consistent by patching all helpers to
      take a nand_chip object instead of an mtd_info one.
      
      Now is nand_release()'s turn.
      Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      66246910
    • Mauro Carvalho Chehab's avatar
      media: dvb_frontend: fix return error code · fd1a885b
      Mauro Carvalho Chehab authored
      commit 330dada5 upstream
      
      The correct error code when a function is not defined is
      -ENOTSUPP. It was typoed wrong as -EOPNOTSUPP, with,
      unfortunately, exists, but it is not used by the DVB core.
      
      Thanks-to: Geert Uytterhoeven <geert@linux-m68k.org>
      Thanks-to: Arnd Bergmann <arnd@arndb.de>
      
      To make me revisit this code.
      
      Fixes: a9cb97c3 ("media: dvb_frontend: be sure to init dvb_frontend_handle_ioctl() return code")
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fd1a885b
    • Katsuhiro Suzuki's avatar
      media: dvb_frontend: fix wrong cast in compat_ioctl · 39f03fef
      Katsuhiro Suzuki authored
      commit 5c6c9c48 upstream
      
      FE_GET_PROPERTY has always failed as following situations:
        - Use compatible ioctl
        - The array of 'struct dtv_property' has 2 or more items
      
      This patch fixes wrong cast to a pointer 'struct dtv_property' from a
      pointer of 2nd or after item of 'struct compat_dtv_property' array.
      Signed-off-by: default avatarKatsuhiro Suzuki <suzuki.katsuhiro@socionext.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      39f03fef
    • Jaedon Shin's avatar
      media: dvb_frontend: Add commands implementation for compat ioct · 20bcc237
      Jaedon Shin authored
      commit 18192a77 upstream
      
      The dtv_properties structure and the dtv_property structure are
      different sizes in 32-bit and 64-bit system. This patch provides
      FE_SET_PROPERTY and FE_GET_PROPERTY ioctl commands implementation for
      32-bit user space applications.
      Signed-off-by: default avatarJaedon Shin <jaedon.shin@gmail.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      20bcc237
    • Jaedon Shin's avatar
      media: dvb_frontend: Add compat_ioctl callback · 415ba04b
      Jaedon Shin authored
      commit c2dfd227 upstream
      
      Adds compat_ioctl for 32-bit user space applications on a 64-bit system.
      
      [m.chehab@osg.samsung.com: add missing include compat.h]
      Signed-off-by: default avatarJaedon Shin <jaedon.shin@gmail.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      415ba04b
    • Jaedon Shin's avatar
      media: dvb_frontend: Add unlocked_ioctl in dvb_frontend.c · 630b81e5
      Jaedon Shin authored
      commit a2282fd1 upstream
      
      Adds unlocked ioctl function directly in dvb_frontend.c instead of using
      dvb_generic_ioctl().
      Signed-off-by: default avatarJaedon Shin <jaedon.shin@gmail.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      630b81e5
    • Mauro Carvalho Chehab's avatar
      media: dvb_frontend: be sure to init dvb_frontend_handle_ioctl() return code · ae5c6c40
      Mauro Carvalho Chehab authored
      commit a9cb97c3 upstream
      
      As smatch warned:
      	drivers/media/dvb-core/dvb_frontend.c:2468 dvb_frontend_handle_ioctl() error: uninitialized symbol 'err'.
      
      The ioctl handler actually got a regression here: before changeset
      d73dcf0c ("media: dvb_frontend: cleanup ioctl handling logic"),
      the code used to return -EOPNOTSUPP if an ioctl handler was not
      implemented on a driver. After the change, it may return a random
      value.
      
      Fixes: d73dcf0c ("media: dvb_frontend: cleanup ioctl handling logic")
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Tested-by: default avatarDaniel Scheller <d.scheller@gmx.net>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ae5c6c40
    • Satendra Singh Thakur's avatar
      media: dvb_frontend: dtv_property_process_set() cleanups · b252335d
      Satendra Singh Thakur authored
      commit media: dvb_frontend: dtv_property_process_set() cleanups upstream
      
      Since all properties in the func dtv_property_process_set() use
      at most 4 bytes arguments, change the code to pass
      u32 cmd and u32 data as function arguments, instead of passing a
      pointer to the entire struct dtv_property *tvp.
      
      Instead of having a generic dtv_property_dump(), added its own
      properties debug logic in the dtv_property_process_set().
      Signed-off-by: default avatarSatendra Singh Thakur <satendra.t@samsung.com>
      Reviewed-by: default avatarShuah Khan <shuahkh@osg.samsung.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b252335d
    • Mauro Carvalho Chehab's avatar
      media: dvb_frontend: fix return values for FE_SET_PROPERTY · 55089d34
      Mauro Carvalho Chehab authored
      commit 259a41d9 upstream
      
      There are several problems with regards to the return of
      FE_SET_PROPERTY. The original idea were to return per-property
      return codes via tvp->result field, and to return an updated
      set of values.
      
      However, that never worked. What's actually implemented is:
      
      - the FE_SET_PROPERTY implementation doesn't call .get_frontend
        callback in order to get the actual parameters after return;
      
      - the tvp->result field is only filled if there's no error.
        So, it is always filled with zero;
      
      - FE_SET_PROPERTY doesn't call memdup_user() nor any other
        copy_to_user() function. So, any changes to the properties
        will be lost;
      
      - FE_SET_PROPERTY is declared as a write-only ioctl (IOW).
      
      While we could fix the above, it could cause regressions.
      
      So, let's just assume what the code really does, updating
      the documentation accordingly and removing the logic that
      would update the discarded tvp->result.
      Reviewed-by: default avatarShuah Khan <shuahkh@osg.samsung.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      55089d34