MPTCP Linux Development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hang Nan" <2122295973@qq.com>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH net v5 2/3] net: mptcp: reject token 0 in mptcp_token_get_sock()
Date: Tue, 17 Nov 2026 15:11:03 +0000	[thread overview]
Message-ID: <sashiko-outbox-219033@kernel.org> (raw)
In-Reply-To: <tencent_46FC62D4DE8FB8E6C90049F5AB28BDAA8C05@qq.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mptcp: missing EXPORT_SYMBOL_GPL for mptcp_token_exists()
--

commit 58d873c76950c5892687659dc3383bb38a22332f
Author: Hang Nan <2122295973@qq.com>

net: mptcp: reject token 0 in mptcp_token_get_sock()

This commit rejects token 0 in mptcp_token_get_sock() so that lookups cannot
match sockets that are being torn down or have not been hashed yet, and adds
a KUnit test covering this case.

> diff --git a/net/mptcp/token_test.c b/net/mptcp/token_test.c
> index be9acce8a5673..2418d392ff7b9 100644
> --- a/net/mptcp/token_test.c
> +++ b/net/mptcp/token_test.c
> @@ -132,11 +132,62 @@ static void mptcp_token_test_destroyed(struct kunit *test)
>  	mptcp_token_destroy(msk);
>  }
>  
> +static void mptcp_token_test_zero(struct kunit *test)
> +{
> +	struct mptcp_subflow_request_sock *req = build_req_sock(test);
> +	struct mptcp_sock *msk = build_msk(test);
> +	struct mptcp_sock *null_msk = NULL;
> +	u32 token = 0;
> +	int i;
> +
> +	/* An empty chain does not answer a lookup for token 0 either. */
> +	KUNIT_EXPECT_PTR_EQ(test, null_msk, mptcp_token_get_sock(&init_net, 0));
> +
> +	/* Build the state a socket being torn down, or one that has just been
> +	 * allocated, presents to a reader: hashed and carrying token 0.  A
> +	 * lookup for token 0 only reaches a socket that hashes to bucket 0,
> +	 * and the token a connection gets is random, so retry until one lands
> +	 * there; mptcp_token_exists() reports that without going through the
> +	 * guarded lookup.
> +	 */
> +	for (i = 0; i < (1 << 20); i++) {
> +		/* the token is derived from local_key, so vary it */
> +		mptcp_subflow_rsk((struct request_sock *)req)->local_key = i + 1;
> +
> +		if (mptcp_token_new_request((struct request_sock *)req))
> +			continue;
> +
> +		token = req->token;
> +		msk->token = token;
> +		if (!mptcp_token_accept(req, msk))
> +			continue;
> +
> +		WRITE_ONCE(msk->token, 0);
> +		if (mptcp_token_exists(0))
> +			break;

[Severity: Medium]
Does calling mptcp_token_exists() here break the build when
CONFIG_MPTCP_KUNIT_TEST=m?

MPTCP is built-in while mptcp_token_test can be built as a module, and
unlike the other token helpers in net/mptcp/token.c, mptcp_token_exists() is
not exported under #if IS_MODULE(CONFIG_MPTCP_KUNIT_TEST), causing modpost
to fail with an undefined symbol error.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_BB8DA72524E32FD374B8B2950B247B62E207@qq.com?part=2

  parent reply	other threads:[~2026-11-17 15:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20261116145829.96849-1-2122295973@qq.com>
2026-11-16 14:58 ` [PATCH net v5 1/3] net: mptcp: take token lookup references with acquire ordering Hang Nan
2026-11-16 14:58 ` [PATCH net v5 2/3] net: mptcp: reject token 0 in mptcp_token_get_sock() Hang Nan
2026-11-17  6:44   ` kernel test robot
2026-11-17 15:11   ` sashiko-bot [this message]
2026-11-16 14:58 ` [PATCH net v5 3/3] net: mptcp: verify the token slot in mptcp_token_iter_next() Hang Nan

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-219033@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=2122295973@qq.com \
    --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