* [PATCH v2 net 1/3] gue: Fix skb memleak with inner IP protocol 0.
2026-01-15 17:24 [PATCH v2 net 0/3] fou/gue: Fix skb memleak with inner protocol 0 Kuniyuki Iwashima
@ 2026-01-15 17:24 ` Kuniyuki Iwashima
2026-01-15 17:24 ` [PATCH v2 net 2/3] tools: ynl: Specify --no-line-number in ynl-regen.sh Kuniyuki Iwashima
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Kuniyuki Iwashima @ 2026-01-15 17:24 UTC (permalink / raw)
To: David S . Miller, David Ahern, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Simon Horman, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev,
syzbot+4d8c7d16b0e95c0d0f0d
syzbot reported skb memleak below. [0]
The repro generated a GUE packet with its inner protocol 0.
gue_udp_recv() returns -guehdr->proto_ctype for "resubmit"
in ip_protocol_deliver_rcu(), but this only works with
non-zero protocol number.
Let's drop such packets.
Note that 0 is a valid number (IPv6 Hop-by-Hop Option).
I think it is not practical to encap HOPOPT in GUE, so once
someone starts to complain, we could pass down a resubmit
flag pointer to distinguish two zeros from the upper layer:
* no error
* resubmit HOPOPT
[0]
BUG: memory leak
unreferenced object 0xffff888109695a00 (size 240):
comm "syz.0.17", pid 6088, jiffies 4294943096
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 40 c2 10 81 88 ff ff 00 00 00 00 00 00 00 00 .@..............
backtrace (crc a84b336f):
kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
slab_post_alloc_hook mm/slub.c:4958 [inline]
slab_alloc_node mm/slub.c:5263 [inline]
kmem_cache_alloc_noprof+0x3b4/0x590 mm/slub.c:5270
__build_skb+0x23/0x60 net/core/skbuff.c:474
build_skb+0x20/0x190 net/core/skbuff.c:490
__tun_build_skb drivers/net/tun.c:1541 [inline]
tun_build_skb+0x4a1/0xa40 drivers/net/tun.c:1636
tun_get_user+0xc12/0x2030 drivers/net/tun.c:1770
tun_chr_write_iter+0x71/0x120 drivers/net/tun.c:1999
new_sync_write fs/read_write.c:593 [inline]
vfs_write+0x45d/0x710 fs/read_write.c:686
ksys_write+0xa7/0x170 fs/read_write.c:738
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xa4/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Fixes: 37dd0247797b1 ("gue: Receive side for Generic UDP Encapsulation")
Reported-by: syzbot+4d8c7d16b0e95c0d0f0d@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/netdev/6965534b.050a0220.38aacd.0001.GAE@google.com/
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
---
net/ipv4/fou_core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/ipv4/fou_core.c b/net/ipv4/fou_core.c
index 3970b6b7ace5..ab8f309f8925 100644
--- a/net/ipv4/fou_core.c
+++ b/net/ipv4/fou_core.c
@@ -215,6 +215,9 @@ static int gue_udp_recv(struct sock *sk, struct sk_buff *skb)
return gue_control_message(skb, guehdr);
proto_ctype = guehdr->proto_ctype;
+ if (unlikely(!proto_ctype))
+ goto drop;
+
__skb_pull(skb, sizeof(struct udphdr) + hdrlen);
skb_reset_transport_header(skb);
--
2.52.0.457.g6b5491de43-goog
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v2 net 2/3] tools: ynl: Specify --no-line-number in ynl-regen.sh.
2026-01-15 17:24 [PATCH v2 net 0/3] fou/gue: Fix skb memleak with inner protocol 0 Kuniyuki Iwashima
2026-01-15 17:24 ` [PATCH v2 net 1/3] gue: Fix skb memleak with inner IP " Kuniyuki Iwashima
@ 2026-01-15 17:24 ` Kuniyuki Iwashima
2026-01-15 17:31 ` Eric Dumazet
2026-01-15 17:24 ` [PATCH v2 net 3/3] fou: Don't allow 0 for FOU_ATTR_IPPROTO Kuniyuki Iwashima
2026-01-19 14:18 ` [PATCH v2 net 0/3] fou/gue: Fix skb memleak with inner protocol 0 patchwork-bot+netdevbpf
3 siblings, 1 reply; 7+ messages in thread
From: Kuniyuki Iwashima @ 2026-01-15 17:24 UTC (permalink / raw)
To: David S . Miller, David Ahern, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Simon Horman, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev
If grep.lineNumber is enabled in .gitconfig,
[grep]
lineNumber = true
ynl-regen.sh fails with the following error:
$ ./tools/net/ynl/ynl-regen.sh -f
...
ynl_gen_c.py: error: argument --mode: invalid choice: '4:' (choose from user, kernel, uapi)
GEN 4: net/ipv4/fou_nl.c
Let's specify --no-line-number explicitly.
Fixes: be5bea1cc0bf ("net: add basic C code generators for Netlink")
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
tools/net/ynl/ynl-regen.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/net/ynl/ynl-regen.sh b/tools/net/ynl/ynl-regen.sh
index 81b4ecd89100..d9809276db98 100755
--- a/tools/net/ynl/ynl-regen.sh
+++ b/tools/net/ynl/ynl-regen.sh
@@ -21,7 +21,7 @@ files=$(git grep --files-with-matches '^/\* YNL-GEN \(kernel\|uapi\|user\)')
for f in $files; do
# params: 0 1 2 3
# $YAML YNL-GEN kernel $mode
- params=( $(git grep -B1 -h '/\* YNL-GEN' $f | sed 's@/\*\(.*\)\*/@\1@') )
+ params=( $(git grep --no-line-number -B1 -h '/\* YNL-GEN' $f | sed 's@/\*\(.*\)\*/@\1@') )
args=$(sed -n 's@/\* YNL-ARG \(.*\) \*/@\1@p' $f)
if [ $f -nt ${params[0]} -a -z "$force" ]; then
--
2.52.0.457.g6b5491de43-goog
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v2 net 2/3] tools: ynl: Specify --no-line-number in ynl-regen.sh.
2026-01-15 17:24 ` [PATCH v2 net 2/3] tools: ynl: Specify --no-line-number in ynl-regen.sh Kuniyuki Iwashima
@ 2026-01-15 17:31 ` Eric Dumazet
0 siblings, 0 replies; 7+ messages in thread
From: Eric Dumazet @ 2026-01-15 17:31 UTC (permalink / raw)
To: Kuniyuki Iwashima
Cc: David S . Miller, David Ahern, Jakub Kicinski, Paolo Abeni,
Simon Horman, Kuniyuki Iwashima, netdev
On Thu, Jan 15, 2026 at 6:25 PM Kuniyuki Iwashima <kuniyu@google.com> wrote:
>
> If grep.lineNumber is enabled in .gitconfig,
>
> [grep]
> lineNumber = true
>
> ynl-regen.sh fails with the following error:
>
> $ ./tools/net/ynl/ynl-regen.sh -f
> ...
> ynl_gen_c.py: error: argument --mode: invalid choice: '4:' (choose from user, kernel, uapi)
> GEN 4: net/ipv4/fou_nl.c
>
> Let's specify --no-line-number explicitly.
Reviewed-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 net 3/3] fou: Don't allow 0 for FOU_ATTR_IPPROTO.
2026-01-15 17:24 [PATCH v2 net 0/3] fou/gue: Fix skb memleak with inner protocol 0 Kuniyuki Iwashima
2026-01-15 17:24 ` [PATCH v2 net 1/3] gue: Fix skb memleak with inner IP " Kuniyuki Iwashima
2026-01-15 17:24 ` [PATCH v2 net 2/3] tools: ynl: Specify --no-line-number in ynl-regen.sh Kuniyuki Iwashima
@ 2026-01-15 17:24 ` Kuniyuki Iwashima
2026-01-15 17:27 ` Eric Dumazet
2026-01-19 14:18 ` [PATCH v2 net 0/3] fou/gue: Fix skb memleak with inner protocol 0 patchwork-bot+netdevbpf
3 siblings, 1 reply; 7+ messages in thread
From: Kuniyuki Iwashima @ 2026-01-15 17:24 UTC (permalink / raw)
To: David S . Miller, David Ahern, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Simon Horman, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev
fou_udp_recv() has the same problem mentioned in the previous
patch.
If FOU_ATTR_IPPROTO is set to 0, skb is not freed by
fou_udp_recv() nor "resubmit"-ted in ip_protocol_deliver_rcu().
Let's forbid 0 for FOU_ATTR_IPPROTO.
Fixes: 23461551c0062 ("fou: Support for foo-over-udp RX path")
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
v2:
* Updated ynl spec and generated fou_nl.c (Jakub)
---
Documentation/netlink/specs/fou.yaml | 2 ++
net/ipv4/fou_nl.c | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/Documentation/netlink/specs/fou.yaml b/Documentation/netlink/specs/fou.yaml
index 8e7974ec453f..331f1b342b3a 100644
--- a/Documentation/netlink/specs/fou.yaml
+++ b/Documentation/netlink/specs/fou.yaml
@@ -39,6 +39,8 @@ attribute-sets:
-
name: ipproto
type: u8
+ checks:
+ min: 1
-
name: type
type: u8
diff --git a/net/ipv4/fou_nl.c b/net/ipv4/fou_nl.c
index 7a99639204b1..309d5ba983d0 100644
--- a/net/ipv4/fou_nl.c
+++ b/net/ipv4/fou_nl.c
@@ -15,7 +15,7 @@
const struct nla_policy fou_nl_policy[FOU_ATTR_IFINDEX + 1] = {
[FOU_ATTR_PORT] = { .type = NLA_BE16, },
[FOU_ATTR_AF] = { .type = NLA_U8, },
- [FOU_ATTR_IPPROTO] = { .type = NLA_U8, },
+ [FOU_ATTR_IPPROTO] = NLA_POLICY_MIN(NLA_U8, 1),
[FOU_ATTR_TYPE] = { .type = NLA_U8, },
[FOU_ATTR_REMCSUM_NOPARTIAL] = { .type = NLA_FLAG, },
[FOU_ATTR_LOCAL_V4] = { .type = NLA_U32, },
--
2.52.0.457.g6b5491de43-goog
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v2 net 3/3] fou: Don't allow 0 for FOU_ATTR_IPPROTO.
2026-01-15 17:24 ` [PATCH v2 net 3/3] fou: Don't allow 0 for FOU_ATTR_IPPROTO Kuniyuki Iwashima
@ 2026-01-15 17:27 ` Eric Dumazet
0 siblings, 0 replies; 7+ messages in thread
From: Eric Dumazet @ 2026-01-15 17:27 UTC (permalink / raw)
To: Kuniyuki Iwashima
Cc: David S . Miller, David Ahern, Jakub Kicinski, Paolo Abeni,
Simon Horman, Kuniyuki Iwashima, netdev
On Thu, Jan 15, 2026 at 6:25 PM Kuniyuki Iwashima <kuniyu@google.com> wrote:
>
> fou_udp_recv() has the same problem mentioned in the previous
> patch.
>
> If FOU_ATTR_IPPROTO is set to 0, skb is not freed by
> fou_udp_recv() nor "resubmit"-ted in ip_protocol_deliver_rcu().
>
> Let's forbid 0 for FOU_ATTR_IPPROTO.
>
> Fixes: 23461551c0062 ("fou: Support for foo-over-udp RX path")
> Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
> ---
Reviewed-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 net 0/3] fou/gue: Fix skb memleak with inner protocol 0.
2026-01-15 17:24 [PATCH v2 net 0/3] fou/gue: Fix skb memleak with inner protocol 0 Kuniyuki Iwashima
` (2 preceding siblings ...)
2026-01-15 17:24 ` [PATCH v2 net 3/3] fou: Don't allow 0 for FOU_ATTR_IPPROTO Kuniyuki Iwashima
@ 2026-01-19 14:18 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-19 14:18 UTC (permalink / raw)
To: Kuniyuki Iwashima
Cc: davem, dsahern, edumazet, kuba, pabeni, horms, kuni1840, netdev
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 15 Jan 2026 17:24:45 +0000 you wrote:
> syzbot reported memleak for a GUE packet with its inner
> protocol number 0.
>
> Patch 1 fixes the issue, and patch 3 fixes the same issue
> in FOU.
>
>
> [...]
Here is the summary with links:
- [v2,net,1/3] gue: Fix skb memleak with inner IP protocol 0.
https://git.kernel.org/netdev/net/c/9a56796ad258
- [v2,net,2/3] tools: ynl: Specify --no-line-number in ynl-regen.sh.
https://git.kernel.org/netdev/net/c/68578370f9b3
- [v2,net,3/3] fou: Don't allow 0 for FOU_ATTR_IPPROTO.
https://git.kernel.org/netdev/net/c/7a9bc9e3f423
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 7+ messages in thread