* [PATCH] net: gue: reject invalid REMCSUM offsets
@ 2026-08-20 22:02 Jérémy Jean
2026-08-24 12:27 ` Simon Horman
0 siblings, 1 reply; 3+ messages in thread
From: Jérémy Jean @ 2026-08-20 22:02 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, netdev, linux-kernel, Jérémy Jean
The REMCSUM option carries an absolute checksum start and checksum field
offset. gue_remcsum() passes them to skb_remcsum_process(), whose
partial path stores offset - start in the u16 skb->csum_offset. If
offset is less than start, this underflows (for example, 1/0 becomes
0xffff).
A forwarded packet can retain CHECKSUM_PARTIAL and reach a
NETIF_F_HW_CSUM driver which trusts the metadata, leading
skb_copy_and_csum_dev() to write two bytes about 64 KiB beyond the
destination buffer.
Reject reversed tuples in both normal and GRO receive paths.
Fixes: fe881ef11cf0 ("gue: Use checksum partial with remote checksum offload")
Assisted-by: Codex:gpt-5
Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
---
net/ipv4/fou_core.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/ipv4/fou_core.c b/net/ipv4/fou_core.c
index ab09dfcdecbd..c4b8b7293994 100644
--- a/net/ipv4/fou_core.c
+++ b/net/ipv4/fou_core.c
@@ -97,6 +97,9 @@ static struct guehdr *gue_remcsum(struct sk_buff *skb, struct guehdr *guehdr,
size_t plen = sizeof(struct udphdr) + hdrlen +
max_t(size_t, offset + sizeof(u16), start);
+ if (unlikely(offset < start))
+ return NULL;
+
if (skb->remcsum_offload)
return guehdr;
@@ -308,6 +311,9 @@ static struct guehdr *gue_gro_remcsum(struct sk_buff *skb, unsigned int off,
size_t start = ntohs(pd[0]);
size_t offset = ntohs(pd[1]);
+ if (unlikely(offset < start))
+ return NULL;
+
if (skb->remcsum_offload)
return guehdr;
--
2.47.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: gue: reject invalid REMCSUM offsets
2026-08-20 22:02 [PATCH] net: gue: reject invalid REMCSUM offsets Jérémy Jean
@ 2026-08-24 12:27 ` Simon Horman
2026-08-24 13:38 ` Eric Dumazet
0 siblings, 1 reply; 3+ messages in thread
From: Simon Horman @ 2026-08-24 12:27 UTC (permalink / raw)
To: Jérémy Jean
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
netdev, linux-kernel
On Thu, Aug 20, 2026 at 10:02:10PM +0000, Jérémy Jean wrote:
> The REMCSUM option carries an absolute checksum start and checksum field
> offset. gue_remcsum() passes them to skb_remcsum_process(), whose
> partial path stores offset - start in the u16 skb->csum_offset. If
> offset is less than start, this underflows (for example, 1/0 becomes
> 0xffff).
>
> A forwarded packet can retain CHECKSUM_PARTIAL and reach a
> NETIF_F_HW_CSUM driver which trusts the metadata, leading
> skb_copy_and_csum_dev() to write two bytes about 64 KiB beyond the
> destination buffer.
>
> Reject reversed tuples in both normal and GRO receive paths.
>
> Fixes: fe881ef11cf0 ("gue: Use checksum partial with remote checksum offload")
> Assisted-by: Codex:gpt-5
> Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: gue: reject invalid REMCSUM offsets
2026-08-24 12:27 ` Simon Horman
@ 2026-08-24 13:38 ` Eric Dumazet
0 siblings, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2026-08-24 13:38 UTC (permalink / raw)
To: Simon Horman
Cc: Jérémy Jean, David S. Miller, Jakub Kicinski,
Paolo Abeni, netdev, linux-kernel
On Mon, Aug 24, 2026 at 2:27 PM Simon Horman <horms@kernel.org> wrote:
>
> On Thu, Aug 20, 2026 at 10:02:10PM +0000, Jérémy Jean wrote:
> > The REMCSUM option carries an absolute checksum start and checksum field
> > offset. gue_remcsum() passes them to skb_remcsum_process(), whose
> > partial path stores offset - start in the u16 skb->csum_offset. If
> > offset is less than start, this underflows (for example, 1/0 becomes
> > 0xffff).
> >
> > A forwarded packet can retain CHECKSUM_PARTIAL and reach a
> > NETIF_F_HW_CSUM driver which trusts the metadata, leading
> > skb_copy_and_csum_dev() to write two bytes about 64 KiB beyond the
> > destination buffer.
> >
> > Reject reversed tuples in both normal and GRO receive paths.
> >
> > Fixes: fe881ef11cf0 ("gue: Use checksum partial with remote checksum offload")
> > Assisted-by: Codex:gpt-5
> > Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
>
> Reviewed-by: Simon Horman <horms@kernel.org>
Patch looks fine. I wonder if it would make sense to catch the issue earlier in
a single place ( validate_gue_flags())
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-24 13:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-20 22:02 [PATCH] net: gue: reject invalid REMCSUM offsets Jérémy Jean
2026-08-24 12:27 ` Simon Horman
2026-08-24 13:38 ` Eric Dumazet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®