From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9BCA18A955; Wed, 25 Sep 2024 12:01:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727265684; cv=none; b=Woz+tVQmOW5f+up1jM74D7eL07E/Cziw9cxuZBmBPMPQpXPbqfwHQwLJenM2vJE98wmFVfXqFabkAxhzGJ78sk9aI3rHG3VHPe7aFgG/KHaBVUovinlwjK3ZF0BQCioscOxZAA19iZRpp+M5jUiWQyJHy/V4duZlQBbWnbmzCkI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727265684; c=relaxed/simple; bh=m6g1/T++F9gxi9y9LjBZx6JGGbo3MyCMDcOYnbkWviQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nweSa3Y0jPqQMYJitD9+wMdHKiHK5RdGjA89t0Gj5SaBTHfKKCBVlZQNJMnXxF2P+rHg5kP/eD6NVeGZTbqqS0bljoD4us5lcSVCM9Xd3oUx1j9by33oKtNlXnh/B8IrXmC/SdnPn12tVFXKpEJQeUHv/aNsqVhI+RQZOWoSnqs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rbF2vgrb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rbF2vgrb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C969DC4CEC3; Wed, 25 Sep 2024 12:01:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727265684; bh=m6g1/T++F9gxi9y9LjBZx6JGGbo3MyCMDcOYnbkWviQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rbF2vgrbQ0wZskk4i9/V1f/UH6aJz2vilsIkvwyqOiQPBwt7EMA6flsiZuvTbOvsW brzi8ZV4FhRDOJyv7XrOE/MySRpyNFmDb/Ym3neG79/n1fPqB3KsVChNzE6HPac6ZN xHnGL06mNwUYSWXHaIsveW/IJb29uDBSiWL+xSjSgm2z7GRop1vNNM5ffQgu019Tgd /SKQrMEI9iNX3Rn+5tYiNeGY6eg9DdgxuRpMFyA8cHXDVMjesqfsc1nleuZ4re7Uia 8tJ/CPnqco4mU1M61KxgLSSwQYY9Y2H75msqevvJItqYi4X5uVJgKHhmGOEIWtm99+ GGz5/0Ht742fA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Gustavo A. R. Silva" , Andy Shevchenko , Brian Norris , Kalle Valo , Sasha Levin , francesco.dolcini@toradex.com, yu-hao.lin@nxp.com, kees@kernel.org, johannes.berg@intel.com, dmantipov@yandex.ru, linux-wireless@vger.kernel.org Subject: [PATCH AUTOSEL 6.10 070/197] wifi: mwifiex: Fix memcpy() field-spanning write warning in mwifiex_cmd_802_11_scan_ext() Date: Wed, 25 Sep 2024 07:51:29 -0400 Message-ID: <20240925115823.1303019-70-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240925115823.1303019-1-sashal@kernel.org> References: <20240925115823.1303019-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.10.11 Content-Transfer-Encoding: 8bit From: "Gustavo A. R. Silva" [ Upstream commit 498365e52bebcbc36a93279fe7e9d6aec8479cee ] Replace one-element array with a flexible-array member in `struct host_cmd_ds_802_11_scan_ext`. With this, fix the following warning: elo 16 17:51:58 surfacebook kernel: ------------[ cut here ]------------ elo 16 17:51:58 surfacebook kernel: memcpy: detected field-spanning write (size 243) of single field "ext_scan->tlv_buffer" at drivers/net/wireless/marvell/mwifiex/scan.c:2239 (size 1) elo 16 17:51:58 surfacebook kernel: WARNING: CPU: 0 PID: 498 at drivers/net/wireless/marvell/mwifiex/scan.c:2239 mwifiex_cmd_802_11_scan_ext+0x83/0x90 [mwifiex] Reported-by: Andy Shevchenko Closes: https://lore.kernel.org/linux-hardening/ZsZNgfnEwOcPdCly@black.fi.intel.com/ Signed-off-by: Gustavo A. R. Silva Reviewed-by: Andy Shevchenko Acked-by: Brian Norris Signed-off-by: Kalle Valo Link: https://patch.msgid.link/ZsZa5xRcsLq9D+RX@elsanto Signed-off-by: Sasha Levin --- drivers/net/wireless/marvell/mwifiex/fw.h | 2 +- drivers/net/wireless/marvell/mwifiex/scan.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/fw.h b/drivers/net/wireless/marvell/mwifiex/fw.h index 3adc447b715f6..5b072120e3f21 100644 --- a/drivers/net/wireless/marvell/mwifiex/fw.h +++ b/drivers/net/wireless/marvell/mwifiex/fw.h @@ -1587,7 +1587,7 @@ struct host_cmd_ds_802_11_scan_rsp { struct host_cmd_ds_802_11_scan_ext { u32 reserved; - u8 tlv_buffer[1]; + u8 tlv_buffer[]; } __packed; struct mwifiex_ie_types_bss_mode { diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c index 0326b121747cb..17ce84f5207e3 100644 --- a/drivers/net/wireless/marvell/mwifiex/scan.c +++ b/drivers/net/wireless/marvell/mwifiex/scan.c @@ -2530,8 +2530,7 @@ int mwifiex_ret_802_11_scan_ext(struct mwifiex_private *priv, ext_scan_resp = &resp->params.ext_scan; tlv = (void *)ext_scan_resp->tlv_buffer; - buf_left = le16_to_cpu(resp->size) - (sizeof(*ext_scan_resp) + S_DS_GEN - - 1); + buf_left = le16_to_cpu(resp->size) - (sizeof(*ext_scan_resp) + S_DS_GEN); while (buf_left >= sizeof(struct mwifiex_ie_types_header)) { type = le16_to_cpu(tlv->type); -- 2.43.0