From: Ian Rogers <irogers@google.com>
To: Xin Long <lucien.xin@gmail.com>
Cc: willemb@google.com,
Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
linux-sctp@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
Elkin Cruz <elkin@google.com>, Ian Rogers <irogers@google.com>
Subject: Re: [PATCH net] sctp: initialize new_value in custom proc_dointvec sysctl handlers
Date: Tue, 1 Dec 2026 09:38:07 -0800 [thread overview]
Message-ID: <20261201173807.1423448-1-irogers@google.com> (raw)
In-Reply-To: <CADvbK_dWxgqXMjEpAO420-E=d=0HH=jGpef0XL3GHSq0By5dmg@mail.gmail.com>
On Thu, Nov 26, 2026 at 2:17 PM Xin Long <lucien.xin@gmail.com> wrote:
>
> On Wed, Nov 25, 2026 at 8:43 PM <willemb@google.com> wrote:
> >
> > Returning early on reads (`if (!write) return proc_dointvec(ctl, write,
> > buffer, lenp, ppos);`), initializing `old_value = READ_ONCE(...)` /
> > `new_value = old_value` unconditionally on the write path (keeping Clang's
> > -Wconditional-uninitialized happy), and gating the commit block on
> > `new_value != old_value` with WRITE_ONCE() avoids both the data race and
> > stale writebacks on ignored writes.
> Right.
>
> I think you can replace proc_sctp_do_rto_min() and proc_sctp_do_rto_max()
> with proc_dointvec_minmax().
>
> Then apply Willem's suggestion only to proc_sctp_do_auth() and
> proc_sctp_do_probe_interval().
[...]
> With sctp_sysctl_mutex, we don't need the extra old_value variable, unlike
> in proc_sctp_do_auth() and proc_sctp_do_probe_interval() above.
Thanks both for the thorough review! I've updated the patch to replace
proc_sctp_do_rto_min() and proc_sctp_do_rto_max() with
proc_dointvec_minmax(), apply the early !write return + READ_ONCE() /
WRITE_ONCE() + new_value != old_value check to proc_sctp_do_auth() and
proc_sctp_do_probe_interval(), and hold sctp_sysctl_mutex across
new_value initialization and proc_dointvec() in proc_sctp_do_udp_port().
I also reproduced the unpatched stack corruption/-EINVAL in QEMU with
CONFIG_INIT_STACK_NONE=y and verified the fix under
CONFIG_KCSAN_STRICT=y, CONFIG_PROVE_LOCKING=y, and
tools/testing/selftests/net/sctp_vrf.sh. I'll send v2 shortly.
Thanks,
Ian
pw-bot: cr
prev parent reply other threads:[~2026-12-01 17:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 17:03 [PATCH net] sctp: initialize new_value in custom proc_dointvec sysctl handlers Ian Rogers
2026-11-24 14:25 ` Xin Long
2026-11-26 1:43 ` willemb
2026-11-26 22:17 ` Xin Long
2026-12-01 17:38 ` Ian Rogers [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=20261201173807.1423448-1-irogers@google.com \
--to=irogers@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=elkin@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sctp@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=lucien.xin@gmail.com \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.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