Re: [PATCH net-next v2 4/5] rds: annotate data-races around core rds sysctls
From: netdev-bot+sashiko
Date: Wed Nov 18 2026 - 23:53:37 EST
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