android_kernel_xiaomi_sm8450/drivers/net
Ido Schimmel 56750ea5d1 mlxsw: spectrum_acl_tcam: Fix stack corruption
[ Upstream commit 483ae90d8f976f8339cf81066312e1329f2d3706 ]

When tc filters are first added to a net device, the corresponding local
port gets bound to an ACL group in the device. The group contains a list
of ACLs. In turn, each ACL points to a different TCAM region where the
filters are stored. During forwarding, the ACLs are sequentially
evaluated until a match is found.

One reason to place filters in different regions is when they are added
with decreasing priorities and in an alternating order so that two
consecutive filters can never fit in the same region because of their
key usage.

In Spectrum-2 and newer ASICs the firmware started to report that the
maximum number of ACLs in a group is more than 16, but the layout of the
register that configures ACL groups (PAGT) was not updated to account
for that. It is therefore possible to hit stack corruption [1] in the
rare case where more than 16 ACLs in a group are required.

Fix by limiting the maximum ACL group size to the minimum between what
the firmware reports and the maximum ACLs that fit in the PAGT register.

Add a test case to make sure the machine does not crash when this
condition is hit.

[1]
Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: mlxsw_sp_acl_tcam_group_update+0x116/0x120
[...]
 dump_stack_lvl+0x36/0x50
 panic+0x305/0x330
 __stack_chk_fail+0x15/0x20
 mlxsw_sp_acl_tcam_group_update+0x116/0x120
 mlxsw_sp_acl_tcam_group_region_attach+0x69/0x110
 mlxsw_sp_acl_tcam_vchunk_get+0x492/0xa20
 mlxsw_sp_acl_tcam_ventry_add+0x25/0xe0
 mlxsw_sp_acl_rule_add+0x47/0x240
 mlxsw_sp_flower_replace+0x1a9/0x1d0
 tc_setup_cb_add+0xdc/0x1c0
 fl_hw_replace_filter+0x146/0x1f0
 fl_change+0xc17/0x1360
 tc_new_tfilter+0x472/0xb90
 rtnetlink_rcv_msg+0x313/0x3b0
 netlink_rcv_skb+0x58/0x100
 netlink_unicast+0x244/0x390
 netlink_sendmsg+0x1e4/0x440
 ____sys_sendmsg+0x164/0x260
 ___sys_sendmsg+0x9a/0xe0
 __sys_sendmsg+0x7a/0xc0
 do_syscall_64+0x40/0xe0
 entry_SYSCALL_64_after_hwframe+0x63/0x6b

Fixes: c3ab435466 ("mlxsw: spectrum: Extend to support Spectrum-2 ASIC")
Reported-by: Orel Hagag <orelh@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Amit Cohen <amcohen@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Acked-by: Paolo Abeni <pabeni@redhat.com>
Link: https://lore.kernel.org/r/2d91c89afba59c22587b444994ae419dbea8d876.1705502064.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 14:37:56 -08:00
..
appletalk
arcnet arcnet: restoring support for multiple Sohard Arcnet cards 2023-12-13 18:26:59 +01:00
bonding bonding: stop the device in bond_setup_by_slave() 2023-11-28 16:54:54 +00:00
caif caif_virtio: fix race between virtio_device_ready() and ndo_open() 2022-07-07 17:52:18 +02:00
can can: dev: can_restart(): fix race condition between controller restart and netif_carrier_on() 2023-11-20 11:06:45 +01:00
dsa net: dsa: vsc73xx: Add null pointer check to vsc73xx_gpio_probe 2024-01-25 14:37:55 -08:00
ethernet mlxsw: spectrum_acl_tcam: Fix stack corruption 2024-01-25 14:37:56 -08:00
fddi net: defxx: Fix missing err handling in dfx_init() 2023-01-14 10:15:42 +01:00
fjes
hamradio hamradio: baycom_epp: Fix return type of baycom_send_packet() 2023-01-14 10:16:16 +01:00
hippi drivers: net: hippi: Fix deadlock in rr_close() 2022-05-09 09:05:06 +02:00
hyperv hv_netvsc: rndis_filter needs to select NLS 2023-12-13 18:26:59 +01:00
ieee802154 net: ieee802154: adf7242: Fix some potential buffer overflow in adf7242_stats_show() 2023-11-08 17:30:42 +01:00
ipa net: ipa: compute DMA pool size properly 2023-04-05 11:23:48 +02:00
ipvlan ipvlan: add ipvlan_route_v6_outbound() helper 2023-11-28 16:54:53 +00:00
mdio net: mdio: mvusb: Fix an error handling path in mvusb_mdio_probe() 2023-05-30 12:57:45 +01:00
netdevsim netdevsim: fix uninitialized data in nsim_dev_trap_fa_cookie_write() 2023-07-27 08:44:24 +02:00
pcs
phy net: phy: micrel: populate .soft_reset for KSZ9131 2024-01-25 14:37:55 -08:00
plip net: plip: don't call kfree_skb/dev_kfree_skb() under spin_lock_irq() 2022-12-14 11:32:04 +01:00
ppp ppp: limit MRU to 64K 2023-11-28 16:54:54 +00:00
slip drivers: net: slip: fix NPD bug in sl_tx_timeout() 2022-04-20 09:23:24 +02:00
team team: Fix use-after-free when an option instance allocation fails 2023-12-20 15:44:37 +01:00
usb asix: Add check for usbnet_get_endpoints 2024-01-15 18:48:05 +01:00
vmxnet3 vmxnet3: correctly report csum_level for encapsulated packet 2023-01-14 10:16:45 +01:00
vxlan vxlan: generalize vxlan_parse_gpe_hdr and remove unused args 2023-09-19 12:20:04 +02:00
wan drivers/net: process the result of hdlc_open() and add call of hdlc_close() in uhdlc_close() 2023-10-10 21:53:37 +02:00
wimax
wireguard wireguard: use DEV_STATS_INC() 2023-12-08 08:46:08 +01:00
wireless wifi: mwifiex: configure BSSID consistently when starting AP 2024-01-25 14:37:52 -08:00
xen-netback xen-netback: don't produce zero-size SKB frags 2024-01-25 14:37:51 -08:00
bareudp.c bareudp: use ipv6_mod_enabled to check if IPv6 enabled 2022-04-08 14:40:22 +02:00
dummy.c
eql.c
geneve.c geneve: fix TOS inheriting for ipv4 2022-08-25 11:38:02 +02:00
gtp.c gtp: fix fragmentation needed check with gso 2023-11-08 17:30:43 +01:00
ifb.c
Kconfig lib/crypto: blake2s: include as built-in 2022-05-30 09:33:26 +02:00
LICENSE.SRC
loopback.c net: loopback: use NET_NAME_PREDICTABLE for name_assign_type 2022-12-21 17:32:08 +01:00
macsec.c net: add DEV_STATS_READ() helper 2023-11-20 11:06:46 +01:00
macvlan.c macvlan: Don't propagate promisc change to lower dev in passthru 2023-11-28 16:54:55 +00:00
macvtap.c macvtap: advertise link netns via netlink 2022-04-13 21:00:59 +02:00
Makefile vxlan: move to its own directory 2023-08-11 11:57:35 +02:00
mdio.c
mii.c
net_failover.c net/net_failover: fix txq exceeding warning 2023-04-05 11:23:47 +02:00
netconsole.c
nlmon.c
ntb_netdev.c ntb_netdev: Use dev_kfree_skb_any() in interrupt context 2023-01-14 10:15:44 +01:00
rionet.c
sb1000.c
Space.c
sungem_phy.c net: sungem_phy: Add of_node_put() for reference returned by of_get_parent() 2022-08-03 12:00:46 +02:00
tap.c net: tap_open(): set sk_uid from current_fsuid() 2023-08-11 11:57:52 +02:00
thunderbolt.c net: thunderbolt: Fix TCPv6 GSO checksum calculation 2023-10-10 21:53:35 +02:00
tun.c tun: prevent negative ifindex 2023-10-25 11:54:20 +02:00
veth.c veth: Fixing transmit return status for dropped packets 2023-09-19 12:20:26 +02:00
virtio_net.c virtio-net: set queues after driver_ok 2023-08-26 15:26:56 +02:00
vrf.c
vsockmon.c
xen-netfront.c xen-netfront: Fix NULL sring after live migration 2022-12-14 11:32:02 +01:00