Linux Security Modules development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jiayuan Chen" <jiayuan.chen@linux.dev>
Cc: linux-security-module@vger.kernel.org, mptcp@lists.linux.dev,
	linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>
Subject: Re: [PATCH net-next 06/14] sctp: annotate data-races around sctp sysctls
Date: Tue, 10 Nov 2026 03:01:26 +0000	[thread overview]
Message-ID: <sashiko-outbox-206079@kernel.org> (raw)
In-Reply-To: <20261109025425.328445-7-jiayuan.chen@linux.dev>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] sctp: missing READ_ONCE() on cookie_auth_enable in
  proc_sctp_do_hmac_alg()
- [Low] sctp: missing READ_ONCE() in proc_sctp_do_rto_min() and
  proc_sctp_do_rto_max()
--

commit 93a2b54452b64ee91dbf610597cfa8b06cc871d2
Author: Jiayuan Chen <jiayuan.chen@linux.dev>

sctp: annotate data-races around sctp sysctls

This commit adds READ_ONCE() and WRITE_ONCE() annotations to per-netns SCTP
sysctl variables accessed concurrently by readers and sysctl handlers.

> diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
> index 2b94c211427de..8a84ae3272d24 100644
> --- a/net/sctp/sysctl.c
> +++ b/net/sctp/sysctl.c
> @@ -402,11 +402,11 @@ static int proc_sctp_do_hmac_alg(const struct ctl_table *ctl, int write,
>  		if (ret)
>  			return ret;
>  		if (!strcmp(tmp, "sha256")) {
> -			net->sctp.cookie_auth_enable = 1;
> +			WRITE_ONCE(net->sctp.cookie_auth_enable, 1);
>  			return 0;
>  		}
>  		if (!strcmp(tmp, "none")) {
> -			net->sctp.cookie_auth_enable = 0;
> +			WRITE_ONCE(net->sctp.cookie_auth_enable, 0);
>  			return 0;
>  		}
>  		return -EINVAL;

[Severity: Low]
Should the read path right below in proc_sctp_do_hmac_alg() also use
READ_ONCE(net->sctp.cookie_auth_enable)?

net/sctp/sysctl.c:proc_sctp_do_hmac_alg() {
    ...
	if (net->sctp.cookie_auth_enable)
		tbl.data = (char *)"sha256";
    ...
}

Unlike proc_dointvec(), proc_dostring() only sees the selected string
literal, so a concurrent sysctl read and write of cookie_hmac_alg still
race on net->sctp.cookie_auth_enable.

> @@ -441,7 +441,7 @@ static int proc_sctp_do_rto_min(const struct ctl_table *ctl, int write,
>  		if (new_value > max || new_value < min)
>  			return -EINVAL;
>  
> -		net->sctp.rto_min = new_value;
> +		WRITE_ONCE(net->sctp.rto_min, new_value);
>  	}
>  
>  	return ret;
> @@ -469,7 +469,7 @@ static int proc_sctp_do_rto_max(const struct ctl_table *ctl, int write,
>  		if (new_value > max || new_value < min)
>  			return -EINVAL;
>  
> -		net->sctp.rto_max = new_value;
> +		WRITE_ONCE(net->sctp.rto_max, new_value);
>  	}
>  
>  	return ret;

[Severity: Low]
Do proc_sctp_do_rto_min() and proc_sctp_do_rto_max() also need READ_ONCE()
when dereferencing ctl->extra2 and ctl->extra1?

sctp_sysctl_net_register() points rto_min's extra2 at &net->sctp.rto_max
and rto_max's extra1 at &net->sctp.rto_min:

net/sctp/sysctl.c:proc_sctp_do_rto_min() {
	struct net *net = container_of(ctl->data, struct net, sctp.rto_min);
	unsigned int min = *(unsigned int *) ctl->extra1;
	unsigned int max = *(unsigned int *) ctl->extra2;
    ...
}

Reading or writing rto_min while rto_max is being updated (or vice versa)
still performs an unannotated plain read against the peer handler's
WRITE_ONCE().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261109025425.328445-1-jiayuan.chen@linux.dev?part=6

  reply	other threads:[~2026-11-10  3:01 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09  2:51 [PATCH net-next 00/14] net: annotate data-races around sysctl knobs Jiayuan Chen
2026-11-09  2:52 ` [PATCH net-next 01/14] ipv4: annotate data-races around ip_rt_* sysctls Jiayuan Chen
2026-11-10  3:01   ` sashiko-bot
2026-11-10  5:53   ` netdev-bot+sashiko
2026-11-09  2:52 ` [PATCH net-next 02/14] inet: frags: annotate data-races around fqdir->timeout and fqdir->max_dist Jiayuan Chen
2026-11-10  3:01   ` sashiko-bot
2026-11-09  2:52 ` [PATCH net-next 03/14] ipv6: annotate data-races around addrconf sysctls Jiayuan Chen
2026-11-10  3:01   ` sashiko-bot
2026-11-09  2:52 ` [PATCH net-next 04/14] ipv6: annotate data-races around icmpv6 reply sysctls Jiayuan Chen
2026-11-10  3:01   ` sashiko-bot
2026-11-09  2:52 ` [PATCH net-next 05/14] calipso: annotate data-races around cache sysctls Jiayuan Chen
2026-11-10  3:01   ` sashiko-bot
2026-11-10  5:53   ` netdev-bot+sashiko
2026-11-09  2:52 ` [PATCH net-next 06/14] sctp: annotate data-races around sctp sysctls Jiayuan Chen
2026-11-10  3:01   ` sashiko-bot [this message]
2026-11-10  5:53   ` netdev-bot+sashiko
2026-11-09  2:52 ` [PATCH net-next 07/14] mptcp: annotate data-races around pernet sysctls Jiayuan Chen
2026-11-10  3:01   ` sashiko-bot
2026-11-10 11:28   ` Matthieu Baerts
2026-11-09  2:52 ` [PATCH net-next 08/14] rds: annotate data-races around core rds sysctls Jiayuan Chen
2026-11-10  3:01   ` sashiko-bot
2026-11-09  2:52 ` [PATCH net-next 09/14] netfilter: conntrack: annotate data-races around conntrack sysctls Jiayuan Chen
2026-11-10  3:01   ` sashiko-bot
2026-11-09  2:52 ` [PATCH net-next 10/14] netfilter: bridge: annotate data-races around br_netfilter and nf_log sysctls Jiayuan Chen
2026-11-10  3:01   ` sashiko-bot
2026-11-10  5:53   ` netdev-bot+sashiko
2026-11-09  2:52 ` [PATCH net-next 11/14] ipvs: annotate data-races around lblc_expiration and lblcr_expiration Jiayuan Chen
2026-11-10  3:01   ` sashiko-bot
2026-11-09  2:52 ` [PATCH net-next 12/14] net/smc: annotate data-races around smc sysctls Jiayuan Chen
2026-11-10  3:01   ` sashiko-bot
2026-11-09  2:52 ` [PATCH net-next 13/14] netfilter: conntrack: annotate data-races around timeout and tcp sysctls Jiayuan Chen
2026-11-10  3:01   ` sashiko-bot
2026-11-09  2:52 ` [PATCH net-next 14/14] netfilter: cttimeout: annotate data-races around the default timeouts Jiayuan Chen
2026-11-10  3:01   ` sashiko-bot
2026-11-10  5:53   ` netdev-bot+sashiko
2026-11-09  3:11 ` [PATCH net-next 00/14] net: annotate data-races around sysctl knobs Jason Xing
2026-11-09  3:33   ` Jiayuan Chen
2026-11-09  6:52     ` Jason Xing

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=sashiko-outbox-206079@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=jiayuan.chen@linux.dev \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /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