Netdev List
 help / color / mirror / Atom feed
From: Fernando Fernandez Mancera <fmancera@suse.de>
To: netdev@vger.kernel.org
Cc: nicolas.dichtel@6wind.com, shemminger@vyatta.com,
	dforster@brocade.com, gospo@cumulusnetworks.com,
	ddutt@cumulusnetworks.com, brian.haley@hp.com, horms@kernel.org,
	pabeni@redhat.com, kuba@kernel.org, edumazet@google.com,
	davem@davemloft.net, idosch@nvidia.com, dsahern@kernel.org
Subject: Re: [PATCH net 0/6] ipv6: fix sysctl error handling and missing notifications
Date: Fri, 19 Jun 2026 18:42:18 +0200	[thread overview]
Message-ID: <ce2dd6b5-5716-4ae7-8183-8a96642c6be4@suse.de> (raw)
In-Reply-To: <20260618162225.4588-1-fmancera@suse.de>

On 6/18/26 6:22 PM, Fernando Fernandez Mancera wrote:
> While working on a different IPv6 patch series I have spotted multiple
> minor bugs around sysctl error handling and notifications. In general,
> they are not serious issues.
> 
> In addition, there is one more issue in forwarding sysctl as it does not
> check for CAP_NET_ADMIN for the namespace. I am keeping that patch out
> of this series and I am aiming it at the net-next tree once it re-opens.
> 
> Fernando Fernandez Mancera (6):
>    ipv6: fix error handling in disable_ipv6 sysctl
>    ipv6: fix error handling in ignore_routes_with_linkdown sysctl
>    ipv6: fix error handling in forwarding sysctl
>    ipv6: fix error handling in disable_policy sysctl
>    ipv6: reset value and position for proxy_ndp sysctl restart
>    ipv6: fix missing notification for ignore_routes_with_linkdown
> 
>   net/ipv6/addrconf.c | 35 +++++++++++++++++++++++++++--------
>   1 file changed, 27 insertions(+), 8 deletions(-)
> 

So I have checked the feedback from sashiko.dev [1]. In general, it is 
real but I have doubts about this one. While it is real, I am not so 
sure we actually care about this scenario. In any case, this is a 
pattern around kernel code and it would require fixes everywhere 
(IPv4/IPv6/other places (?)).

The easier thing to do is what Nicolas suggested about taking the lock 
before parsing the value i.e before calling proc_dointvec().

I also do wonder if I should fix them in individual commits or together 
in the same commit as they have different fixes tag. Or maybe we can aim 
this last part to net-next. Thoughts?

Please, see the feedback attached below.

Thanks!

[1] https://sashiko.dev/#/patchset/20260618162225.4588-1-fmancera%40suse.de

 > diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
 > index 8ff015975e279..1cfb223476bd6 100644
 > --- a/net/ipv6/addrconf.c
 > +++ b/net/ipv6/addrconf.c
[ ... ]
 > @@ -6493,8 +6494,12 @@ static int addrconf_sysctl_proxy_ndp(const 
struct ctl_table *ctl, int write,
 >  	if (write && old != new) {
 >  		struct net *net = ctl->extra2;
 >
 > -		if (!rtnl_net_trylock(net))
 > +		if (!rtnl_net_trylock(net)) {
 > +			/* Restore the original values before restarting */
 > +			*valp = old;
 > +			*ppos = pos;
 >  			return restart_syscall();
 > +		}
 >

Does this rollback introduce a race condition that can silently discard
concurrent writes?
The sysctl core does not serialize concurrent writes to the same sysctl
parameter, and proc_dointvec() modifies the global sysctl memory pointed to
by ctl->data directly.
If Thread A and Thread B concurrently write to proxy_ndp, and Thread A fails
to acquire the RTNL lock, setting *valp = old will unconditionally reset the
global memory back to what Thread A observed before its write. This seems
like it would clobber Thread B's concurrent update.
If Thread B successfully acquires the RTNL lock, it will evaluate its local
old != new stack variables as true and emit a RTM_NEWNETCONF netlink
notification. However, the notification will read the corrupted *valp 
memory,
leaving the emitted event and internal sysctl state out of sync.
Could this be avoided by duplicating the ctl_table, pointing the data field
to a local stack variable, calling proc_dointvec() on the local variable,
and only updating the global *valp after successfully acquiring the lock,
similar to how it is handled in addrconf_sysctl_forward()?


      parent reply	other threads:[~2026-06-19 16:48 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-18 16:22 [PATCH net 0/6] ipv6: fix sysctl error handling and missing notifications Fernando Fernandez Mancera
2026-06-18 16:22 ` [PATCH net 1/6] ipv6: fix error handling in disable_ipv6 sysctl Fernando Fernandez Mancera
2026-06-19  9:33   ` Nicolas Dichtel
2026-06-18 16:22 ` [PATCH net 2/6] ipv6: fix error handling in ignore_routes_with_linkdown sysctl Fernando Fernandez Mancera
2026-06-19  9:34   ` Nicolas Dichtel
2026-06-18 16:22 ` [PATCH net 3/6] ipv6: fix error handling in forwarding sysctl Fernando Fernandez Mancera
2026-06-19  9:34   ` Nicolas Dichtel
2026-06-19 10:28     ` Fernando Fernandez Mancera
2026-06-19 13:04       ` Nicolas Dichtel
2026-06-18 16:22 ` [PATCH net 4/6] ipv6: fix error handling in disable_policy sysctl Fernando Fernandez Mancera
2026-06-19  9:35   ` Nicolas Dichtel
2026-06-18 16:22 ` [PATCH net 5/6] ipv6: reset value and position for proxy_ndp sysctl restart Fernando Fernandez Mancera
2026-06-19  9:58   ` Nicolas Dichtel
2026-06-19 10:09     ` Fernando Fernandez Mancera
2026-06-18 16:22 ` [PATCH net 6/6] ipv6: fix missing notification for ignore_routes_with_linkdown Fernando Fernandez Mancera
2026-06-19 10:02   ` Nicolas Dichtel
2026-06-19 16:42 ` Fernando Fernandez Mancera [this message]

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=ce2dd6b5-5716-4ae7-8183-8a96642c6be4@suse.de \
    --to=fmancera@suse.de \
    --cc=brian.haley@hp.com \
    --cc=davem@davemloft.net \
    --cc=ddutt@cumulusnetworks.com \
    --cc=dforster@brocade.com \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=gospo@cumulusnetworks.com \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.dichtel@6wind.com \
    --cc=pabeni@redhat.com \
    --cc=shemminger@vyatta.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox