All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Fernando Fernandez Mancera" <fmancera@suse.de>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH 02/13 RFC net-next] net: core: add IPv4 fallback stubs and guards for CONFIG_IPV4=n
Date: Fri, 30 Oct 2026 04:54:28 +0000	[thread overview]
Message-ID: <sashiko-outbox-190468@kernel.org> (raw)
In-Reply-To: <20260712013941.4570-3-fmancera@suse.de>

Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [Critical] The `SIOCGIFCONF` ioctl handler returns `-EAFNOSUPPORT` instead of an empty list, breaking UAPI.
- [High] RCU read lock leak in `neigh_xmit()` when CONFIG_IPV4 is disabled.
- [Low] Missing stubs for IPv4 functions called by IPv6 code leads to undefined references.
- [Low] Missing stubs for IP output functions and unconditional `tcp_prot` reference lead to undefined reference linker errors.
- [Low] Undefined reference to `tcp_twsk_unique` in IPv6 hashtables when CONFIG_IPV4 is disabled.
--

--- Patch [2]: [PATCH 02/13 RFC net-next] net: core: add IPv4 fallback stubs and guards for CONFIG_IPV4=n ---
commit c3ba15b9e372b7ea2df4737d8f114c24f3baec0c
Author: Fernando Fernandez Mancera <fmancera@suse.de>

net: core: add IPv4 fallback stubs and guards for CONFIG_IPV4=n

To enable compiling the core network stack without IPv4, generic
networking code must avoid referencing missing IPv4 symbols.

This patch provides static inline stubs in include/net/ip.h and
include/net/route.h that return a proper error code when IPv4 is
disabled. This behaves as IPv6 code does. In addition, it introduces
guards around IPv4 specific code in generic implementations to prevent
undefined reference errors while linking.

> diff --git a/include/net/ip.h b/include/net/ip.h
> index 7f2fe1a8401b1..aeac40d11c725 100644
> --- a/include/net/ip.h
> +++ b/include/net/ip.h
[ ... ]
> @@ -225,27 +235,58 @@ int ip_append_data(struct sock *sk, struct flowi4 *fl4,
[ ... ]
> +static inline void ip_flush_pending_frames(struct sock *sk)
> +{
> +}
> +#endif
> +
> +int ip_generic_getfrag(void *from, char *to, int offset, int len, int odd,
> +		       struct sk_buff *skb);
> +int ip_send_skb(struct net *net, struct sk_buff *skb);
> +int ip_push_pending_frames(struct sock *sk, struct flowi4 *fl4);
> +int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl);

[Severity: Low]
Could these un-stubbed declarations cause undefined reference errors during
linking? 

The declarations for ip_generic_getfrag(), ip_send_skb(),
ip_push_pending_frames(), and ip_queue_xmit() are placed outside the
CONFIG_IPV4 guard without providing static inline stubs. If net/ipv4/af_inet.c
and net/ipv4/udp.c are compiled without CONFIG_IPV4, references to these
functions and tcp_prot will break the build.

Additionally, are there missing stubs for IPv4 functions called directly by the
IPv6 subsystem? When building with CONFIG_IPV6=y and CONFIG_IPV4=n, IPv6 mapped
socket code directly calls IPv4 functions:

net/ipv6/datagram.c:ipv6_mapped_datagram_connect() calls __ip4_datagram_connect()
net/ipv6/tcp_ipv6.c:tcp_v6_connect() calls tcp_v4_connect()
net/ipv6/inet6_hashtables.c:__inet6_check_established() calls tcp_twsk_unique()

Without stubs for these functions, or proper guards in the IPv6 code, the linker
will fail.

> diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
> index a320e264eaaf0..f7ca3701b6bd1 100644
> --- a/net/core/dev_ioctl.c
> +++ b/net/core/dev_ioctl.c
> @@ -39,6 +39,7 @@ static int dev_ifname(struct net *net, struct ifreq *ifr)
>   */
>  int dev_ifconf(struct net *net, struct ifconf __user *uifc)
>  {
> +#if IS_ENABLED(CONFIG_IPV4)
>  	struct net_device *dev;
>  	void __user *pos;
>  	size_t size;
[ ... ]
> @@ -82,6 +83,9 @@ int dev_ifconf(struct net *net, struct ifconf __user *uifc)
>  	rtnl_net_unlock(net);
>  
>  	return put_user(total, &uifc->ifc_len);
> +#else
> +	return -EAFNOSUPPORT;
> +#endif
>  }

[Severity: Critical]
Will this break legacy userspace applications that enumerate interfaces?

By returning -EAFNOSUPPORT instead of an empty list, the behavior changes
for the SIOCGIFCONF ioctl when the kernel is compiled without IPv4.

Could this branch instead return 0 interfaces via put_user(0, &uifc->ifc_len)
to maintain backwards compatibility for tools expecting the ioctl to succeed?

> diff --git a/net/core/neighbour.c b/net/core/neighbour.c
> index 1349c0eedb642..1a40a0ab041b8 100644
> --- a/net/core/neighbour.c
> +++ b/net/core/neighbour.c
> @@ -3208,9 +3208,13 @@ int neigh_xmit(int index, struct net_device *dev,
>  			goto out_kfree_skb;
>  		}
>  		if (index == NEIGH_ARP_TABLE) {
> +#if IS_ENABLED(CONFIG_IPV4)
>  			u32 key = *((u32 *)addr);
>  
>  			neigh = __ipv4_neigh_lookup_noref(dev, key);
> +#else
> +			goto out_kfree_skb;
> +#endif
>  		} else {
>  			neigh = __neigh_lookup_noref(tbl, addr, dev);
>  		}

[Severity: High]
Does this error path leak the RCU read lock?

The function neigh_xmit() acquires the rcu_read_lock() earlier, and this
goto out_kfree_skb jumps directly to the cleanup label, missing the
rcu_read_unlock() call.

Could this stall RCU grace periods if a packet is transmitted where
index == NEIGH_ARP_TABLE when CONFIG_IPV4 is disabled?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260712013941.4570-1-fmancera@suse.de?part=2

  reply	other threads:[~2026-10-30  4:54 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-12  1:38 [PATCH 00/13 RFC net-next] Allow compiling an IPv6-only kernel network stack Fernando Fernandez Mancera
2026-07-12  1:38 ` [PATCH 01/13 RFC net-next] net: ipv4: introduce CONFIG_IPV4 to decouple the IPv4 stack Fernando Fernandez Mancera
2026-07-12  1:38   ` [Intel-wired-lan] " Fernando Fernandez Mancera
2026-07-12 11:01   ` Arnd Bergmann
2026-07-12 11:01     ` [Intel-wired-lan] " Arnd Bergmann
2026-07-13 14:00     ` Fernando Fernandez Mancera
2026-07-13 14:00       ` [Intel-wired-lan] " Fernando Fernandez Mancera
2026-07-13 14:22       ` Arnd Bergmann
2026-07-13 14:22         ` [Intel-wired-lan] " Arnd Bergmann
2026-07-13 14:57         ` Fernando Fernandez Mancera
2026-07-13 14:57           ` [Intel-wired-lan] " Fernando Fernandez Mancera
2026-10-30  4:54   ` sashiko-bot
2026-07-12  1:39 ` [PATCH 02/13 RFC net-next] net: core: add IPv4 fallback stubs and guards for CONFIG_IPV4=n Fernando Fernandez Mancera
2026-10-30  4:54   ` sashiko-bot [this message]
2026-07-12  1:39 ` [PATCH 03/13 RFC net-next] net: inet: relocate ip_generic_getfrag and guard IPv4 socket logic Fernando Fernandez Mancera
2026-07-12  1:39 ` [PATCH 04/13 RFC net-next] net: tcp: move protocol agnostic TCP functions out of tcp_ipv4.c Fernando Fernandez Mancera
2026-10-30  4:54   ` sashiko-bot
2026-07-12  1:39 ` [PATCH 05/13 RFC net-next] net: raw: split IPv4 specific logic into raw_ipv4.c Fernando Fernandez Mancera
2026-07-12  1:39 ` [PATCH 06/13 RFC net-next] net: udp: split IPv4 specific logic into udp_ipv4.c Fernando Fernandez Mancera
2026-07-12  1:39 ` [PATCH 07/13 RFC net-next] net: icmp: split IPv4 specific logic into icmp_ipv4.c Fernando Fernandez Mancera
2026-07-12  1:39 ` [PATCH 08/13 RFC net-next] net: ping: split IPv4 specific logic into ping_ipv4.c Fernando Fernandez Mancera
2026-10-30  4:54   ` sashiko-bot
2026-07-12  1:39 ` [PATCH 09/13 RFC net-next] net: fib: split common nexthop logic to fib_core.c Fernando Fernandez Mancera
2026-10-30  4:54   ` sashiko-bot
2026-07-12  1:39 ` [PATCH 10/13 RFC net-next] net: tunnel: guard IPv4 tunnel functions with CONFIG_IPV4 Fernando Fernandez Mancera
2026-07-12  1:39 ` [PATCH 11/13 RFC net-next] net: cipso: guard IPv4 packet manipulation functions Fernando Fernandez Mancera
2026-07-12 16:22   ` Paul Moore
2026-07-13 14:03     ` Fernando Fernandez Mancera
2026-10-30  4:54   ` sashiko-bot
2026-07-12  1:39 ` [PATCH 12/13 RFC net-next] netfilter: ipv4: guard ip_route_me_harder() with CONFIG_IPV4 Fernando Fernandez Mancera
2026-07-12  1:39 ` [PATCH 13/13 RFC net-next] net: ipv4: make CONFIG_IPV4 boolean Fernando Fernandez Mancera

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-190468@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=fmancera@suse.de \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.