Skip to content

Commit 20c1be4

Browse files
committed
Merge branch 'net-bpf-nd_tbl-fixes-for-when-ipv6-disable-1'
Ricardo B. Marlière says: ==================== {net,bpf}: nd_tbl fixes for when ipv6.disable=1 Please consider merging these four patches to fix three crashes that were found after this report: https://lore.kernel.org/all/CAHXs0ORzd62QOG-Fttqa2Cx_A_VFp=utE2H2VTX5nqfgs7LDxQ@mail.gmail.com The first patch from Jakub Kicinski is a preparation in order to enable the use ipv6_mod_enabled() even when CONFIG_IPV6=n. ==================== Link: https://patch.msgid.link/20260307-net-nd_tbl_fixes-v4-0-e2677e85628c@suse.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 908c344 + d56b5d1 commit 20c1be4

5 files changed

Lines changed: 20 additions & 10 deletions

File tree

drivers/net/bonding/bond_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3428,7 +3428,7 @@ int bond_rcv_validate(const struct sk_buff *skb, struct bonding *bond,
34283428
} else if (is_arp) {
34293429
return bond_arp_rcv(skb, bond, slave);
34303430
#if IS_ENABLED(CONFIG_IPV6)
3431-
} else if (is_ipv6) {
3431+
} else if (is_ipv6 && likely(ipv6_mod_enabled())) {
34323432
return bond_na_rcv(skb, bond, slave);
34333433
#endif
34343434
} else {

include/linux/ipv6.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,12 @@ struct tcp6_timewait_sock {
333333
};
334334

335335
#if IS_ENABLED(CONFIG_IPV6)
336-
bool ipv6_mod_enabled(void);
336+
extern int disable_ipv6_mod;
337+
338+
static inline bool ipv6_mod_enabled(void)
339+
{
340+
return disable_ipv6_mod == 0;
341+
}
337342

338343
static inline struct ipv6_pinfo *inet6_sk(const struct sock *__sk)
339344
{

net/core/filter.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,6 +2228,9 @@ static int bpf_out_neigh_v6(struct net *net, struct sk_buff *skb,
22282228
return -ENOMEM;
22292229
}
22302230

2231+
if (unlikely(!ipv6_mod_enabled()))
2232+
goto out_drop;
2233+
22312234
rcu_read_lock();
22322235
if (!nh) {
22332236
dst = skb_dst(skb);
@@ -2335,6 +2338,10 @@ static int bpf_out_neigh_v4(struct net *net, struct sk_buff *skb,
23352338

23362339
neigh = ip_neigh_for_gw(rt, skb, &is_v6gw);
23372340
} else if (nh->nh_family == AF_INET6) {
2341+
if (unlikely(!ipv6_mod_enabled())) {
2342+
rcu_read_unlock();
2343+
goto out_drop;
2344+
}
23382345
neigh = ip_neigh_gw6(dev, &nh->ipv6_nh);
23392346
is_v6gw = true;
23402347
} else if (nh->nh_family == AF_INET) {

net/ipv4/af_inet.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@
124124

125125
#include <trace/events/sock.h>
126126

127+
/* Keep the definition of IPv6 disable here for now, to avoid annoying linker
128+
* issues in case IPv6=m
129+
*/
130+
int disable_ipv6_mod;
131+
EXPORT_SYMBOL(disable_ipv6_mod);
132+
127133
/* The inetsw table contains everything that inet_create needs to
128134
* build a new socket.
129135
*/

net/ipv6/af_inet6.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ struct ipv6_params ipv6_defaults = {
8686
.autoconf = 1,
8787
};
8888

89-
static int disable_ipv6_mod;
90-
9189
module_param_named(disable, disable_ipv6_mod, int, 0444);
9290
MODULE_PARM_DESC(disable, "Disable IPv6 module such that it is non-functional");
9391

@@ -97,12 +95,6 @@ MODULE_PARM_DESC(disable_ipv6, "Disable IPv6 on all interfaces");
9795
module_param_named(autoconf, ipv6_defaults.autoconf, int, 0444);
9896
MODULE_PARM_DESC(autoconf, "Enable IPv6 address autoconfiguration on all interfaces");
9997

100-
bool ipv6_mod_enabled(void)
101-
{
102-
return disable_ipv6_mod == 0;
103-
}
104-
EXPORT_SYMBOL_GPL(ipv6_mod_enabled);
105-
10698
static struct ipv6_pinfo *inet6_sk_generic(struct sock *sk)
10799
{
108100
const int offset = sk->sk_prot->ipv6_pinfo_offset;

0 commit comments

Comments
 (0)