Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: jiayuan.chen@linux.dev
Cc: netdev@vger.kernel.org, dust.li@linux.alibaba.com,
	dsahern@kernel.org, idosch@nvidia.com, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	horms@kernel.org, matttbe@kernel.org, martineau@kernel.org,
	geliang@kernel.org, achender@kernel.org,
	alibuda@linux.alibaba.com, sidraya@linux.ibm.com,
	mjambigi@linux.ibm.com, tonylu@linux.alibaba.com,
	guwen@linux.alibaba.com, linux-kernel@vger.kernel.org,
	mptcp@lists.linux.dev, linux-rdma@vger.kernel.org,
	rds-devel@oss.oracle.com, linux-s390@vger.kernel.org
Subject: Re: [PATCH net-next v2 4/5] rds: annotate data-races around core rds sysctls
Date: Thu, 19 Nov 2026 04:53:27 +0000	[thread overview]
Message-ID: <179506400752.3136.8984114555998117139@kernel.org> (raw)
In-Reply-To: <20261118045137.174026-5-jiayuan.chen@linux.dev>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The patch only annotates the RDS datapath readers of
  rds_sysctl_reconnect_min_jiffies and rds_sysctl_reconnect_max_jiffies.

--

rds: annotate data-races around core rds sysctls

This patch adds READ_ONCE() to the lockless RDS readers of
reconnect_min_delay_ms, reconnect_max_delay_ms, max_unacked_packets,
max_unacked_bytes and ping_enable. The sysctl handlers already update
these with WRITE_ONCE().

[ ... ]

> diff --git a/net/rds/threads.c b/net/rds/threads.c
> index 639302bab51ef..115fcff0a5b13 100644
> --- a/net/rds/threads.c
> +++ b/net/rds/threads.c
> @@ -137,7 +137,7 @@ void rds_queue_reconnect(struct rds_conn_path *cp)
>  
>  	set_bit(RDS_RECONNECT_PENDING, &cp->cp_flags);
>  	if (cp->cp_reconnect_jiffies == 0) {
> -		cp->cp_reconnect_jiffies = rds_sysctl_reconnect_min_jiffies;
> +		cp->cp_reconnect_jiffies = READ_ONCE(rds_sysctl_reconnect_min_jiffies);
>  		rcu_read_lock();
>  		if (!rds_destroy_pending(cp->cp_conn))
>  			queue_delayed_work(cp->cp_wq, &cp->cp_conn_w, 0);
> @@ -156,7 +156,7 @@ void rds_queue_reconnect(struct rds_conn_path *cp)
>  	rcu_read_unlock();
>  
>  	cp->cp_reconnect_jiffies = min(cp->cp_reconnect_jiffies * 2,
> -					rds_sysctl_reconnect_max_jiffies);
> +					READ_ONCE(rds_sysctl_reconnect_max_jiffies));
>  }

[Severity: Medium]
These two variables have one more lockless reader that is still a plain
load: the sysctl handlers themselves. Does that leave part of the race
described in the commit message unfixed?

In net/rds/sysctl.c, each reconnect sysctl uses the other one's variable
as its range bound:

net/rds/sysctl.c:rds_sysctl_rds_table[] {
	.procname       = "reconnect_min_delay_ms",
	.data		= &rds_sysctl_reconnect_min_jiffies,
	...
	.extra2		= &rds_sysctl_reconnect_max_jiffies,
	...
	.procname       = "reconnect_max_delay_ms",
	.data		= &rds_sysctl_reconnect_max_jiffies,
	...
	.extra1		= &rds_sysctl_reconnect_min_jiffies,
}

Both entries use proc_doulongvec_ms_jiffies_minmax(), which ends up in
proc_ulong_conv() in kernel/sysctl.c:

kernel/sysctl.c:proc_ulong_conv() {
	...
		if ((tbl->extra1 && *(ulong *)tbl->extra1 > tmp_k) ||
		    (tbl->extra2 && *(ulong *)tbl->extra2 < tmp_k))
			return -ERANGE;
		WRITE_ONCE(*k_ptr, tmp_k);
	...
}

If one task writes reconnect_min_delay_ms while another writes
reconnect_max_delay_ms, each handler's WRITE_ONCE() races with the other
handler's plain read of the same variable. KCSAN would report this.

The bound check is also not atomic with the store, so both writers can
pass their checks against the other's old value. For example, with min=100
and max=1000:

task A: write min=500, checked against max=1000, passes
task B: write max=200, checked against min=100, passes

Both writes succeed and leave min=500 > max=200. rds_queue_reconnect()
then starts the backoff at READ_ONCE(min) = 500 and caps the next value at
min(1000, READ_ONCE(max)) = 200. That puts the backoff below the
configured minimum.

Could the extra1/extra2 loads in proc_ulong_conv() use READ_ONCE()? Or
could the two RDS handlers be serialized so that min <= max is enforced
atomically? As far as I can tell, no later patch in the series changes
kernel/sysctl.c or net/rds/sysctl.c.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118045137.174026-1-jiayuan.chen%40linux.dev

  reply	other threads:[~2026-11-19  4:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18  4:51 [PATCH net-next v2 0/5] net: annotate data-races around sysctl knobs Jiayuan Chen
2026-11-18  4:51 ` [PATCH net-next v2 1/5] inet: frags: annotate data-races around fqdir->timeout and fqdir->max_dist Jiayuan Chen
2026-11-18  4:51 ` [PATCH net-next v2 2/5] ipv6: annotate data-races around icmpv6 reply sysctls Jiayuan Chen
2026-11-18  4:51 ` [PATCH net-next v2 3/5] mptcp: annotate data-races around pernet sysctls Jiayuan Chen
2026-11-18  4:51 ` [PATCH net-next v2 4/5] rds: annotate data-races around core rds sysctls Jiayuan Chen
2026-11-19  4:53   ` netdev-bot+sashiko [this message]
2026-11-18  4:51 ` [PATCH net-next v2 5/5] net/smc: annotate data-races around smc sysctls Jiayuan Chen
2026-11-19  7:23   ` Sidraya Jayagond

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=179506400752.3136.8984114555998117139@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=achender@kernel.org \
    --cc=alibuda@linux.alibaba.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=dust.li@linux.alibaba.com \
    --cc=edumazet@kernel.org \
    --cc=geliang@kernel.org \
    --cc=guwen@linux.alibaba.com \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=jiayuan.chen@linux.dev \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=martineau@kernel.org \
    --cc=matttbe@kernel.org \
    --cc=mjambigi@linux.ibm.com \
    --cc=mptcp@lists.linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rds-devel@oss.oracle.com \
    --cc=sidraya@linux.ibm.com \
    --cc=tonylu@linux.alibaba.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