android_kernel_msm-6.1_noth.../drivers/net
Krister Johansen 90947ebf87 net: ena: fix shift-out-of-bounds in exponential backoff
commit 1e9cb763e9bacf0c932aa948f50dcfca6f519a26 upstream.

The ENA adapters on our instances occasionally reset.  Once recently
logged a UBSAN failure to console in the process:

  UBSAN: shift-out-of-bounds in build/linux/drivers/net/ethernet/amazon/ena/ena_com.c:540:13
  shift exponent 32 is too large for 32-bit type 'unsigned int'
  CPU: 28 PID: 70012 Comm: kworker/u72:2 Kdump: loaded not tainted 5.15.117
  Hardware name: Amazon EC2 c5d.9xlarge/, BIOS 1.0 10/16/2017
  Workqueue: ena ena_fw_reset_device [ena]
  Call Trace:
  <TASK>
  dump_stack_lvl+0x4a/0x63
  dump_stack+0x10/0x16
  ubsan_epilogue+0x9/0x36
  __ubsan_handle_shift_out_of_bounds.cold+0x61/0x10e
  ? __const_udelay+0x43/0x50
  ena_delay_exponential_backoff_us.cold+0x16/0x1e [ena]
  wait_for_reset_state+0x54/0xa0 [ena]
  ena_com_dev_reset+0xc8/0x110 [ena]
  ena_down+0x3fe/0x480 [ena]
  ena_destroy_device+0xeb/0xf0 [ena]
  ena_fw_reset_device+0x30/0x50 [ena]
  process_one_work+0x22b/0x3d0
  worker_thread+0x4d/0x3f0
  ? process_one_work+0x3d0/0x3d0
  kthread+0x12a/0x150
  ? set_kthread_struct+0x50/0x50
  ret_from_fork+0x22/0x30
  </TASK>

Apparently, the reset delays are getting so large they can trigger a
UBSAN panic.

Looking at the code, the current timeout is capped at 5000us.  Using a
base value of 100us, the current code will overflow after (1<<29).  Even
at values before 32, this function wraps around, perhaps
unintentionally.

Cap the value of the exponent used for this backoff at (1<<16) which is
larger than currently necessary, but large enough to support bigger
values in the future.

Cc: stable@vger.kernel.org
Fixes: 4bb7f4cf60 ("net: ena: reduce driver load time")
Signed-off-by: Krister Johansen <kjlx@templeofstupid.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Reviewed-by: Shay Agroskin <shayagr@amazon.com>
Link: https://lore.kernel.org/r/20230711013621.GE1926@templeofstupid.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-07-23 13:49:44 +02:00
..
appletalk
arcnet
bonding bonding: do not assume skb mac_header is set 2023-07-19 16:21:12 +02:00
caif
can can: kvaser_pciefd: Set hardware timestamp on transmitted packets 2023-07-19 16:21:11 +02:00
dsa net: dsa: qca8k: Add check for skb_copy 2023-07-23 13:49:24 +02:00
ethernet net: ena: fix shift-out-of-bounds in exponential backoff 2023-07-23 13:49:44 +02:00
fddi
fjes
hamradio
hippi
hyperv hv_netvsc: Check status in SEND_RNDIS_PKT completion message 2023-03-10 09:33:53 +01:00
ieee802154 ieee802154: hwsim: Fix possible memory leaks 2023-06-28 11:12:27 +02:00
ipa net: ipa: compute DMA pool size properly 2023-04-06 12:10:48 +02:00
ipvlan ipvlan: Fix return value of ipvlan_queue_xmit() 2023-07-19 16:21:13 +02:00
mctp
mdio net: mdio: mvusb: Fix an error handling path in mvusb_mdio_probe() 2023-05-24 17:32:31 +01:00
netdevsim netdevsim: fix uninitialized data in nsim_dev_trap_fa_cookie_write() 2023-07-23 13:49:27 +02:00
pcs net: pcs: xpcs: fix C73 AN not getting enabled 2023-05-24 17:32:47 +01:00
phy net: phy: dp83td510: fix kernel stall during netboot in DP83TD510E PHY driver 2023-07-23 13:49:32 +02:00
plip
ppp pptp: Fix fib lookup calls. 2023-07-19 16:22:06 +02:00
pse-pd
slip
team net: fix stack overflow when LRO is disabled for virtual interfaces 2023-05-30 14:03:20 +01:00
usb net: usb: qmi_wwan: add support for Compal RXM-G1 2023-06-21 16:00:56 +02:00
vmxnet3 vmxnet3: use gro callback when UPT is enabled 2023-04-06 12:10:52 +02:00
vxlan
wan net: lapbether: only support ethernet devices 2023-06-21 16:01:02 +02:00
wireguard wireguard: netlink: send staged packets when setting initial private key 2023-07-19 16:22:17 +02:00
wireless wifi: rtw89: debug: fix error code in rtw89_debug_priv_send_h2c_set() 2023-07-23 13:49:27 +02:00
wwan net: wwan: t7xx: Ensure init is completed before system sleep 2023-06-09 10:34:15 +02:00
xen-netback xen/netback: use same error messages for same errors 2023-04-26 14:28:37 +02:00
amt.c
bareudp.c
dummy.c
eql.c
geneve.c
gtp.c gtp: Fix use-after-free in __gtp_encap_destroy(). 2023-07-19 16:21:12 +02:00
ifb.c
Kconfig
LICENSE.SRC
loopback.c
macsec.c net: macsec: fix double free of percpu stats 2023-06-21 16:01:02 +02:00
macvlan.c
macvtap.c
Makefile
mdio.c
mhi_net.c
mii.c
net_failover.c net/net_failover: fix txq exceeding warning 2023-04-06 12:10:46 +02:00
netconsole.c
nlmon.c
ntb_netdev.c
rionet.c
sb1000.c
Space.c
sungem_phy.c
tap.c net: add vlan_get_protocol_and_depth() helper 2023-05-24 17:32:32 +01:00
thunderbolt.c
tun.c tun: Fix memory leak for detached NAPI queue. 2023-05-24 17:32:47 +01:00
veth.c veth: Fix use after free in XDP_REDIRECT 2023-03-22 13:33:49 +01:00
virtio_net.c virtio_net: use control_buf for coalesce params 2023-06-14 11:15:28 +02:00
vrf.c
vsockmon.c
xen-netfront.c