android_kernel_motorola_sm6225/net/wireless
Gustavo A. R. Silva 4c9eba4a39 wifi: wext-core: Fix -Wstringop-overflow warning in ioctl_standard_iw_point()
[ Upstream commit 71e7552c90db2a2767f5c17c7ec72296b0d92061 ]

-Wstringop-overflow is legitimately warning us about extra_size
pontentially being zero at some point, hence potenially ending
up _allocating_ zero bytes of memory for extra pointer and then
trying to access such object in a call to copy_from_user().

Fix this by adding a sanity check to ensure we never end up
trying to allocate zero bytes of data for extra pointer, before
continue executing the rest of the code in the function.

Address the following -Wstringop-overflow warning seen when built
m68k architecture with allyesconfig configuration:
                 from net/wireless/wext-core.c:11:
In function '_copy_from_user',
    inlined from 'copy_from_user' at include/linux/uaccess.h:183:7,
    inlined from 'ioctl_standard_iw_point' at net/wireless/wext-core.c:825:7:
arch/m68k/include/asm/string.h:48:25: warning: '__builtin_memset' writing 1 or more bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]
   48 | #define memset(d, c, n) __builtin_memset(d, c, n)
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:153:17: note: in expansion of macro 'memset'
  153 |                 memset(to + (n - res), 0, res);
      |                 ^~~~~~
In function 'kmalloc',
    inlined from 'kzalloc' at include/linux/slab.h:694:9,
    inlined from 'ioctl_standard_iw_point' at net/wireless/wext-core.c:819:10:
include/linux/slab.h:577:16: note: at offset 1 into destination object of size 0 allocated by '__kmalloc'
  577 |         return __kmalloc(size, flags);
      |                ^~~~~~~~~~~~~~~~~~~~~~

This help with the ongoing efforts to globally enable
-Wstringop-overflow.

Link: https://github.com/KSPP/linux/issues/315
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/ZItSlzvIpjdjNfd8@work
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-08-11 11:45:25 +02:00
..
certs
.gitignore
ap.c
chan.c
core.c cfg80211: set custom regdomain after wiphy registration 2022-06-06 08:24:20 +02:00
core.h nl80211: validate key indexes for cfg80211_registered_device 2021-06-10 13:24:04 +02:00
debugfs.c wifi: cfg80211: debugfs: fix return type in ht40allow_map_read() 2022-09-15 12:17:02 +02:00
debugfs.h
ethtool.c cfg80211: check wiphy driver existence for drvinfo report 2020-03-05 16:42:13 +01:00
ibss.c
Kconfig
lib80211.c
lib80211_crypt_ccmp.c
lib80211_crypt_tkip.c
lib80211_crypt_wep.c
Makefile cfg80211: make certificate generation more robust 2021-06-30 08:48:25 -04:00
mesh.c
mlme.c
nl80211.c nl80211: show SSID for P2P_GO interfaces 2022-06-14 16:59:19 +02:00
nl80211.h
ocb.c
of.c
radiotap.c
rdev-ops.h cfg80211: Fix radar event during another phy CAC 2020-02-05 14:43:46 +00:00
reg.c wifi: cfg80211: Fix not unregister reg_pdev when load_builtin_regdb_keys() fails 2023-01-18 11:30:14 +01:00
reg.h
scan.c cfg80211: Fix possible memory leak in function cfg80211_bss_update 2021-08-04 12:23:45 +02:00
sme.c wifi: cfg80211: Partial revert "wifi: cfg80211: Fix use after free for wext" 2023-03-13 10:17:15 +01:00
sysfs.c
sysfs.h
trace.c
trace.h cfg80211: Fix radar event during another phy CAC 2020-02-05 14:43:46 +00:00
util.c cfg80211: call cfg80211_stop_ap when switch from P2P_GO type 2021-11-26 11:36:24 +01:00
wext-compat.c
wext-compat.h
wext-core.c wifi: wext-core: Fix -Wstringop-overflow warning in ioctl_standard_iw_point() 2023-08-11 11:45:25 +02:00
wext-priv.c
wext-proc.c
wext-sme.c
wext-spy.c wireless: wext-spy: Fix out-of-bounds warning 2021-07-20 16:16:02 +02:00