Skip to contentSkip to conversation

netfilter: lwtunnel: expose read-only sysctl nf_hooks_lwtunnel for non init-netns

PATCH New Pablo Neira Ayuso 1 participant 1 message Oct 29

Subsystems (2)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH v3 1/1 netfilter: lwtunnel: expose read-only sysctl nf_hooks_lwtunnel for non init-netns

Expose nf_hooks_lwtunnel sysctl with 0444 mode from non init-netns instead of 0644, sashiko reports this is exposing a global static branch to modification by unprivileged users.

Fixes 7a3f5b0de364 ("netfilter: add netfilter hooks to SRv6 data plane")

---
v3: recover non-const struct ctl_table *dup to address compilation warning.

 net/netfilter/nf_hooks_lwtunnel.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
net/netfilter/nf_hooks_lwtunnel.c +8 -4
index 40c6fce14a63..7e2ee8677f1f 100644
@@ -68,14 +68,18 @@ static int __net_init nf_lwtunnel_net_init(struct net *net)
 {
 	const struct ctl_table *table;
 	struct ctl_table_header *hdr;
+	struct ctl_table *dup;
 
 	table = nf_lwtunnel_sysctl_table;
 	if (!net_eq(net, &init_net)) {
-		table = kmemdup(nf_lwtunnel_sysctl_table,
-				sizeof(nf_lwtunnel_sysctl_table),
-				GFP_KERNEL_ACCOUNT);
-		if (!table)
+		dup = kmemdup(nf_lwtunnel_sysctl_table,
+			      sizeof(nf_lwtunnel_sysctl_table),
+			      GFP_KERNEL_ACCOUNT);
+		if (!dup)
 			goto err_alloc;
+
+		dup->mode = 0444;
+		table = dup;
 	}
 
 	hdr = register_net_sysctl_sz(net, "net/netfilter", table,
Signature · 1 line
2.47.3