linux/net
Gustavo A. R. Silva 8e0a94e31a wifi: wext-core: Fix -Wstringop-overflow warning in ioctl_standard_iw_point()
[ Upstream commit 71e7552c90 ]

-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-07-27 08:50:35 +02:00
..
6lowpan
9p
802
8021q
appletalk
atm
ax25
batman-adv batman-adv: Broken sync while rescheduling delayed work 2023-06-14 11:15:23 +02:00
bluetooth Bluetooth: MGMT: Fix marking SCAN_RSP as not connectable 2023-07-19 16:22:02 +02:00
bpf
bpfilter
bridge net: bridge: keep ports without IFF_UNICAST_FLT in BR_PROMISC mode 2023-07-19 16:22:04 +02:00
caif
can can: bcm: Fix UAF in bcm_proc_show() 2023-07-27 08:50:27 +02:00
ceph libceph: harden msgr2.1 frame segment length checks 2023-07-23 13:49:41 +02:00
core devlink: report devlink_port_type_warn source device 2023-07-27 08:50:35 +02:00
dcb
dccp
dns_resolver
dsa net: dsa: sja1105: always enable the send_meta options 2023-07-19 16:22:06 +02:00
ethernet
ethtool
hsr
ieee802154
ife
ipv4 bpf: tcp: Avoid taking fast sock lock in iterator 2023-07-27 08:50:34 +02:00
ipv6 ipv6/addrconf: fix a potential refcount underflow for idev 2023-07-23 13:49:24 +02:00
iucv
kcm
key
l2tp
l3mdev
lapb
llc
mac80211 wifi: mac80211: Remove "Missing iftype sband data/EHT cap" spam 2023-07-19 16:21:09 +02:00
mac802154
mctp
mpls
mptcp mptcp: ensure listener is unhashed before updating the sk status 2023-07-01 13:16:22 +02:00
ncsi net/ncsi: change from ndo_set_mac_address to dev_set_mac_address 2023-07-23 13:49:51 +02:00
netfilter netfilter: nf_tables: prevent OOB access in nft_byteorder_eval 2023-07-19 16:22:17 +02:00
netlabel
netlink netlink: Add __sock_i_ino() for __netlink_diag_dump(). 2023-07-19 16:21:13 +02:00
netrom
nfc net: nfc: Fix use-after-free caused by nfc_llcp_find_local 2023-07-19 16:21:13 +02:00
nsh
openvswitch
packet
phonet
psample
qrtr
rds
rfkill
rose
rxrpc
sched net/sched: sch_qfq: reintroduce lmax bound check for MTU 2023-07-23 13:49:50 +02:00
sctp sctp: fix potential deadlock on &net->sctp.addr_wq_lock 2023-07-19 16:22:00 +02:00
smc
strparser
sunrpc SUNRPC: Fix UAF in svc_tcp_listen_data_ready() 2023-07-19 16:21:48 +02:00
switchdev
tipc net: tipc: resize nlattr array to correct size 2023-06-21 16:01:02 +02:00
tls
unix
vmw_vsock
wireless wifi: wext-core: Fix -Wstringop-overflow warning in ioctl_standard_iw_point() 2023-07-27 08:50:35 +02:00
x25
xdp xsk: Honor SO_BINDTODEVICE on bind 2023-07-19 16:22:05 +02:00
xfrm xfrm: Ensure policies always checked on XFRM-I input path 2023-06-28 11:12:28 +02:00
compat.c
devres.c
Kconfig
Kconfig.debug
Makefile
socket.c
sysctl_net.c