linux-stable/net/wireless
Gustavo A. R. Silva 71e7552c90 wifi: wext-core: Fix -Wstringop-overflow warning in ioctl_standard_iw_point()
-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>
2023-06-19 12:05:27 +02:00
..
certs
.gitignore
ap.c wifi: nl80211: add MLO_LINK_ID to CMD_STOP_AP event 2023-02-14 12:09:17 +01:00
chan.c wifi: cfg80211: move puncturing bitmap validation from mac80211 2023-02-14 12:09:18 +01:00
core.c wifi: cfg80211: move scan done work to wiphy work 2023-06-07 19:53:37 +02:00
core.h wifi: cfg80211: move scan done work to wiphy work 2023-06-07 19:53:37 +02:00
debugfs.c wifi: cfg80211: debugfs: fix return type in ht40allow_map_read() 2022-08-25 10:04:46 +02:00
debugfs.h
ethtool.c wifi: cfg80211: use strscpy to replace strlcpy 2022-07-15 11:43:12 +02:00
ibss.c wifi: cfg80211: remove support for static WEP 2023-01-18 17:31:44 +01:00
Kconfig
lib80211.c
lib80211_crypt_ccmp.c wifi: use struct_group to copy addresses 2022-09-03 16:40:06 +02:00
lib80211_crypt_tkip.c
lib80211_crypt_wep.c
Makefile
mesh.c
mlme.c wifi: nl80211: Add support for randomizing TA of auth and deauth frames 2023-03-07 11:12:02 +01:00
nl80211.c wifi: cfg80211: Support association to AP MLD with disabled links 2023-06-14 12:21:17 +02:00
nl80211.h wifi: nl80211: add MLO_LINK_ID to CMD_STOP_AP event 2023-02-14 12:09:17 +01:00
ocb.c
of.c
pmsr.c wifi: cfg80211: hold wiphy lock in pmsr work 2023-06-07 19:53:07 +02:00
radiotap.c
rdev-ops.h wifi: cfg80211: fix link del callback to call correct handler 2023-06-09 13:30:16 +02:00
reg.c wifi: cfg80211: fix double lock bug in reg_wdev_chan_valid() 2023-06-09 13:28:41 +02:00
reg.h
scan.c wifi: cfg80211: move scan done work to wiphy work 2023-06-07 19:53:37 +02:00
sme.c wifi: cfg80211: hold wiphy lock in auto-disconnect 2023-06-07 19:53:04 +02:00
sysfs.c wifi: cfg80211: add a work abstraction with special semantics 2023-06-07 19:53:15 +02:00
sysfs.h
trace.c
trace.h wifi: cfg80211: replace strlcpy() with strscpy() 2023-06-14 12:32:19 +02:00
util.c Merge wireless into wireless-next 2023-06-19 12:04:16 +02:00
wext-compat.c wifi: cfg80211: remove support for static WEP 2023-01-18 17:31:44 +01:00
wext-compat.h wifi: cfg80211: Avoid clashing function prototypes 2022-11-16 11:31:47 +02:00
wext-core.c wifi: wext-core: Fix -Wstringop-overflow warning in ioctl_standard_iw_point() 2023-06-19 12:05:27 +02:00
wext-priv.c
wext-proc.c
wext-sme.c wifi: cfg80211: wext: hold wiphy lock in siwgenie 2023-06-07 19:53:11 +02:00
wext-spy.c