kernel_samsung_a53x/net/mac80211
Dmitry Antipov 645463907c wifi: mac80211: fix UBSAN noise in ieee80211_prep_hw_scan()
[ Upstream commit 92ecbb3ac6f3fe8ae9edf3226c76aa17b6800699 ]

When testing the previous patch with CONFIG_UBSAN_BOUNDS, I've
noticed the following:

UBSAN: array-index-out-of-bounds in net/mac80211/scan.c:372:4
index 0 is out of range for type 'struct ieee80211_channel *[]'
CPU: 0 PID: 1435 Comm: wpa_supplicant Not tainted 6.9.0+ #1
Hardware name: LENOVO 20UN005QRT/20UN005QRT <...BIOS details...>
Call Trace:
 <TASK>
 dump_stack_lvl+0x2d/0x90
 __ubsan_handle_out_of_bounds+0xe7/0x140
 ? timerqueue_add+0x98/0xb0
 ieee80211_prep_hw_scan+0x2db/0x480 [mac80211]
 ? __kmalloc+0xe1/0x470
 __ieee80211_start_scan+0x541/0x760 [mac80211]
 rdev_scan+0x1f/0xe0 [cfg80211]
 nl80211_trigger_scan+0x9b6/0xae0 [cfg80211]
 ...<the rest is not too useful...>

Since '__ieee80211_start_scan()' leaves 'hw_scan_req->req.n_channels'
uninitialized, actual boundaries of 'hw_scan_req->req.channels' can't
be checked in 'ieee80211_prep_hw_scan()'. Although an initialization
of 'hw_scan_req->req.n_channels' introduces some confusion around
allocated vs. used VLA members, this shouldn't be a problem since
everything is correctly adjusted soon in 'ieee80211_prep_hw_scan()'.

Cleanup 'kmalloc()' math in '__ieee80211_start_scan()' by using the
convenient 'struct_size()' as well.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Link: https://msgid.link/20240517153332.18271-2-dmantipov@yandex.ru
[improve (imho) indentation a bit]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 14:19:47 +01:00
..
aead_api.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
aead_api.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
aes_ccm.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
aes_cmac.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
aes_cmac.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
aes_gcm.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
aes_gmac.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
aes_gmac.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
agg-rx.c Backport mac80211 patches from linux-6.1.y 2024-06-15 16:29:20 -03:00
agg-tx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
airtime.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cfg.c wifi: mac80211: check/clear fast rx for non-4addr sta VLAN changes 2024-11-19 09:22:41 +01:00
chan.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
debug.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
debugfs.c Backport mac80211 patches from linux-6.1.y 2024-06-15 16:29:20 -03:00
debugfs.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
debugfs_key.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
debugfs_key.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
debugfs_netdev.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
debugfs_netdev.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
debugfs_sta.c Backport mac80211 patches from linux-6.1.y 2024-06-15 16:29:20 -03:00
debugfs_sta.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
driver-ops.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
driver-ops.h Backport mac80211 patches from linux-6.1.y 2024-06-15 16:29:20 -03:00
ethtool.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fils_aead.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fils_aead.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
he.c wifi: mac80211: correctly parse Spatial Reuse Parameter Set element 2024-11-19 14:19:00 +01:00
ht.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ibss.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ieee80211_i.h wifi: mac80211: fix ieee80211_bss_*_flags kernel-doc 2024-11-19 11:32:43 +01:00
iface.c kcov: Remove kcov include from sched.h and move it to its users. 2024-11-19 11:32:46 +01:00
Kconfig Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
key.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
key.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
led.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
led.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
main.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mesh.c wifi: mac80211: mesh: init nonpeer_pm to active by default in mesh sdata 2024-11-19 14:19:47 +01:00
mesh.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mesh_hwmp.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mesh_pathtbl.c wifi: mac80211: mesh: Fix leak of mesh_preq_queue objects 2024-11-19 14:19:00 +01:00
mesh_plink.c wifi: mac80211: mesh_plink: fix matches_local logic 2024-11-18 12:11:58 +01:00
mesh_ps.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mesh_sync.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
michael.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
michael.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mlme.c Backport mac80211 patches from linux-6.1.y 2024-06-15 16:29:20 -03:00
ocb.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
offchannel.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rate.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rate.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rc80211_minstrel.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rc80211_minstrel.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rc80211_minstrel_debugfs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rc80211_minstrel_ht.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rc80211_minstrel_ht.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rc80211_minstrel_ht_debugfs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rx.c kcov: Remove kcov include from sched.h and move it to its users. 2024-11-19 11:32:46 +01:00
s1g.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scan.c wifi: mac80211: fix UBSAN noise in ieee80211_prep_hw_scan() 2024-11-19 14:19:47 +01:00
spectmgmt.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sta_info.c wifi: mac80211: Fix deadlock in ieee80211_sta_ps_deliver_wakeup() 2024-11-19 14:19:00 +01:00
sta_info.h Backport mac80211 patches from linux-6.1.y 2024-06-15 16:29:20 -03:00
status.c Backport mac80211 patches from linux-6.1.y 2024-06-15 16:29:20 -03:00
tdls.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tkip.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tkip.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
trace.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
trace.h Backport mac80211 patches from linux-6.1.y 2024-06-15 16:29:20 -03:00
trace_msg.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tx.c wifi: mac80211: fix race condition on enabling fast-xmit 2024-11-18 22:25:32 +01:00
util.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vht.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
wep.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
wep.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
wme.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
wme.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
wpa.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
wpa.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00