1. Mar 16, 2018
    • Hans de Goede's avatar
      Bluetooth: hci_bcm: Set pulsed_host_wake flag in sleep parameters · e07c99b0
      Hans de Goede authored
      The IRQ output of the bcm bt-device is really a level IRQ signal, which
      signals a logical high as long as the device's buffer contains data. Since
      the draining in the buffer is done in the tty driver, we cannot (easily)
      wait in a threaded interrupt handler for the draining, after which the
      IRQ should go low again.
      
      So instead we treat the IRQ as an edge interrupt. This opens the window
      for a theoretical race where we wakeup, read some data and then autosuspend
      *before* the IRQ has gone (logical) low, followed by the device just at
      that moment receiving more data, causing the IRQ to stay high and we never
      see an edge.
      
      Since we call pm_runtime_mark_last_busy() on every received byte, there
      should be plenty time for the IRQ to go (logical) low before we ever
      suspend, so this should never happen, but after commit 43fff768
      
      
      ("Bluetooth: hci_bcm: Streamline runtime PM code"), which has been reverted
      since, this was actually happening causing the device to get stuck in
      runtime suspend.
      
      The bcm bt-device actually has a workaround for this, if we set the
      pulsed_host_wake flag in the sleep parameters, then the device monitors
      if the host is draining the buffer and if not then after a timeout the
      device will pulse the IRQ line, causing us to see an edge, fixing the
      stuck in suspend condition.
      
      This commit sets the pulsed_host_wake flag to fix the (mostly theoretical)
      race caused by us treating the IRQ as an edge IRQ.
      
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Reviewed-by: default avatarLukas Wunner <lukas@wunner.de>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      e07c99b0
    • Hans de Goede's avatar
      Revert "Bluetooth: hci_bcm: Streamline runtime PM code" · b09c6152
      Hans de Goede authored
      This reverts commit 43fff768
      
       ("Bluetooth: hci_bcm: Streamline runtime
      PM code"). The commit msg for this commit states "No functional change
      intended.", but replacing:
      
       pm_runtime_get();
       pm_runtime_mark_last_busy();
       pm_runtime_put_autosuspend();
      
      with:
      
       pm_request_resume();
      
      Does result in a functional change, pm_request_resume() only calls
      pm_runtime_mark_last_busy() if the device was suspended before the call.
      
      This results in the following happening:
      
      1) Device is runtime suspended
      2) Device drives host_wake IRQ logically high as it starts receiving data
      3) bcm_host_wake() gets called, causes the device to runtime-resume,
         current time gets marked as last_busy time
      4) After 5 seconds the autosuspend timer expires and the dev autosuspends
         as no one has been calling pm_runtime_mark_last_busy(), the device was
         resumed during those 5 seconds, so all the pm_request_resume() calls
         while receiving data and/or bcm_host_wake() calls were nops
      5) If 4) happens while the device has (just received) data in its buffer to
         be read by the host the IRQ line is *already* / still logically high
         when we autosuspend and since we use an edge triggered IRQ, the IRQ
         will never trigger, causing the device to get stuck in suspend
      
      Therefor this commit has to be reverted, so that we avoid the device
      getting stuck in suspend.
      
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Acked-by: default avatarLukas Wunner <lukas@wunner.de>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      b09c6152
    • Takashi Iwai's avatar
      Bluetooth: btusb: Fix quirk for Atheros 1525/QCA6174 · f44cb4b1
      Takashi Iwai authored
      The Atheros 1525/QCA6174 BT doesn't seem working properly on the
      recent kernels, as it tries to load a wrong firmware
      ar3k/AthrBT_0x00000200.dfu and it fails.
      
      This seems to have been a problem for some time, and the known
      workaround is to apply BTUSB_QCA_ROM quirk instead of BTUSB_ATH3012.
      
      The device in question is:
      
      T: Bus=01 Lev=01 Prnt=01 Port=09 Cnt=03 Dev#=  4 Spd=12   MxCh= 0
      D: Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
      P: Vendor=0cf3 ProdID=3004 Rev= 0.01
      C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
      I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E: Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
      E: Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
      E: Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
      I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E: Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
      E: Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
      I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E: Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
      E: Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
      I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E: Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
      E: Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
      I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E: Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
      E: Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
      I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E: Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
      E: Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
      I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E: Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
      E: Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
      
      Bugzilla: http://bugzilla.opensuse.org/show_bug.cgi?id=1082504
      
      
      Reported-by: default avatarIvan Levshin <ivan.levshin@microfocus.com>
      Tested-by: default avatarIvan Levshin <ivan.levshin@microfocus.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      f44cb4b1
  2. Mar 15, 2018
  3. Mar 14, 2018
  4. Mar 13, 2018
    • Dan Carpenter's avatar
      qed: Use after free in qed_rdma_free() · f89782c2
      Dan Carpenter authored
      We're dereferencing "p_hwfn->p_rdma_info" but that is freed on the line
      before in qed_rdma_resc_free(p_hwfn).
      
      Fixes: 9de506a5
      
       ("qed: Free RoCE ILT Memory on rmmod qedr")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Acked-by: default avatarMichal Kalderon <Michal.Kalderon@cavium.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f89782c2
    • David S. Miller's avatar
      Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec · d2ddf628
      David S. Miller authored
      
      
      Steffen Klassert says:
      
      ====================
      pull request (net): ipsec 2018-03-13
      
      1) Refuse to insert 32 bit userspace socket policies on 64
         bit systems like we do it for standard policies. We don't
         have a compat layer, so inserting socket policies from
         32 bit userspace will lead to a broken configuration.
      
      2) Make the policy hold queue work without the flowcache.
         Dummy bundles are not chached anymore, so we need to
         generate a new one on each lookup as long as the SAs
         are not yet in place.
      
      3) Fix the validation of the esn replay attribute. The
         The sanity check in verify_replay() is bypassed if
         the XFRM_STATE_ESN flag is not set. Fix this by doing
         the sanity check uncoditionally.
         From Florian Westphal.
      
      4) After most of the dst_entry garbage collection code
         is removed, we may leak xfrm_dst entries as they are
         neither cached nor tracked somewhere. Fix this by
         reusing the 'uncached_list' to track xfrm_dst entries
         too. From Xin Long.
      
      5) Fix a rcu_read_lock/rcu_read_unlock imbalance in
         xfrm_get_tos() From Xin Long.
      
      6) Fix an infinite loop in xfrm_get_dst_nexthop. On
         transport mode we fetch the child dst_entry after
         we continue, so this pointer is never updated.
         Fix this by fetching it before we continue.
      
      7) Fix ESN sequence number gap after IPsec GSO packets.
          We accidentally increment the sequence number counter
          on the xfrm_state by one packet too much in the ESN
          case. Fix this by setting the sequence number to the
          correct value.
      
      8) Reset the ethernet protocol after decapsulation only if a
         mac header was set. Otherwise it breaks configurations
         with TUN devices. From Yossi Kuperman.
      
      9) Fix __this_cpu_read() usage in preemptible code. Use
         this_cpu_read() instead in ipcomp_alloc_tfms().
         From Greg Hackmann.
      
      Please pull or let me know if there are problems.
      ====================
      
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d2ddf628
    • Greg Hackmann's avatar
      net: xfrm: use preempt-safe this_cpu_read() in ipcomp_alloc_tfms() · 0dcd7876
      Greg Hackmann authored
      f7c83bcb ("net: xfrm: use __this_cpu_read per-cpu helper") added a
      __this_cpu_read() call inside ipcomp_alloc_tfms().
      
      At the time, __this_cpu_read() required the caller to either not care
      about races or to handle preemption/interrupt issues.  3.15 tightened
      the rules around some per-cpu operations, and now __this_cpu_read()
      should never be used in a preemptible context.  On 3.15 and later, we
      need to use this_cpu_read() instead.
      
      syzkaller reported this leading to the following kernel BUG while
      fuzzing sendmsg:
      
      BUG: using __this_cpu_read() in preemptible [00000000] code: repro/3101
      caller is ipcomp_init_state+0x185/0x990
      CPU: 3 PID: 3101 Comm: repro Not tainted 4.16.0-rc4-00123-g86f84779 #154
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
      Call Trace:
       dump_stack+0xb9/0x115
       check_preemption_disabled+0x1cb/0x1f0
       ipcomp_init_state+0x185/0x990
       ? __xfrm_init_state+0x876/0xc20
       ? lock_downgrade+0x5e0...
      0dcd7876
    • Florian Fainelli's avatar
      net: dsa: Fix dsa_is_user_port() test inversion · 5a9f8df6
      Florian Fainelli authored
      During the conversion to dsa_is_user_port(), a condition ended up being
      reversed, which would prevent the creation of any user port when using
      the legacy binding and/or platform data, fix that.
      
      Fixes: 4a5b85ff
      
       ("net: dsa: use dsa_is_user_port everywhere")
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5a9f8df6
    • David S. Miller's avatar
      Merge branch '1GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-queue · 59bb8835
      David S. Miller authored
      
      
      Jeff Kirsher says:
      
      ====================
      Intel Wired LAN Driver Updates 2018-03-12
      
      This series contains fixes to e1000e only.
      
      Benjamin Poirier provides two fixes, first reverts commits that changed
      what happens to the link status when there is an error.  These commits
      were to resolve a race condition, but in the process of fixing the race
      condition, they changed the behavior when an error occurred.  Second fix
      resolves a race condition by not setting "get_link_status" to false
      after checking the link.
      ====================
      
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      59bb8835
    • David S. Miller's avatar
      Merge branch 'l2tp-fix-races-with-ipv4-mapped-ipv6-addresses' · 38fbbc9c
      David S. Miller authored
      
      
      Paolo Abeni says:
      
      ====================
      l2tp: fix races with ipv4-mapped ipv6 addresses
      
      The syzbot reported an l2tp oops that uncovered some races in the l2tp xmit
      path and a partially related issue in the generic ipv6 code.
      
      We need to address them separately.
      
      v1 -> v2:
       - add missing fixes tag in patch 1
       - fix several issues in patch 2
      
      v2 -> v3:
       - dropped some unneeded chunks in patch 2
      ====================
      
      Reviewed-by: default avatarGuillaume Nault <g.nault@alphalink.fr>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      38fbbc9c
    • Paolo Abeni's avatar
      l2tp: fix races with ipv4-mapped ipv6 addresses · b954f940
      Paolo Abeni authored
      
      
      The l2tp_tunnel_create() function checks for v4mapped ipv6
      sockets and cache that flag, so that l2tp core code can
      reusing it at xmit time.
      
      If the socket is provided by the userspace, the connection
      status of the tunnel sockets can change between the tunnel
      creation and the xmit call, so that syzbot is able to
      trigger the following splat:
      
      BUG: KASAN: use-after-free in ip6_dst_idev include/net/ip6_fib.h:192
      [inline]
      BUG: KASAN: use-after-free in ip6_xmit+0x1f76/0x2260
      net/ipv6/ip6_output.c:264
      Read of size 8 at addr ffff8801bd949318 by task syz-executor4/23448
      
      CPU: 0 PID: 23448 Comm: syz-executor4 Not tainted 4.16.0-rc4+ #65
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
      Google 01/01/2011
      Call Trace:
        __dump_stack lib/dump_stack.c:17 [inline]
        dump_stack+0x194/0x24d lib/dump_stack.c:53
        print_address_description+0x73/0x250 mm/kasan/report.c:256
        kasan_report_error mm/kasan/report.c:354 [inline]
        kasan_report+0x23c/0x360 mm/kasan/report.c:412
        __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
        ip6_dst_idev include/net/ip6_fib.h:192 [inline]
        ip6_xmit+0x1f76/0x2260 net/ipv6/ip6_output.c:264
        inet6_csk_xmit+0x2fc/0x580 net/ipv6/inet6_connection_sock.c:139
        l2tp_xmit_core net/l2tp/l2tp_core.c:1053 [inline]
        l2tp_xmit_skb+0x105f/0x1410 net/l2tp/l2tp_core.c:1148
        pppol2tp_sendmsg+0x470/0x670 net/l2tp/l2tp_ppp.c:341
        sock_sendmsg_nosec net/socket.c:630 [inline]
        sock_sendmsg+0xca/0x110 net/socket.c:640
        ___sys_sendmsg+0x767/0x8b0 net/socket.c:2046
        __sys_sendmsg+0xe5/0x210 net/socket.c:2080
        SYSC_sendmsg net/socket.c:2091 [inline]
        SyS_sendmsg+0x2d/0x50 net/socket.c:2087
        do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
        entry_SYSCALL_64_after_hwframe+0x42/0xb7
      RIP: 0033:0x453e69
      RSP: 002b:00007f819593cc68 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
      RAX: ffffffffffffffda RBX: 00007f819593d6d4 RCX: 0000000000453e69
      RDX: 0000000000000081 RSI: 000000002037ffc8 RDI: 0000000000000004
      RBP: 000000000072bea0 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
      R13: 00000000000004c3 R14: 00000000006f72e8 R15: 0000000000000000
      
      This change addresses the issues:
      * explicitly checking for TCP_ESTABLISHED for user space provided sockets
      * dropping the v4mapped flag usage - it can become outdated - and
        explicitly invoking ipv6_addr_v4mapped() instead
      
      The issue is apparently there since ancient times.
      
      v1 -> v2: (many thanks to Guillaume)
       - with csum issue introduced in v1
       - replace pr_err with pr_debug
       - fix build issue with IPV6 disabled
       - move l2tp_sk_is_v4mapped in l2tp_core.c
      
      v2 -> v3:
       - don't update inet_daddr for v4mapped address, unneeded
       - drop rendundant check at creation time
      
      Reported-and-tested-by: default avatar <syzbot+92fa328176eb07e4ac1a@syzkaller.appspotmail.com>
      Fixes: 3557baab
      
       ("[L2TP]: PPP over L2TP driver core")
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b954f940
    • Paolo Abeni's avatar
      net: ipv6: keep sk status consistent after datagram connect failure · 2f987a76
      Paolo Abeni authored
      On unsuccesful ip6_datagram_connect(), if the failure is caused by
      ip6_datagram_dst_update(), the sk peer information are cleared, but
      the sk->sk_state is preserved.
      
      If the socket was already in an established status, the overall sk
      status is inconsistent and fouls later checks in datagram code.
      
      Fix this saving the old peer information and restoring them in
      case of failure. This also aligns ipv6 datagram connect() behavior
      with ipv4.
      
      v1 -> v2:
       - added missing Fixes tag
      
      Fixes: 85cb73ff
      
       ("net: ipv6: reset daddr and dport in sk if connect() fails")
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2f987a76
    • Benjamin Poirier's avatar
      e1000e: Fix link check race condition · e2710dbf
      Benjamin Poirier authored
      Alex reported the following race condition:
      
      /* link goes up... interrupt... schedule watchdog */
      \ e1000_watchdog_task
      	\ e1000e_has_link
      		\ hw->mac.ops.check_for_link() === e1000e_check_for_copper_link
      			\ e1000e_phy_has_link_generic(..., &link)
      				link = true
      
      					 /* link goes down... interrupt */
      					 \ e1000_msix_other
      						 hw->mac.get_link_status = true
      
      			/* link is up */
      			mac->get_link_status = false
      
      		link_active = true
      		/* link_active is true, wrongly, and stays so because
      		 * get_link_status is false */
      
      Avoid this problem by making sure that we don't set get_link_status = false
      after having checked the link.
      
      It seems this problem has been present since the introduction of e1000e.
      
      Link: https://lkml.org/lkml/2018/1/29/338
      
      
      Reported-by: default avatarAlexander Duyck <alexander.duyck@gmail.com>
      Signed-off-by: default avatarBenjamin Poirier <bpoirier@suse.com>
      Acked-by: default avatarAlexander Duyck <alexander.h.duyck@intel.com>
      Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      e2710dbf
    • Benjamin Poirier's avatar
      Revert "e1000e: Separate signaling for link check/link up" · 3016e0a0
      Benjamin Poirier authored
      This reverts commit 19110cfb.
      This reverts commit 4110e02e.
      This reverts commit d3604515c9eda464a92e8e67aae82dfe07fe3c98.
      
      Commit 19110cfb ("e1000e: Separate signaling for link check/link up")
      changed what happens to the link status when there is an error which
      happens after "get_link_status = false" in the copper check_for_link
      callbacks. Previously, such an error would be ignored and the link
      considered up. After that commit, any error implies that the link is down.
      
      Revert commit 19110cfb ("e1000e: Separate signaling for link check/link
      up") and its followups. After reverting, the race condition described in
      the log of commit 19110cfb is reintroduced. It may still be triggered
      by LSC events but this should keep the link down in case the link is
      electrically unstable, as discussed. The race may no longer be
      triggered by RXO events because commit 4aea7a5c ("e1000e: Avoid
      receiver overrun interrupt bursts") restored reading icr in the Other
      handler.
      
      Link: https://lkml.org/lkml/2018/3/1/789
      
      
      Signed-off-by: default avatarBenjamin Poirier <bpoirier@suse.com>
      Acked-by: default avatarAlexander Duyck <alexander.h.duyck@intel.com>
      Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      3016e0a0
    • David S. Miller's avatar
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf · b7475948
      David S. Miller authored
      Pablo Neira Ayuso says:
      
      ====================
      Netfilter fixes for net
      
      The following patchset contains Netfilter fixes for your net tree, they are:
      
      1) Fixed hashtable representation doesn't support timeout flag, skip it
         otherwise rules to add elements from the packet fail bogusly fail with
         EOPNOTSUPP.
      
      2) Fix bogus error with 32-bits ebtables userspace and 64-bits kernel,
         patch from Florian Westphal.
      
      3) Sanitize proc names in several x_tables extensions, also from Florian.
      
      4) Add sanitization to ebt_among wormhash logic, from Florian.
      
      5) Missing release of hook array in flowtable.
      ====================
      b7475948
  5. Mar 12, 2018