Skip to contentSkip to conversation

net/ipv6: ioam6: prevent schema length wraparound in trace fill

PATCH Applied Pengpeng Hou 3 participants 3 messages Mar 25 – Mar 27

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

PATCH 1/1 net/ipv6: ioam6: prevent schema length wraparound in trace fill

ioam6_fill_trace_data() stores the schema contribution to the trace length in a u8. With bit 22 enabled and the largest schema payload, sclen becomes 1 + 1020 / 4, wraps from 256 to 0, and bypasses the remaining-space check. __ioam6_fill_trace_data() then positions the write cursor without reserving the schema area but still copies the 4-byte schema header and the full schema payload, overrunning the trace buffer.

Keep sclen in an unsigned int so the remaining-space check and the write cursor calculation both see the full schema length.

Fixes 8c6f6fa67726 ("ipv6: ioam: IOAM Generic Netlink API")
---
 net/ipv6/ioam6.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv6/ioam6.c +2 -2
index b76f89d92e7b..3978773bec42 100644
@@ -708,7 +708,7 @@ static void __ioam6_fill_trace_data(struct sk_buff *skb,
 				    struct ioam6_namespace *ns,
 				    struct ioam6_trace_hdr *trace,
 				    struct ioam6_schema *sc,
-				    u8 sclen, bool is_input)
+				    unsigned int sclen, bool is_input)
 {
 	struct net_device *dev = skb_dst_dev(skb);
 	struct timespec64 ts;
@@ -939,7 +939,7 @@ void ioam6_fill_trace_data(struct sk_buff *skb,
 			   bool is_input)
 {
 	struct ioam6_schema *sc;
-	u8 sclen = 0;
+	unsigned int sclen = 0;
 
 	/* Skip if Overflow flag is set
 	 */
Signature · 1 line
2.50.1 (Apple Git-155)
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Pengpeng Hou

ioam6_fill_trace_data() stores the schema contribution to the trace length in a u8. With bit 22 enabled and the largest schema payload, sclen becomes 1 + 1020 / 4, wraps from 256 to 0, and bypasses the remaining-space check. __ioam6_fill_trace_data() then positions the write cursor without reserving the schema area but still copies the 4-byte schema header and the full schema payload, overrunning the trace buffer.

Quoted 4 lines

Keep sclen in an unsigned int so the remaining-space check and the write cursor calculation both see the full schema length.

Fixes 8c6f6fa67726 ("ipv6: ioam: IOAM Generic Netlink API")

... should be:

Fixes 9ee11f0fff20 ("ipv6: ioam: Data plane support for Pre-allocated Trace")

Respin needed? Otherwise, LGTM.

Quoted 27 lines
---
  net/ipv6/ioam6.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv6/ioam6.c +2 -2
index b76f89d92e7b..3978773bec42 100644
@@ -708,7 +708,7 @@ static void __ioam6_fill_trace_data(struct sk_buff *skb,
  				    struct ioam6_namespace *ns,
  				    struct ioam6_trace_hdr *trace,
  				    struct ioam6_schema *sc,
-				    u8 sclen, bool is_input)
+				    unsigned int sclen, bool is_input)
  {
  	struct net_device *dev = skb_dst_dev(skb);
  	struct timespec64 ts;
@@ -939,7 +939,7 @@ void ioam6_fill_trace_data(struct sk_buff *skb,
  			   bool is_input)
  {
  	struct ioam6_schema *sc;
-	u8 sclen = 0;
+	unsigned int sclen = 0;
 
  	/* Skip if Overflow flag is set
  	 */
#2 lore raw
In reply to Pengpeng Hou
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:

Quoted 9 lines · On Wed, 25 Mar 2026 15:41:52 +0800 you wrote:

ioam6_fill_trace_data() stores the schema contribution to the trace length in a u8. With bit 22 enabled and the largest schema payload, sclen becomes 1 + 1020 / 4, wraps from 256 to 0, and bypasses the remaining-space check. __ioam6_fill_trace_data() then positions the write cursor without reserving the schema area but still copies the 4-byte schema header and the full schema payload, overrunning the trace buffer.

[...]

Here is the summary with links:
- net/ipv6: ioam6: prevent schema length wraparound in trace fill

    https://git.kernel.org/netdev/net/c/5e67ba9bb531

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html