Skip to contentSkip to conversation

netfilter: ipvs: make global sysctl readonly in non-init netns

PATCH Applied Antoine Tenart 4 participants 4 messages Oct 12, 2021 – Oct 17, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: ipvs: make global sysctl readonly in non-init netns

Because the data pointer of net/ipv4/vs/debug_level is not updated per netns, it must be marked as read-only in non-init netns.

Fixes c6d2d445d8de ("IPVS: netns, final patch enabling network name space.")
---
 net/netfilter/ipvs/ip_vs_ctl.c | 5 +++++
 1 file changed, 5 insertions(+)
net/netfilter/ipvs/ip_vs_ctl.c +5 -0
index c25097092a06..29ec3ef63edc 100644
@@ -4090,6 +4090,11 @@ static int __net_init ip_vs_control_net_init_sysctl(struct netns_ipvs *ipvs)
 	tbl[idx++].data = &ipvs->sysctl_conn_reuse_mode;
 	tbl[idx++].data = &ipvs->sysctl_schedule_icmp;
 	tbl[idx++].data = &ipvs->sysctl_ignore_tunneled;
+#ifdef CONFIG_IP_VS_DEBUG
+	/* Global sysctls must be ro in non-init netns */
+	if (!net_eq(net, &init_net))
+		tbl[idx++].mode = 0444;
+#endif
 
 	ipvs->sysctl_hdr = register_net_sysctl(net, "net/ipv4/vs", tbl);
 	if (ipvs->sysctl_hdr == NULL) {
Signature · 1 line
2.31.1
maintainer Acked-by on v1 1/1
#1 lore raw

Hello,

Quoted 5 lines · Antoine Tenart

Because the data pointer of net/ipv4/vs/debug_level is not updated per netns, it must be marked as read-only in non-init netns.

Fixes c6d2d445d8de ("IPVS: netns, final patch enabling network name space.")

Looks good to me, thanks!

Quoted 22 lines
---
 net/netfilter/ipvs/ip_vs_ctl.c | 5 +++++
 1 file changed, 5 insertions(+)
net/netfilter/ipvs/ip_vs_ctl.c +5 -0
index c25097092a06..29ec3ef63edc 100644
@@ -4090,6 +4090,11 @@ static int __net_init ip_vs_control_net_init_sysctl(struct netns_ipvs *ipvs)
 	tbl[idx++].data = &ipvs->sysctl_conn_reuse_mode;
 	tbl[idx++].data = &ipvs->sysctl_schedule_icmp;
 	tbl[idx++].data = &ipvs->sysctl_ignore_tunneled;
+#ifdef CONFIG_IP_VS_DEBUG
+	/* Global sysctls must be ro in non-init netns */
+	if (!net_eq(net, &init_net))
+		tbl[idx++].mode = 0444;
+#endif
 
 	ipvs->sysctl_hdr = register_net_sysctl(net, "net/ipv4/vs", tbl);
 	if (ipvs->sysctl_hdr == NULL) {
Signature · 1 line
2.31.1

Regards

--
Julian Anastasov <[email protected]>

maintainer Acked-by
#2 lore raw
Quoted 8 lines · Julian Anastasov

Hello,

Quoted 3 lines · Antoine Tenart

Because the data pointer of net/ipv4/vs/debug_level is not updated per netns, it must be marked as read-only in non-init netns.

Quoted 6 lines
Quoted 2 lines
Fixes c6d2d445d8de ("IPVS: netns, final patch enabling network name space.")

Looks good to me, thanks!

Likewise, thanks.

Pablo, please consider picking up this patch.

maintainer Applied
#3 lore raw
In reply to Antoine Tenart
Quoted 2 lines · Antoine Tenart

Because the data pointer of net/ipv4/vs/debug_level is not updated per netns, it must be marked as read-only in non-init netns.

Applied, thanks