All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: gregkh@linuxfoundation.org, stable@vger.kernel.org
Cc: kuba@kernel.org, matttbe@kernel.org,
	Nathan Chancellor <nathan@kernel.org>
Subject: [PATCH 6.6.y / 6.1.y] mptcp: Avoid unsequenced accesses to jiffies in mptcp_reset_tout_timer()
Date: Wed,  2 Dec 2026 10:44:50 -0700	[thread overview]
Message-ID: <20261202174449.2109291-2-nathan@kernel.org> (raw)
In-Reply-To: <2026120202-autopilot-december-2be2@gregkh>

commit 728a2abd15a767f662a44030931ea7b2959b4e88 upstream.

After a recent improvement in clang to warn on unsequenced accesses to
volatile variables [1], an instance appears in mptcp_reset_tout_timer(),
which can break the build with CONFIG_WERROR=y / W=e:

  net/mptcp/protocol.c:3044:20: error: unsequenced accesses to volatile qualified 'jiffies' [-Werror,-Wunsequenced]
   3044 |                         tcp_jiffies32 + jiffies + mptcp_close_timeout(sk);
        |                         ~~~~~~~~~~~~~   ^

Per C11 5.1.2.3.2, accessing a volatile object is a side effect. Per C11
6.5.2, unsequenced side effects on the same scalar object are undefined
behavior. Per C11 6.5.3, unless otherwise specified, side effects and
value computations of subexpressions are unsequenced within expressions.

Add an explicit sequence point by splitting the addition expression in
half, eliminating the undefined behavior and clearing up the warning.

Cc: stable@vger.kernel.org
Fixes: 76a13b315709 ("mptcp: invoke MP_FAIL response when needed")
Closes: https://github.com/ClangBuiltLinux/linux/issues/2193
Link: https://github.com/llvm/llvm-project/commit/955715460eaf9188c241c74750637fc82dfcc423 [1]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20261114-mptcp-wunsequenced-v1-1-707a73a6c172@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[nathan: Fix conflict in older trees]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 net/mptcp/protocol.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index d2ffd3b46de2..f742c89eab88 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2803,7 +2803,8 @@ void mptcp_reset_tout_timer(struct mptcp_sock *msk, unsigned long fail_tout)
 		return;
 
 	close_timeout = (unsigned long)inet_csk(sk)->icsk_mtup.probe_timestamp -
-			tcp_jiffies32 + jiffies + TCP_TIMEWAIT_LEN;
+			tcp_jiffies32;
+	close_timeout += jiffies + TCP_TIMEWAIT_LEN;
 
 	/* the close timeout takes precedence on the fail one, and here at least one of
 	 * them is active

base-commit: e2bb30811e063ce0db964484357973b855b06572
-- 
2.56.1


      reply	other threads:[~2026-12-02 17:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 13:13 FAILED: patch "[PATCH] mptcp: Avoid unsequenced accesses to jiffies in" failed to apply to 6.6-stable tree gregkh
2026-12-02 17:44 ` Nathan Chancellor [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=20261202174449.2109291-2-nathan@kernel.org \
    --to=nathan@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kuba@kernel.org \
    --cc=matttbe@kernel.org \
    --cc=stable@vger.kernel.org \
    /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.