From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-a2-smtp.messagingengine.com (fout-a2-smtp.messagingengine.com [103.168.172.145]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D57C45FFC8 for ; Mon, 28 Sep 2026 09:32:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.145 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790587952; cv=none; b=af/6Xy+9XZfVQajSRE6tqKTemZZsJL6LM5bs5KAPtL/tjy7GehQhtWgUMc8LMEDNawvDper8VCAeVfcpHBm/GXAS58K3w38BPnri7zJEk7r83C9gcZfBYTBCbifHErZeWP1PzEfBNOlr8JA9wDEpHiW3ZrGxEroRleIMNeZ5FO4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790587952; c=relaxed/simple; bh=zYg/f6PiMWHyhfP3EMjkG4qA98Ryk0MNjoX+bMB0eBs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WEs5b0vlCLsKI0XBjgKHUBv9jm9v8HWXShBt39paswXo01zIoNRaYbdgQh6oOCy+WLze+wM4LBdbr7WEedGmu+7R/xttHAK7toQD/7UUBWoEbFceErfaJ4K9yeFkvdpnM66BBBwFrg6SF+TyBlYImlf/Xbgu9MicsN0tP4pLEdY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=queasysnail.net; spf=pass smtp.mailfrom=queasysnail.net; dkim=pass (2048-bit key) header.d=queasysnail.net header.i=@queasysnail.net header.b=p0wpI8yK; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=NuW34iY8; arc=none smtp.client-ip=103.168.172.145 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=queasysnail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=queasysnail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=queasysnail.net header.i=@queasysnail.net header.b="p0wpI8yK"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="NuW34iY8" Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfout.phl.internal (Postfix) with ESMTP id 1A673EC00E3; Mon, 28 Sep 2026 05:32:28 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-09.internal (MEProxy); Mon, 28 Sep 2026 05:32:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=queasysnail.net; h=cc:cc:content-transfer-encoding:content-type:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=fm2; t=1790587948; x=1790674348; bh=7h/HLu2+wsYLHJQn9fZNG/I1kfMujPI3 51k00oQemuM=; b=p0wpI8yKpUwTbCeIObjcNyjWiD2rF3/bfJwwQ+VMoo+PsZOi w6iyightYhfycrKlRawvSu+RnAvSwbrF/sSX1EYeBFDCAj/aY1V3wn7XBP9W5Vi9 gy2i4a8t14rE+YwjsCXfZWElIgFg2WxXs8paDS9tU2rPJtvjFWCD4W1VEzei3piY fRiMHNRA3s65vKXZHMmJuSsUNnJrcHndMZnMN4uYl7jnNXpz8wzzSW4jeWjVRCcv Gs3s5YiFQJNH4jWLwIBhteObw5WpYyn5+kDgPGpS7msW2DqvMLMG5YrSi3uaQNHz h/Qjw4efKLA00iycRJWBCrOHB9q5sVuCdUaEmA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1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JGo/79uH 3M6KQRABaKfb85tBBG3OS2El2CX9LLJhYiaH2U3JHP5g29PPTs6JjcHw7xHA X-ME-Proxy: Feedback-ID: i934648bf:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 28 Sep 2026 05:32:27 -0400 (EDT) Date: Mon, 28 Sep 2026 11:32:25 +0200 From: Sabrina Dubroca To: Jiayuan Chen Cc: netdev@vger.kernel.org, Hyunwoo Kim Subject: Re: [PATCH net] strparser: make sure __strp_recv isn't running before tearing down the parser Message-ID: References: <4c80ea646f95abbd5beca2c081d129fe7d61a0aa.1790344112.git.sd@queasysnail.net> <641ccc52-2677-4a52-aa11-e3b3c3c50920@linux.dev> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <641ccc52-2677-4a52-aa11-e3b3c3c50920@linux.dev> 2026-09-28, 17:23:57 +0800, Jiayuan Chen wrote: > > 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 > > Link: https://lore.kernel.org/all/aZgpkyTDU3aXe_V0@v4bel/ > > Fixes: e27cca96cd68 ("xfrm: add espintcp (RFC 8229)") > > Signed-off-by: Sabrina Dubroca > > --- > > 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); That's what I'm saying above the diffstat. This cb abstraction hasn't been used in the 9 years it's existed, we should get rid of those useless indirections (I'll have the patch out on netdev this week). -- Sabrina