* [PATCH] net/ipv6: ioam6: prevent schema length wraparound in trace fill
@ 2026-03-25 7:41 Pengpeng Hou
2026-03-26 14:05 ` Justin Iurman
0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-03-25 7:41 UTC (permalink / raw)
To: Justin Iurman, David S . Miller, David Ahern, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, netdev, linux-kernel, pengpeng
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")
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
net/ipv6/ioam6.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/ipv6/ioam6.c b/net/ipv6/ioam6.c
index b76f89d92e7b..3978773bec42 100644
--- a/net/ipv6/ioam6.c
+++ b/net/ipv6/ioam6.c
@@ -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.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net/ipv6: ioam6: prevent schema length wraparound in trace fill
2026-03-25 7:41 [PATCH] net/ipv6: ioam6: prevent schema length wraparound in trace fill Pengpeng Hou
@ 2026-03-26 14:05 ` Justin Iurman
0 siblings, 0 replies; 2+ messages in thread
From: Justin Iurman @ 2026-03-26 14:05 UTC (permalink / raw)
To: Pengpeng Hou, David S . Miller, David Ahern, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, netdev, linux-kernel
On 3/25/26 08:41, Pengpeng Hou 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.
>
> 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.
Reviewed-by: Justin Iurman <justin.iurman@gmail.com>
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
> ---
> net/ipv6/ioam6.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/ipv6/ioam6.c b/net/ipv6/ioam6.c
> index b76f89d92e7b..3978773bec42 100644
> --- a/net/ipv6/ioam6.c
> +++ b/net/ipv6/ioam6.c
> @@ -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
> */
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-26 14:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-25 7:41 [PATCH] net/ipv6: ioam6: prevent schema length wraparound in trace fill Pengpeng Hou
2026-03-26 14:05 ` Justin Iurman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox