Netdev List
 help / color / mirror / Atom feed
From: Jiayuan Chen <jiayuan.chen@linux.dev>
To: Sabrina Dubroca <sd@queasysnail.net>, netdev@vger.kernel.org
Cc: Hyunwoo Kim <imv4bel@gmail.com>
Subject: Re: [PATCH net] strparser: make sure __strp_recv isn't running before tearing down the parser
Date: Mon, 28 Sep 2026 17:23:57 +0800	[thread overview]
Message-ID: <641ccc52-2677-4a52-aa11-e3b3c3c50920@linux.dev> (raw)
In-Reply-To: <4c80ea646f95abbd5beca2c081d129fe7d61a0aa.1790344112.git.sd@queasysnail.net>


On 9/25/26 9:51 PM, Sabrina Dubroca wrote:
> The comment above strp_done() claims that if strp is stopped,
> strp_recv will no longer be called. That's only true if the caller has
> a mechanism (eg locking) to guarantee that strp_recv() calls that
> started before strp_stop() have completed by the time we call
> strp_done().
>
> This adds a lock_sock/release_sock pair to guarantee that any
> in-flight strp_recv() (which runs under either bh_lock_sock or
> lock_sock, depending if it's called from ->sk_data_ready or strp_work)
> has completed.
>
> Only espintcp can be affected by this race condition, but this patch
> makes sure no future user of strp can have the bug.
>
> Reported-by: Hyunwoo Kim <imv4bel@gmail.com>
> Link: https://lore.kernel.org/all/aZgpkyTDU3aXe_V0@v4bel/
> Fixes: e27cca96cd68 ("xfrm: add espintcp (RFC 8229)")
> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
> ---
> This could crash on strp->sk ("general mode" of strp), but this mode
> has been here for 9 years and has never been used. I'll send a
> net-next patch to get rid of it.
>
>   net/strparser/strparser.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/net/strparser/strparser.c b/net/strparser/strparser.c
> index a23f4b4dfc67..401e67533005 100644
> --- a/net/strparser/strparser.c
> +++ b/net/strparser/strparser.c
> @@ -511,6 +511,10 @@ void strp_done(struct strparser *strp)
>   {
>   	WARN_ON(!strp->stopped);
>   
> +	lock_sock(strp->sk);
> +	/* sync with pending strp_recv */
> +	release_sock(strp->sk);
> +


Using sk directly inside strparser breaks the abstraction and that's why 
cb exists.

We can totally use it instead
     strp->cb.lock(strp);
     strp->cb.unlock(strp);


>   	cancel_delayed_work_sync(&strp->msg_timer_work);
>   	cancel_work_sync(&strp->work);
>   

  parent reply	other threads:[~2026-09-28  9:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-25 13:51 [PATCH net] strparser: make sure __strp_recv isn't running before tearing down the parser Sabrina Dubroca
2026-09-28  8:12 ` Sabrina Dubroca
2026-09-28  9:07 ` Hyunwoo Kim
2026-09-28  9:23 ` Jiayuan Chen [this message]
2026-09-28  9:32   ` Sabrina Dubroca

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=641ccc52-2677-4a52-aa11-e3b3c3c50920@linux.dev \
    --to=jiayuan.chen@linux.dev \
    --cc=imv4bel@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=sd@queasysnail.net \
    /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