public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] netfilter: flowtable: account for Ethernet header in nf_flow_pppoe_proto()
@ 2025-07-07 12:45 Eric Dumazet
  2025-07-10 23:50 ` Pablo Neira Ayuso
  2025-07-11  0:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2025-07-07 12:45 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni, Pablo Neira Ayuso,
	Jozsef Kadlecsik
  Cc: netdev, netfilter-devel, coreteam, eric.dumazet, Eric Dumazet,
	syzbot+bf6ed459397e307c3ad2

syzbot found a potential access to uninit-value in nf_flow_pppoe_proto()

Blamed commit forgot the Ethernet header.

BUG: KMSAN: uninit-value in nf_flow_offload_inet_hook+0x7e4/0x940 net/netfilter/nf_flow_table_inet.c:27
  nf_flow_offload_inet_hook+0x7e4/0x940 net/netfilter/nf_flow_table_inet.c:27
  nf_hook_entry_hookfn include/linux/netfilter.h:157 [inline]
  nf_hook_slow+0xe1/0x3d0 net/netfilter/core.c:623
  nf_hook_ingress include/linux/netfilter_netdev.h:34 [inline]
  nf_ingress net/core/dev.c:5742 [inline]
  __netif_receive_skb_core+0x4aff/0x70c0 net/core/dev.c:5837
  __netif_receive_skb_one_core net/core/dev.c:5975 [inline]
  __netif_receive_skb+0xcc/0xac0 net/core/dev.c:6090
  netif_receive_skb_internal net/core/dev.c:6176 [inline]
  netif_receive_skb+0x57/0x630 net/core/dev.c:6235
  tun_rx_batched+0x1df/0x980 drivers/net/tun.c:1485
  tun_get_user+0x4ee0/0x6b40 drivers/net/tun.c:1938
  tun_chr_write_iter+0x3e9/0x5c0 drivers/net/tun.c:1984
  new_sync_write fs/read_write.c:593 [inline]
  vfs_write+0xb4b/0x1580 fs/read_write.c:686
  ksys_write fs/read_write.c:738 [inline]
  __do_sys_write fs/read_write.c:749 [inline]

Reported-by: syzbot+bf6ed459397e307c3ad2@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/netdev/686bc073.a00a0220.c7b3.0086.GAE@google.com/T/#u
Fixes: 87b3593bed18 ("netfilter: flowtable: validate pppoe header")
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 include/net/netfilter/nf_flow_table.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/netfilter/nf_flow_table.h b/include/net/netfilter/nf_flow_table.h
index d711642e78b57c75043e94bf00b782398e5f3621..c003cd194fa2ae40545a196fcc74e83c2868b113 100644
--- a/include/net/netfilter/nf_flow_table.h
+++ b/include/net/netfilter/nf_flow_table.h
@@ -370,7 +370,7 @@ static inline __be16 __nf_flow_pppoe_proto(const struct sk_buff *skb)
 
 static inline bool nf_flow_pppoe_proto(struct sk_buff *skb, __be16 *inner_proto)
 {
-	if (!pskb_may_pull(skb, PPPOE_SES_HLEN))
+	if (!pskb_may_pull(skb, ETH_HLEN + PPPOE_SES_HLEN))
 		return false;
 
 	*inner_proto = __nf_flow_pppoe_proto(skb);
-- 
2.50.0.727.gbf7dc18ff4-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] netfilter: flowtable: account for Ethernet header in nf_flow_pppoe_proto()
  2025-07-07 12:45 [PATCH net] netfilter: flowtable: account for Ethernet header in nf_flow_pppoe_proto() Eric Dumazet
@ 2025-07-10 23:50 ` Pablo Neira Ayuso
  2025-07-11  0:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2025-07-10 23:50 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Jozsef Kadlecsik,
	netdev, netfilter-devel, coreteam, eric.dumazet,
	syzbot+bf6ed459397e307c3ad2

Hi Eric,

Thanks for your patch.

On Mon, Jul 07, 2025 at 12:45:17PM +0000, Eric Dumazet wrote:
> syzbot found a potential access to uninit-value in nf_flow_pppoe_proto()
> 
> Blamed commit forgot the Ethernet header.

I see, vlan indeed includes the ethernet header.

        case htons(ETH_P_8021Q):
+               if (!pskb_may_pull(skb, skb_mac_offset(skb) + sizeof(*veth)))

validates this, after this patch this looks consistent.

> BUG: KMSAN: uninit-value in nf_flow_offload_inet_hook+0x7e4/0x940 net/netfilter/nf_flow_table_inet.c:27
>   nf_flow_offload_inet_hook+0x7e4/0x940 net/netfilter/nf_flow_table_inet.c:27
>   nf_hook_entry_hookfn include/linux/netfilter.h:157 [inline]
>   nf_hook_slow+0xe1/0x3d0 net/netfilter/core.c:623
>   nf_hook_ingress include/linux/netfilter_netdev.h:34 [inline]
>   nf_ingress net/core/dev.c:5742 [inline]
>   __netif_receive_skb_core+0x4aff/0x70c0 net/core/dev.c:5837
>   __netif_receive_skb_one_core net/core/dev.c:5975 [inline]
>   __netif_receive_skb+0xcc/0xac0 net/core/dev.c:6090
>   netif_receive_skb_internal net/core/dev.c:6176 [inline]
>   netif_receive_skb+0x57/0x630 net/core/dev.c:6235
>   tun_rx_batched+0x1df/0x980 drivers/net/tun.c:1485
>   tun_get_user+0x4ee0/0x6b40 drivers/net/tun.c:1938
>   tun_chr_write_iter+0x3e9/0x5c0 drivers/net/tun.c:1984
>   new_sync_write fs/read_write.c:593 [inline]
>   vfs_write+0xb4b/0x1580 fs/read_write.c:686
>   ksys_write fs/read_write.c:738 [inline]
>   __do_sys_write fs/read_write.c:749 [inline]
> 
> Reported-by: syzbot+bf6ed459397e307c3ad2@syzkaller.appspotmail.com
> Closes: https://lore.kernel.org/netdev/686bc073.a00a0220.c7b3.0086.GAE@google.com/T/#u
> Fixes: 87b3593bed18 ("netfilter: flowtable: validate pppoe header")
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Reviewed-by: Pablo Neira Ayuso <pablo@netfilter.org>

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] netfilter: flowtable: account for Ethernet header in nf_flow_pppoe_proto()
  2025-07-07 12:45 [PATCH net] netfilter: flowtable: account for Ethernet header in nf_flow_pppoe_proto() Eric Dumazet
  2025-07-10 23:50 ` Pablo Neira Ayuso
@ 2025-07-11  0:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-07-11  0:30 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: davem, kuba, pabeni, pablo, kadlec, netdev, netfilter-devel,
	coreteam, eric.dumazet, syzbot+bf6ed459397e307c3ad2

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon,  7 Jul 2025 12:45:17 +0000 you wrote:
> syzbot found a potential access to uninit-value in nf_flow_pppoe_proto()
> 
> Blamed commit forgot the Ethernet header.
> 
> BUG: KMSAN: uninit-value in nf_flow_offload_inet_hook+0x7e4/0x940 net/netfilter/nf_flow_table_inet.c:27
>   nf_flow_offload_inet_hook+0x7e4/0x940 net/netfilter/nf_flow_table_inet.c:27
>   nf_hook_entry_hookfn include/linux/netfilter.h:157 [inline]
>   nf_hook_slow+0xe1/0x3d0 net/netfilter/core.c:623
>   nf_hook_ingress include/linux/netfilter_netdev.h:34 [inline]
>   nf_ingress net/core/dev.c:5742 [inline]
>   __netif_receive_skb_core+0x4aff/0x70c0 net/core/dev.c:5837
>   __netif_receive_skb_one_core net/core/dev.c:5975 [inline]
>   __netif_receive_skb+0xcc/0xac0 net/core/dev.c:6090
>   netif_receive_skb_internal net/core/dev.c:6176 [inline]
>   netif_receive_skb+0x57/0x630 net/core/dev.c:6235
>   tun_rx_batched+0x1df/0x980 drivers/net/tun.c:1485
>   tun_get_user+0x4ee0/0x6b40 drivers/net/tun.c:1938
>   tun_chr_write_iter+0x3e9/0x5c0 drivers/net/tun.c:1984
>   new_sync_write fs/read_write.c:593 [inline]
>   vfs_write+0xb4b/0x1580 fs/read_write.c:686
>   ksys_write fs/read_write.c:738 [inline]
>   __do_sys_write fs/read_write.c:749 [inline]
> 
> [...]

Here is the summary with links:
  - [net] netfilter: flowtable: account for Ethernet header in nf_flow_pppoe_proto()
    https://git.kernel.org/netdev/net/c/18cdb3d982da

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] 3+ messages in thread

end of thread, other threads:[~2025-07-11  0:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-07 12:45 [PATCH net] netfilter: flowtable: account for Ethernet header in nf_flow_pppoe_proto() Eric Dumazet
2025-07-10 23:50 ` Pablo Neira Ayuso
2025-07-11  0:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox