* [PATCH] wifi: libertas_tf: validate firmware block extents
@ 2026-08-30 12:48 Pengpeng Hou
0 siblings, 0 replies; only message in thread
From: Pengpeng Hou @ 2026-08-30 12:48 UTC (permalink / raw)
To: linux-wireless; +Cc: Pengpeng Hou, libertas-dev, linux-kernel
check_fwfile_format() reads each block header and trusts its data length
before proving that both fit in the firmware image. A truncated header or
oversized block can therefore pass malformed extents to the download path.
Require the remaining image to contain the complete header and payload
before accepting each block.
Fixes: c305a19a0d0a ("libertas_tf: usb specific functions")
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
drivers/net/wireless/marvell/libertas_tf/if_usb.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/marvell/libertas_tf/if_usb.c b/drivers/net/wireless/marvell/libertas_tf/if_usb.c
index b85c6d783bf7b..b9d1a33bddfce 100644
--- a/drivers/net/wireless/marvell/libertas_tf/if_usb.c
+++ b/drivers/net/wireless/marvell/libertas_tf/if_usb.c
@@ -769,10 +769,18 @@ static int check_fwfile_format(const u8 *data, u32 totlen)
exit = len = 0;
do {
- struct fwheader *fwh = (void *) data;
+ struct fwheader *fwh;
+
+ if (totlen - len < sizeof(*fwh))
+ break;
+
+ fwh = (void *)data;
bincmd = le32_to_cpu(fwh->dnldcmd);
blksize = le32_to_cpu(fwh->datalength);
+ if (blksize > totlen - len - sizeof(*fwh))
+ break;
+
switch (bincmd) {
case FW_HAS_DATA_TO_RECV:
offset = sizeof(struct fwheader) + blksize;
base-commit: 08dbfad3f5040f5bdb6c529da20d6d4e81fefd72
--
2.50.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-30 12:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-30 12:48 [PATCH] wifi: libertas_tf: validate firmware block extents Pengpeng Hou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox