netfilter: lwtunnel: expose read-only sysctl nf_hooks_lwtunnel for non init-netns
Subsystems (2)
Pablo Neira Ayuso
maintainerPATCH 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.
--- net/netfilter/nf_hooks_lwtunnel.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
net/netfilter/nf_hooks_lwtunnel.c +8 -4
@@ -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 ); -if (!table) + dup =kmemdup (nf_lwtunnel_sysctl_table, +sizeof (nf_lwtunnel_sysctl_table), +GFP_KERNEL ); +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
Florian Westphal
maintainerQuoted 3 lines · Pablo Neira Ayuso
Expose
nf_hooks_lwtunnelsysctl with 0444 mode from non init-netns instead of 0644, sashiko reports this is exposing a global static branch to modification by unprivileged users.
No objection but I find this report weird. Why is that an issue in the first place?
Quoted 1 line
Fixes a2225e0250c5 ("netfilter: move the sysctl nf_hooks_lwtunnel into the netfilter core")
AFAICS it was exposed before this too, just via conntrack module and not the core.
Pablo Neira Ayuso
maintainerHi Florian,
Quoted 7 lines · Florian Westphal
Quoted 3 lines · Pablo Neira Ayuso
Expose
nf_hooks_lwtunnelsysctl with 0444 mode from non init-netns instead of 0644, sashiko reports this is exposing a global static branch to modification by unprivileged users.No objection but I find this report weird. Why is that an issue in the first place?
Sashiko specifies that this allows for unpriviledged user to turn on/off the nf_hooks_lwtunnel via static key, which is something that only init_net should be able to do.
Quoted 3 lines
Quoted 1 line
Fixes a2225e0250c5 ("netfilter: move the sysctl nf_hooks_lwtunnel into the netfilter core")AFAICS it was exposed before this too, just via conntrack module and not the core.
I can point to the initial patch:
7a3f5b0de364 ("netfilter: add netfilter hooks to SRv6 data plane")