* [PATCH] scsi: libfc: Prevent integer overflow in fc_fcp_recv_data()
@ 2025-09-30 12:38 Dan Carpenter
2025-10-07 2:29 ` Martin K. Petersen
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2025-09-30 12:38 UTC (permalink / raw)
To: Robert Love
Cc: Hannes Reinecke, James E.J. Bottomley, Martin K. Petersen,
linux-scsi, linux-kernel, kernel-janitors
The "offset" comes from the skb->data that we received. Here the code is
verifying that "offset + len" is within bounds however it does not take
integer overflows into account. Use size_add() to be safe.
This would only be an issue on 32bit systems which are probably a very
small percent of the users. Still, it's worth fixing just for
correctness sake.
Fixes: 42e9a92fe6a9 ("[SCSI] libfc: A modular Fibre Channel library")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/scsi/libfc/fc_fcp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c
index 16d0f02af1e4..31d08c115521 100644
--- a/drivers/scsi/libfc/fc_fcp.c
+++ b/drivers/scsi/libfc/fc_fcp.c
@@ -503,7 +503,7 @@ static void fc_fcp_recv_data(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
host_bcode = FC_ERROR;
goto err;
}
- if (offset + len > fsp->data_len) {
+ if (size_add(offset, len) > fsp->data_len) {
/* this should never happen */
if ((fr_flags(fp) & FCPHF_CRC_UNCHECKED) &&
fc_frame_crc_check(fp))
--
2.51.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] scsi: libfc: Prevent integer overflow in fc_fcp_recv_data()
2025-09-30 12:38 [PATCH] scsi: libfc: Prevent integer overflow in fc_fcp_recv_data() Dan Carpenter
@ 2025-10-07 2:29 ` Martin K. Petersen
0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2025-10-07 2:29 UTC (permalink / raw)
To: Dan Carpenter
Cc: Robert Love, Hannes Reinecke, James E.J. Bottomley,
Martin K. Petersen, linux-scsi, linux-kernel, kernel-janitors
Dan,
> The "offset" comes from the skb->data that we received. Here the code
> is verifying that "offset + len" is within bounds however it does not
> take integer overflows into account. Use size_add() to be safe.
Applied to 6.18/scsi-staging, thanks!
--
Martin K. Petersen
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-10-07 2:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-30 12:38 [PATCH] scsi: libfc: Prevent integer overflow in fc_fcp_recv_data() Dan Carpenter
2025-10-07 2:29 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox