All of lore.kernel.org
 help / color / mirror / Atom feed
From: gang.yan@linux.dev
To: sashiko-reviews@lists.linux.dev
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next v2 3/5] mptcp: use READ_ONCE() over sysctls
Date: Tue, 18 Aug 2026 13:02:37 +0000	[thread overview]
Message-ID: <e0cd265f7d15246668d06c865adacf36943cc6c3@linux.dev> (raw)
In-Reply-To: <20260818100151.DD70A1F00A3E@smtp.kernel.org>

August 18, 2026 at 6:01 PM, sashiko-bot@kernel.org mailto:sashiko-bot@kernel.org  wrote:


> 
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> 
> Pre-existing issues:
> - [High] Concurrent sysctl writes or sysctl updates racing with socket creation can leave the socket's `pm_type` and `ops` mismatched, breaking MPTCP path management.
> --
> 
> --- Patch [3]: [PATCH mptcp-next v2 3/5] mptcp: use READ_ONCE() over sysctls ---
> commit 77c9e4aa4cdd5f6c57cc4cab253d46fd0cf2dfb2
> Author: Matthieu Baerts (NGI0) <matttbe@kernel.org>
> 
> mptcp: use READ_ONCE() over sysctls
> 
> This commit adds READ_ONCE() and WRITE_ONCE() macros around sysctl
> variables in the MPTCP networking code to avoid KCSAN issues. It also
> ensures the pm_type is written with WRITE_ONCE() in proc_path_manager().
> 
> Closes: https://lore.kernel.org/CANn89iL=os-60kDKqMDdyiXuPF5CG=eejS0vmthwpDGXz_Bp8A@mail.gmail.com
> 
> > 
> > diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c
> >  index c0481b09c1a17..733706f06f1b1 100644
> >  --- a/net/mptcp/ctrl.c
> >  +++ b/net/mptcp/ctrl.c
> > 
> [ ... ]
> 
> > 
> > @@ -251,7 +251,7 @@ static int proc_path_manager(const struct ctl_table *ctl, int write,
> >  pm_type = MPTCP_PM_TYPE_KERNEL;
> >  else if (strncmp(pm_name, "userspace", MPTCP_PM_NAME_MAX) == 0)
> >  pm_type = MPTCP_PM_TYPE_USERSPACE;
> >  - pernet->pm_type = pm_type;
> >  + WRITE_ONCE(pernet->pm_type, pm_type);
> > 
> [Severity: High]
> This is a pre-existing issue, but can this sequential update race with socket
> creation and leave the socket's pm_type and ops mismatched?
> 
> If an administrator writes to the sysctl while a new socket is being created,
> could mptcp_pm_data_reset() in net/mptcp/pm.c interleave like this:
> 
> CPU1 (sysctl write)
> proc_path_manager()
>  mptcp_set_path_manager(pernet, pm_name); // Updates pernet->path_manager
> 
> CPU2 (socket creation)
> mptcp_pm_data_reset()
>  pm_type = mptcp_get_pm_type(net); // Reads old pm_type
>  ...
>  mptcp_get_path_manager(net, pm_name); // Reads new path_manager
> 
> CPU1 (sysctl write resumes)
> proc_path_manager()
>  WRITE_ONCE(pernet->pm_type, pm_type); // Updates pernet->pm_type
> 
> Would this leave the new socket corrupted with a contradictory path manager
> state, breaking MPTCP path management logic?

Hi,

I think that may happen. Maybe need anothor patch to fix this.

When I have time, I'll look this.

Thanks
Gang


> 
> > 
> > }
> >  }
> > 
> -- 
> Sashiko AI review · https://sashiko.dev/#/patchset/20260818094825.48446-1-gang.yan@linux.dev?part=3
>

  reply	other threads:[~2026-08-18 13:02 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-18  9:48 [PATCH mptcp-next v2 0/5] mptcp: avoid data-races around the sysctls Gang Yan
2026-08-18  9:48 ` [PATCH mptcp-next v2 1/5] mptcp: sched: change scheduler sysctl atomically Gang Yan
2026-08-18  9:59   ` sashiko-bot
2026-08-18 12:56     ` gang.yan
2026-08-18 15:50       ` Matthieu Baerts
2026-08-18  9:48 ` [PATCH mptcp-next v2 2/5] mptcp: pm: change path_manager " Gang Yan
2026-08-18 10:00   ` sashiko-bot
2026-08-18 12:57     ` gang.yan
2026-08-18 15:52       ` Matthieu Baerts
2026-08-18  9:48 ` [PATCH mptcp-next v2 3/5] mptcp: use READ_ONCE() over sysctls Gang Yan
2026-08-18 10:01   ` sashiko-bot
2026-08-18 13:02     ` gang.yan [this message]
2026-08-18 15:57       ` Matthieu Baerts
2026-08-18  9:48 ` [PATCH mptcp-next v2 4/5] Squash to "mptcp: pm: init and release mptcp_pm_ops" Gang Yan
2026-08-18 10:03   ` sashiko-bot
2026-08-18 13:06     ` gang.yan
2026-08-18  9:48 ` [PATCH mptcp-next v2 5/5] Squash to "bpf: Add mptcp packet scheduler struct_ops" Gang Yan
2026-08-18 11:13 ` [PATCH mptcp-next v2 0/5] mptcp: avoid data-races around the sysctls MPTCP CI

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=e0cd265f7d15246668d06c865adacf36943cc6c3@linux.dev \
    --to=gang.yan@linux.dev \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.