Skip to contentSkip to conversation

ice: iavf: fix USO for 32-bit systems

PATCH In review Magnus Karlsson 2 participants 5 messages Oct 29 – Nov 3

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

cover ice: iavf: fix USO for 32-bit systems

That USO works on these two cards for 64-bit systems is just pure luck. Currently, the computation of the UDP segmentation header is performed using sizeof() a pointer instead of the sizeof() the UDP header that the pointer points to. Since the UDP header happens to be 8 bytes long and a pointer is 8 bytes long on a 64-bit system, this works on all those systems. But no such luck for anyone using a 32-bit system as 8 bytes != 4 bytes. So fix this by using sizeof() the UDP header that the pointer points to instead.

This was found by an LLM while implementing something else that used USO.

v1: https://lore.kernel.org/netdev/[email protected]/
v1 -> v2:
- add missing prefixes on Fixes line (Eric)
- collected Reviewed-by tags from Eric and Maciej

Magnus Karlsson (2):
ice: fix USO for 32-bit systems
iavf: fix USO for 32-bit systems

 drivers/net/ethernet/intel/iavf/iavf_txrx.c | 2 +-
 drivers/net/ethernet/intel/ice/ice_txrx.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.38.1
#1 lore raw

PATCH 1/2 ice: fix USO for 32-bit systems

That USO works for 64-bit systems is just pure luck. Currently, the computation of the UDP segmentation header is performed using sizeof() a pointer instead of the sizeof() the UDP header that the pointer points to. Since the UDP header happens to be 8 bytes long and a pointer is 8 bytes long on a 64-bit system, this works on all those systems. But no such luck for anyone using a 32-bit system as 8 bytes != 4 bytes. So fix this by using sizeof() the UDP header that the pointer points to instead.

This was found by an LLM while implementing something else that used USO.

Fixes a54e3b8cffd6 ("ice: Support UDP segmentation offload")
---
 drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_txrx.c +1 -1
index a2c7c4962882..d9ea812c5c4e 100644
@@ -1925,7 +1925,7 @@ int ice_tso(struct ice_tx_buf *first, struct ice_tx_offload_params *off)
 		csum_replace_by_diff(&l4.udp->check,
 				     (__force __wsum)htonl(paylen));
 		/* compute length of UDP segmentation header */
-		off->header_len = (u8)sizeof(l4.udp) + l4_start;
+		off->header_len = sizeof(*l4.udp) + l4_start;
 	} else {
 		csum_replace_by_diff(&l4.tcp->check,
 				     (__force __wsum)htonl(paylen));
Signature · 1 line
2.38.1
Reviewed-by on v1 1/2
#2 lore raw

RE: [PATCH iwl-net 1/2] ice: fix USO for 32-bit systems

Quoted 46 lines

-----Original Message-----
From: Magnus Karlsson <[email protected]>
Sent: Thursday, October 29, 2026 11:02 AM
To: Karlsson, Magnus <[email protected]>; intel-wired- [email protected]; Nguyen, Anthony L <[email protected]>; Fijalkowski, Maciej <[email protected]>; Kitszel, Przemyslaw <[email protected]>
Cc: Eric Dumazet <[email protected]>
Subject: [PATCH iwl-net 1/2] ice: fix USO for 32-bit systems

That USO works for 64-bit systems is just pure luck. Currently, the computation of the UDP segmentation header is performed using sizeof() a pointer instead of the sizeof() the UDP header that the pointer points to. Since the UDP header happens to be 8 bytes long and a pointer is 8 bytes long on a 64-bit system, this works on all those systems. But no such luck for anyone using a 32-bit system as 8 bytes != 4 bytes. So fix this by using sizeof() the UDP header that the pointer points to instead.

This was found by an LLM while implementing something else that used USO.

Fixes a54e3b8cffd6 ("ice: Support UDP segmentation offload")
---
 drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_txrx.c +1 -1
index a2c7c4962882..d9ea812c5c4e 100644
@@ -1925,7 +1925,7 @@ int ice_tso(struct ice_tx_buf *first, struct
 ice_tx_offload_params *off)
 		csum_replace_by_diff(&l4.udp->check,
 				     (__force __wsum)htonl(paylen));
 		/* compute length of UDP segmentation header */
-		off->header_len = (u8)sizeof(l4.udp) + l4_start;
+		off->header_len = sizeof(*l4.udp) + l4_start;
 	} else {
 		csum_replace_by_diff(&l4.tcp->check,
Quoted 3 lines

(__force __wsum)htonl(paylen));
--
2.38.1

#3 lore raw

PATCH 2/2 iavf: fix USO for 32-bit systems

In reply to Magnus Karlsson

That USO works for 64-bit systems is just pure luck. Currently, the computation of the UDP segmentation header is performed using sizeof() a pointer instead of the sizeof() the UDP header that the pointer points to. Since the UDP header happens to be 8 bytes long and a pointer is 8 bytes long on a 64-bit system, this works on all those systems. But no such luck for anyone using a 32-bit system as 8 bytes != 4 bytes. So fix this by using sizeof() the UDP header that the pointer points to instead.

This was found by an LLM while implementing something else that used USO.

Fixes c91a4f9feb67 ("iavf: add support for UDP Segmentation Offload")
---
 drivers/net/ethernet/intel/iavf/iavf_txrx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_txrx.c +1 -1
index 8982cf75466f..2c290d7788d2 100644
@@ -1807,7 +1807,7 @@ static int iavf_tso(struct iavf_tx_buffer *first, u8 *hdr_len,
 		csum_replace_by_diff(&l4.udp->check,
 				     (__force __wsum)htonl(paylen));
 		/* compute length of UDP segmentation header */
-		*hdr_len = (u8)sizeof(l4.udp) + l4_offset;
+		*hdr_len = sizeof(*l4.udp) + l4_offset;
 	} else {
 		csum_replace_by_diff(&l4.tcp->check,
 				     (__force __wsum)htonl(paylen));
Signature · 1 line
2.38.1
Reviewed-by on v1 2/2
#4 lore raw

RE: [PATCH iwl-net 2/2] iavf: fix USO for 32-bit systems

Quoted 46 lines

-----Original Message-----
From: Magnus Karlsson <[email protected]>
Sent: Thursday, October 29, 2026 11:02 AM
To: Karlsson, Magnus <[email protected]>; intel-wired- [email protected]; Nguyen, Anthony L <[email protected]>; Fijalkowski, Maciej <[email protected]>; Kitszel, Przemyslaw <[email protected]>
Cc: Eric Dumazet <[email protected]>
Subject: [PATCH iwl-net 2/2] iavf: fix USO for 32-bit systems

That USO works for 64-bit systems is just pure luck. Currently, the computation of the UDP segmentation header is performed using sizeof() a pointer instead of the sizeof() the UDP header that the pointer points to. Since the UDP header happens to be 8 bytes long and a pointer is 8 bytes long on a 64-bit system, this works on all those systems. But no such luck for anyone using a 32-bit system as 8 bytes != 4 bytes. So fix this by using sizeof() the UDP header that the pointer points to instead.

This was found by an LLM while implementing something else that used USO.

Fixes c91a4f9feb67 ("iavf: add support for UDP Segmentation Offload")
---
 drivers/net/ethernet/intel/iavf/iavf_txrx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_txrx.c +1 -1
index 8982cf75466f..2c290d7788d2 100644
@@ -1807,7 +1807,7 @@ static int iavf_tso(struct iavf_tx_buffer *first,
 u8 *hdr_len,
 		csum_replace_by_diff(&l4.udp->check,
 				     (__force __wsum)htonl(paylen));
 		/* compute length of UDP segmentation header */
-		*hdr_len = (u8)sizeof(l4.udp) + l4_offset;
+		*hdr_len = sizeof(*l4.udp) + l4_offset;
 	} else {
 		csum_replace_by_diff(&l4.tcp->check,
Quoted 3 lines

(__force __wsum)htonl(paylen));
--
2.38.1