Skip to contentSkip to conversation

scsi: libfc: Prevent integer overflow in fc_fcp_recv_data()

PATCH Applied Dan Carpenter 2 participants 2 messages Sep 30, 2025 – Oct 7, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: libfc: Prevent integer overflow in fc_fcp_recv_data()

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")
---
 drivers/scsi/libfc/fc_fcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/libfc/fc_fcp.c +1 -1
index 16d0f02af1e4..31d08c115521 100644
@@ -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))
Signature · 1 line
2.51.0
#1 lore raw

Dan,

Quoted 3 lines

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!

Signature · 1 line
Martin K. Petersen