1. 25 Oct, 2023 7 commits
  2. 24 Oct, 2023 5 commits
  3. 23 Oct, 2023 6 commits
  4. 22 Oct, 2023 13 commits
    • Fred Chen's avatar
      tcp: fix wrong RTO timeout when received SACK reneging · d2a0fc37
      Fred Chen authored
      This commit fix wrong RTO timeout when received SACK reneging.
      
      When an ACK arrived pointing to a SACK reneging, tcp_check_sack_reneging()
      will rearm the RTO timer for min(1/2*srtt, 10ms) into to the future.
      
      But since the commit 62d9f1a6 ("tcp: fix TLP timer not set when
      CA_STATE changes from DISORDER to OPEN") merged, the tcp_set_xmit_timer()
      is moved after tcp_fastretrans_alert()(which do the SACK reneging check),
      so the RTO timeout will be overwrited by tcp_set_xmit_timer() with
      icsk_rto instead of 1/2*srtt.
      
      Here is a packetdrill script to check this bug:
      0     socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
      +0    bind(3, ..., ...) = 0
      +0    listen(3, 1) = 0
      
      // simulate srtt to 100ms
      +0    < S 0:0(0) win 32792 <mss 1000, sackOK,nop,nop,nop,wscale 7>
      +0    > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 7>
      +.1    < . 1:1(0) ack 1 win 1024
      
      +0    accept(3, ..., ...) = 4
      
      +0    write(4, ..., 10000) = 10000
      +0    > P. 1:10001(10000) ack 1
      
      // inject sack
      +.1    < . 1:1(0) ack 1 win 257 <sack 1001:10001,nop,nop>
      +0    > . 1:1001(1000) ack 1
      
      // inject sack reneging
      +.1    < . 1:1(0) ack 1001 win 257 <sack 9001:10001,nop,nop>
      
      // we expect rto fired in 1/2*srtt (50ms)
      +.05    > . 1001:2001(1000) ack 1
      
      This fix remove the FLAG_SET_XMIT_TIMER from ack_flag when
      tcp_check_sack_reneging() set RTO timer with 1/2*srtt to avoid
      being overwrited later.
      
      Fixes: 62d9f1a6 ("tcp: fix TLP timer not set when CA_STATE changes from DISORDER to OPEN")
      Signed-off-by: default avatarFred Chen <fred.chenchen03@gmail.com>
      Reviewed-by: default avatarNeal Cardwell <ncardwell@google.com>
      Tested-by: default avatarNeal Cardwell <ncardwell@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d2a0fc37
    • David S. Miller's avatar
      Merge branch 'r8152-reg-garbage' · a40614fe
      David S. Miller authored
      Douglas Anderson says:
      
      ====================
      r8152: Avoid writing garbage to the adapter's registers
      
      This series is the result of a cooperative debug effort between
      Realtek and the ChromeOS team. On ChromeOS, we've noticed that Realtek
      Ethernet adapters can sometimes get so wedged that even a reboot of
      the host can't get them to enumerate again, assuming that the adapter
      was on a powered hub and din't lose power when the host rebooted. This
      is sometimes seen in the ChromeOS automated testing lab. The only way
      to recover adapters in this state is to manually power cycle them.
      
      I managed to reproduce one instance of this wedging (unknown if this
      is truly related to what the test lab sees) by doing this:
      1. Start a flood ping from a host to the device.
      2. Drop the device into kdb.
      3. Wait 90 seconds.
      4. Resume from kdb (the "g" command).
      5. Wait another 45 seconds.
      
      Upon analysis, Realtek realized this was happening:
      
      1. The Linux driver was getting a "Tx timeout" after resuming from kdb
         and then trying to reset itself.
      2. As part of the reset, the Linux driver was attempting to do a
         read-modify-write of the adapter's registers.
      3. The read would fail (due to a timeout) and the driver pretended
         that the register contained all 0xFFs. See commit f53a7ad1
         ("r8152: Set memory to all 0xFFs on failed reg reads")
      4. The driver would take this value of all 0xFFs, modify it, and
         attempt to write it back to the adapter.
      5. By this time the USB channel seemed to recover and thus we'd
         successfully write a value that was mostly 0xFFs to the adpater.
      6. The adapter didn't like this and would wedge itself.
      
      Another Engineer also managed to reproduce wedging of the Realtek
      Ethernet adpater during a reboot test on an AMD Chromebook. In that
      case he was sometimes seeing -EPIPE returned from the control
      transfers.
      
      This patch series fixes both issues.
      
      Changes in v5:
      - ("Run the unload routine if we have errors during probe") new for v5.
      - ("Cancel hw_phy_work if we have an error in probe") new for v5.
      - ("Release firmware if we have an error in probe") new for v5.
      - Removed extra mutex_unlock() left over in v4.
      - Fixed minor typos.
      - Don't do queue an unbind/bind reset if probe fails; just retry probe.
      
      Changes in v4:
      - Took out some unnecessary locks/unlocks of the control mutex.
      - Added comment about reading version causing probe fail if 3 fails.
      - Added text to commit msg about the potential unbind/bind loop.
      
      Changes in v3:
      - Fixed v2 changelog ending up in the commit message.
      - farmework -> framework in comments.
      
      Changes in v2:
      - ("Check for unplug in rtl_phy_patch_request()") new for v2.
      - ("Check for unplug in r8153b_ups_en() / r8153c_ups_en()") new for v2.
      - ("Rename RTL8152_UNPLUG to RTL8152_INACCESSIBLE") new for v2.
      - Reset patch no longer based on retry patch, since that was dropped.
      - Reset patch should be robust even if failures happen in probe.
      - Switched booleans to bits in the "flags" variable.
      - Check for -ENODEV instead of "udev->state == USB_STATE_NOTATTACHED"
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a40614fe
    • Douglas Anderson's avatar
      r8152: Block future register access if register access fails · d9962b0d
      Douglas Anderson authored
      Even though the functions to read/write registers can fail, most of
      the places in the r8152 driver that read/write register values don't
      check error codes. The lack of error code checking is problematic in
      at least two ways.
      
      The first problem is that the r8152 driver often uses code patterns
      similar to this:
        x = read_register()
        x = x | SOME_BIT;
        write_register(x);
      
      ...with the above pattern, if the read_register() fails and returns
      garbage then we'll end up trying to write modified garbage back to the
      Realtek adapter. If the write_register() succeeds that's bad. Note
      that as of commit f53a7ad1 ("r8152: Set memory to all 0xFFs on
      failed reg reads") the "garbage" returned by read_register() will at
      least be consistent garbage, but it is still garbage.
      
      It turns out that this problem is very serious. Writing garbage to
      some of the hardware registers on the Ethernet adapter can put the
      adapter in such a bad state that it needs to be power cycled (fully
      unplugged and plugged in again) before it can enumerate again.
      
      The second problem is that the r8152 driver generally has functions
      that are long sequences of register writes. Assuming everything will
      be OK if a random register write fails in the middle isn't a great
      assumption.
      
      One might wonder if the above two problems are real. You could ask if
      we would really have a successful write after a failed read. It turns
      out that the answer appears to be "yes, this can happen". In fact,
      we've seen at least two distinct failure modes where this happens.
      
      On a sc7180-trogdor Chromebook if you drop into kdb for a while and
      then resume, you can see:
      1. We get a "Tx timeout"
      2. The "Tx timeout" queues up a USB reset.
      3. In rtl8152_pre_reset() we try to reinit the hardware.
      4. The first several (2-9) register accesses fail with a timeout, then
         things recover.
      
      The above test case was actually fixed by the patch ("r8152: Increase
      USB control msg timeout to 5000ms as per spec") but at least shows
      that we really can see successful calls after failed ones.
      
      On a different (AMD) based Chromebook with a particular adapter, we
      found that during reboot tests we'd also sometimes get a transitory
      failure. In this case we saw -EPIPE being returned sometimes. Retrying
      worked, but retrying is not always safe for all register accesses
      since reading/writing some registers might have side effects (like
      registers that clear on read).
      
      Let's fully lock out all register access if a register access fails.
      When we do this, we'll try to queue up a USB reset and try to unlock
      register access after the reset. This is slightly tricker than it
      sounds since the r8152 driver has an optimized reset sequence that
      only works reliably after probe happens. In order to handle this, we
      avoid the optimized reset if probe didn't finish. Instead, we simply
      retry the probe routine in this case.
      
      When locking out access, we'll use the existing infrastructure that
      the driver was using when it detected we were unplugged. This keeps us
      from getting stuck in delay loops in some parts of the driver.
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Reviewed-by: default avatarGrant Grundler <grundler@chromium.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d9962b0d
    • Douglas Anderson's avatar
      r8152: Rename RTL8152_UNPLUG to RTL8152_INACCESSIBLE · 715f67f3
      Douglas Anderson authored
      Whenever the RTL8152_UNPLUG is set that just tells the driver that all
      accesses will fail and we should just immediately bail. A future patch
      will use this same concept at a time when the driver hasn't actually
      been unplugged but is about to be reset. Rename the flag in
      preparation for the future patch.
      
      This is a no-op change and just a search and replace.
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Reviewed-by: default avatarGrant Grundler <grundler@chromium.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      715f67f3
    • Douglas Anderson's avatar
      r8152: Check for unplug in r8153b_ups_en() / r8153c_ups_en() · bc65cc42
      Douglas Anderson authored
      If the adapter is unplugged while we're looping in r8153b_ups_en() /
      r8153c_ups_en() we could end up looping for 10 seconds (20 ms * 500
      loops). Add code similar to what's done in other places in the driver
      to check for unplug and bail.
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Reviewed-by: default avatarGrant Grundler <grundler@chromium.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      bc65cc42
    • Douglas Anderson's avatar
      r8152: Check for unplug in rtl_phy_patch_request() · dc90ba37
      Douglas Anderson authored
      If the adapter is unplugged while we're looping in
      rtl_phy_patch_request() we could end up looping for 10 seconds (2 ms *
      5000 loops). Add code similar to what's done in other places in the
      driver to check for unplug and bail.
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Reviewed-by: default avatarGrant Grundler <grundler@chromium.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      dc90ba37
    • Douglas Anderson's avatar
      r8152: Release firmware if we have an error in probe · b8d35024
      Douglas Anderson authored
      The error handling in rtl8152_probe() is missing a call to release
      firmware. Add it in to match what's in the cleanup code in
      rtl8152_disconnect().
      
      Fixes: 9370f2d0 ("r8152: support request_firmware for RTL8153")
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Reviewed-by: default avatarGrant Grundler <grundler@chromium.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b8d35024
    • Douglas Anderson's avatar
      r8152: Cancel hw_phy_work if we have an error in probe · bb8adff9
      Douglas Anderson authored
      The error handling in rtl8152_probe() is missing a call to cancel the
      hw_phy_work. Add it in to match what's in the cleanup code in
      rtl8152_disconnect().
      
      Fixes: a028a9e0 ("r8152: move the settings of PHY to a work queue")
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Reviewed-by: default avatarGrant Grundler <grundler@chromium.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      bb8adff9
    • Douglas Anderson's avatar
      r8152: Run the unload routine if we have errors during probe · 5dd17689
      Douglas Anderson authored
      The rtl8152_probe() function lacks a call to the chip-specific
      unload() routine when it sees an error in probe. Add it in to match
      the cleanup code in rtl8152_disconnect().
      
      Fixes: ac718b69 ("net/usb: new driver for RTL8152")
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Reviewed-by: default avatarGrant Grundler <grundler@chromium.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5dd17689
    • Douglas Anderson's avatar
      r8152: Increase USB control msg timeout to 5000ms as per spec · a5feba71
      Douglas Anderson authored
      According to the comment next to USB_CTRL_GET_TIMEOUT and
      USB_CTRL_SET_TIMEOUT, although sending/receiving control messages is
      usually quite fast, the spec allows them to take up to 5 seconds.
      Let's increase the timeout in the Realtek driver from 500ms to 5000ms
      (using the #defines) to account for this.
      
      This is not just a theoretical change. The need for the longer timeout
      was seen in testing. Specifically, if you drop a sc7180-trogdor based
      Chromebook into the kdb debugger and then "go" again after sitting in
      the debugger for a while, the next USB control message takes a long
      time. Out of ~40 tests the slowest USB control message was 4.5
      seconds.
      
      While dropping into kdb is not exactly an end-user scenario, the above
      is similar to what could happen due to an temporary interrupt storm,
      what could happen if there was a host controller (HW or SW) issue, or
      what could happen if the Realtek device got into a confused state and
      needed time to recover.
      
      This change is fairly critical since the r8152 driver in Linux doesn't
      expect register reads/writes (which are backed by USB control
      messages) to fail.
      
      Fixes: ac718b69 ("net/usb: new driver for RTL8152")
      Suggested-by: default avatarHayes Wang <hayeswang@realtek.com>
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Reviewed-by: default avatarGrant Grundler <grundler@chromium.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a5feba71
    • Shigeru Yoshida's avatar
      net: usb: smsc95xx: Fix uninit-value access in smsc95xx_read_reg · 51a32e82
      Shigeru Yoshida authored
      syzbot reported the following uninit-value access issue [1]:
      
      smsc95xx 1-1:0.0 (unnamed net_device) (uninitialized): Failed to read reg index 0x00000030: -32
      smsc95xx 1-1:0.0 (unnamed net_device) (uninitialized): Error reading E2P_CMD
      =====================================================
      BUG: KMSAN: uninit-value in smsc95xx_reset+0x409/0x25f0 drivers/net/usb/smsc95xx.c:896
       smsc95xx_reset+0x409/0x25f0 drivers/net/usb/smsc95xx.c:896
       smsc95xx_bind+0x9bc/0x22e0 drivers/net/usb/smsc95xx.c:1131
       usbnet_probe+0x100b/0x4060 drivers/net/usb/usbnet.c:1750
       usb_probe_interface+0xc75/0x1210 drivers/usb/core/driver.c:396
       really_probe+0x506/0xf40 drivers/base/dd.c:658
       __driver_probe_device+0x2a7/0x5d0 drivers/base/dd.c:800
       driver_probe_device+0x72/0x7b0 drivers/base/dd.c:830
       __device_attach_driver+0x55a/0x8f0 drivers/base/dd.c:958
       bus_for_each_drv+0x3ff/0x620 drivers/base/bus.c:457
       __device_attach+0x3bd/0x640 drivers/base/dd.c:1030
       device_initial_probe+0x32/0x40 drivers/base/dd.c:1079
       bus_probe_device+0x3d8/0x5a0 drivers/base/bus.c:532
       device_add+0x16ae/0x1f20 drivers/base/core.c:3622
       usb_set_configuration+0x31c9/0x38c0 drivers/usb/core/message.c:2207
       usb_generic_driver_probe+0x109/0x2a0 drivers/usb/core/generic.c:238
       usb_probe_device+0x290/0x4a0 drivers/usb/core/driver.c:293
       really_probe+0x506/0xf40 drivers/base/dd.c:658
       __driver_probe_device+0x2a7/0x5d0 drivers/base/dd.c:800
       driver_probe_device+0x72/0x7b0 drivers/base/dd.c:830
       __device_attach_driver+0x55a/0x8f0 drivers/base/dd.c:958
       bus_for_each_drv+0x3ff/0x620 drivers/base/bus.c:457
       __device_attach+0x3bd/0x640 drivers/base/dd.c:1030
       device_initial_probe+0x32/0x40 drivers/base/dd.c:1079
       bus_probe_device+0x3d8/0x5a0 drivers/base/bus.c:532
       device_add+0x16ae/0x1f20 drivers/base/core.c:3622
       usb_new_device+0x15f6/0x22f0 drivers/usb/core/hub.c:2589
       hub_port_connect drivers/usb/core/hub.c:5440 [inline]
       hub_port_connect_change drivers/usb/core/hub.c:5580 [inline]
       port_event drivers/usb/core/hub.c:5740 [inline]
       hub_event+0x53bc/0x7290 drivers/usb/core/hub.c:5822
       process_one_work kernel/workqueue.c:2630 [inline]
       process_scheduled_works+0x104e/0x1e70 kernel/workqueue.c:2703
       worker_thread+0xf45/0x1490 kernel/workqueue.c:2784
       kthread+0x3e8/0x540 kernel/kthread.c:388
       ret_from_fork+0x66/0x80 arch/x86/kernel/process.c:147
       ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304
      
      Local variable buf.i225 created at:
       smsc95xx_read_reg drivers/net/usb/smsc95xx.c:90 [inline]
       smsc95xx_reset+0x203/0x25f0 drivers/net/usb/smsc95xx.c:892
       smsc95xx_bind+0x9bc/0x22e0 drivers/net/usb/smsc95xx.c:1131
      
      CPU: 1 PID: 773 Comm: kworker/1:2 Not tainted 6.6.0-rc1-syzkaller-00125-ge42bebf6 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/04/2023
      Workqueue: usb_hub_wq hub_event
      =====================================================
      
      Similar to e9c65989 ("net: usb: smsc75xx: Fix uninit-value access in
      __smsc75xx_read_reg"), this issue is caused because usbnet_read_cmd() reads
      less bytes than requested (zero byte in the reproducer). In this case,
      'buf' is not properly filled.
      
      This patch fixes the issue by returning -ENODATA if usbnet_read_cmd() reads
      less bytes than requested.
      
      sysbot reported similar uninit-value access issue [2]. The root cause is
      the same as mentioned above, and this patch addresses it as well.
      
      Fixes: 2f7ca802 ("net: Add SMSC LAN9500 USB2.0 10/100 ethernet adapter driver")
      Reported-and-tested-by: syzbot+c74c24b43c9ae534f0e0@syzkaller.appspotmail.com
      Reported-and-tested-by: syzbot+2c97a98a5ba9ea9c23bd@syzkaller.appspotmail.com
      Closes: https://syzkaller.appspot.com/bug?extid=c74c24b43c9ae534f0e0 [1]
      Closes: https://syzkaller.appspot.com/bug?extid=2c97a98a5ba9ea9c23bd [2]
      Signed-off-by: default avatarShigeru Yoshida <syoshida@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      51a32e82
    • Su Hui's avatar
      net: chelsio: cxgb4: add an error code check in t4_load_phy_fw · 9f771493
      Su Hui authored
      t4_set_params_timeout() can return -EINVAL if failed, add check
      for this.
      Signed-off-by: default avatarSu Hui <suhui@nfschina.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9f771493
    • Christophe JAILLET's avatar
      net: ieee802154: adf7242: Fix some potential buffer overflow in adf7242_stats_show() · ca082f01
      Christophe JAILLET authored
      strncat() usage in adf7242_debugfs_init() is wrong.
      The size given to strncat() is the maximum number of bytes that can be
      written, excluding the trailing NULL.
      
      Here, the size that is passed, DNAME_INLINE_LEN, does not take into account
      the size of "adf7242-" that is already in the array.
      
      In order to fix it, use snprintf() instead.
      
      Fixes: 7302b9d9 ("ieee802154/adf7242: Driver for ADF7242 MAC IEEE802154")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ca082f01
  5. 21 Oct, 2023 7 commits
  6. 20 Oct, 2023 2 commits