]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
wifi: wilc1000: avoid buffer overflow in WID string configuration
authorAjay.Kathat@microchip.com <Ajay.Kathat@microchip.com>
Fri, 29 Aug 2025 22:58:43 +0000 (22:58 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Sep 2025 09:16:41 +0000 (11:16 +0200)
commitae50f8562306a7ea1cf3c9722f97ee244f974729
tree4a42d4434cb84527dcd042b81dca4e8e1a988d99
parentd06a83038bd636a6002f83e6da6d3b75b550450b
wifi: wilc1000: avoid buffer overflow in WID string configuration

[ Upstream commit fe9e4d0c39311d0f97b024147a0d155333f388b5 ]

Fix the following copy overflow warning identified by Smatch checker.

 drivers/net/wireless/microchip/wilc1000/wlan_cfg.c:184 wilc_wlan_parse_response_frame()
        error: '__memcpy()' 'cfg->s[i]->str' copy overflow (512 vs 65537)

This patch introduces size check before accessing the memory buffer.
The checks are base on the WID type of received data from the firmware.
For WID string configuration, the size limit is determined by individual
element size in 'struct wilc_cfg_str_vals' that is maintained in 'len' field
of 'struct wilc_cfg_str'.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-wireless/aLFbr9Yu9j_TQTey@stanley.mountain
Suggested-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Link: https://patch.msgid.link/20250829225829.5423-1-ajay.kathat@microchip.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/microchip/wilc1000/wlan_cfg.c
drivers/net/wireless/microchip/wilc1000/wlan_cfg.h