🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20967

Re: [PATCH net-next v5 1/6] psp: support rx rekey operation

#20967
From: "Daniel Zahka"
Date: Mon, 23 Nov 2026 12:38
135 lines
15703 bytes
On Sat Nov 21, 2026 at 6:03 PM EST, netdev-bot+sashiko wrote:
> Thank you for your contribution! Sashiko AI review found more severe
> issue(s) in other patches of this series. This mail is only an FYI, in case
> you want to address the nit picks below when you respin.
>
> Low priority / nit picks for your consideration:
>
> - [Low] The uAPI doc for the rx-assoc op in
>   Documentation/netlink/specs/psp.yaml now reads "If the socket already…
> - [Low] psp_assocs_key_rotated() (net/psp/psp_sock.c) now does a plain
>   read-modify-write `pas->prev_generation |= ~PSP_GEN_VALID_MASK` on…
>
> --
>
> psp: support rx rekey operation
>
> This commit lets rx-assoc run on a socket that already has full PSP
> state. It creates a new psp_assoc that keeps the existing Tx state and
> gets new Rx state. The previous Rx SPI and generation are kept as a
> fallback, so packets sent by the peer before it switches keys are still
> accepted.
>
>> diff --git a/Documentation/netlink/specs/psp.yaml b/Documentation/netlink/specs/psp.yaml
>> index f3266763c3253..d5713f5d1af7e 100644
>> --- a/Documentation/netlink/specs/psp.yaml
>> +++ b/Documentation/netlink/specs/psp.yaml
>> @@ -265,7 +265,9 @@ operations:
>>  
>>      -
>>        name: rx-assoc
>> -      doc: Allocate a new Rx key + SPI pair, associate it with a socket.
>> +      doc: |
>> +        Allocate a new Rx key + SPI pair, associate it with a socket.
>> +        If the socket already has PSP state, rekey its Rx direction.
>
> [Severity: Low]
> Does this doc match the behaviour for every socket that has PSP state?
> psp_sock_rx_rekey() in net/psp/psp_sock.c rejects the rekey unless both
> directions are set up:
>
> 	if (!prev->tx.spi || !prev->peer_tx) {
> 		NL_SET_ERR_MSG(extack, "Socket PSP state is not fully established");
> 		return -EBUSY;
> 	}
>
> So a second rx-assoc on a socket that only has Rx state still fails with
> -EBUSY.
>
> psp.rst describes this precondition, but the YAML spec, which ynl and
> the generated docs use, does not. Should the op doc say something like
> "If the socket already has fully established PSP state, rekey its Rx
> direction."?
>
>>        attribute-set: assoc
>>        do:
>>          request:
>
> [ ... ]
>
>> diff --git a/net/psp/psp_sock.c b/net/psp/psp_sock.c
>> index f2cba3fa3a235..c1e38845f08c3 100644
>> --- a/net/psp/psp_sock.c
>> +++ b/net/psp/psp_sock.c
>
> [ ... ]
>
>> @@ -302,8 +333,21 @@ void psp_assocs_key_rotated(struct psp_dev *psd)
>>  	 */
>>  	list_for_each_entry_safe(pas, next, &psd->prev_assocs, assocs_list) {
>>  		pas->generation |= ~PSP_GEN_VALID_MASK;
>> +		pas->prev_generation |= ~PSP_GEN_VALID_MASK;
>>  		psd->stats.stales++;
>>  	}
>> +
>> +	/* Don't allow SPI from two generations ago to alias one from the
>> +	 * current generation. Rx rekeying under the same device key generation
>> +	 * is currently permitted, so skip if the previous SPI is from just one
>> +	 * generation ago.
>> +	 */
>> +	list_for_each_entry(pas, &psd->active_assocs, assocs_list) {
>> +		if ((pas->rx.spi ^ pas->prev_spi) &
>> +		    cpu_to_be32(PSP_SPI_KEY_PHASE))
>> +			pas->prev_generation |= ~PSP_GEN_VALID_MASK;
>> +	}
>
> [Severity: Low]
> Can these plain writes to prev_generation race with the Rx datapath?
>
> These assocs are still published through sk->psp_assoc. The only lock
> held here is psd->lock, which the pre-hook of psp_nl_key_rotate_doit()
> takes.
>
> The reader in psp_pse_matches_pas() runs without psd->lock and without
> READ_ONCE():
>
> 	(pas->prev_spi && pas->prev_spi == pse->spi &&
> 	 pas->prev_generation == pse->generation));
>
> It is reached from paths that hold only the socket lock or RCU:
>
>   tcp_v4_do_rcv() / tcp_v6_do_rcv()
>     -> psp_sk_rx_policy_check()
>       -> __psp_sk_rx_policy_check()
>         -> psp_pse_matches_pas()
>
>   psp_twsk_rx_policy_check()  (RCU only)
>     -> __psp_sk_rx_policy_check()
>       -> psp_pse_matches_pas()
>
> So a key-rotate running while PSP packets arrive on an rx-rekeyed socket
> is an unannotated data race that KCSAN would report. The field is a u8,
> so it can't tear, and the result is unordered against the rotation in
> any case.
>
> The existing pas->generation write already works this way. This patch
> applies the same pattern to a new field that the datapath reads, and
> adds a second write site in the active_assocs loop.
>
> Would it make sense to use WRITE_ONCE() here and READ_ONCE() in
> psp_pse_matches_pas()?
>
>> +
>>  	list_splice_init(&psd->prev_assocs, &psd->stale_assocs);
>>  	list_splice_init(&psd->active_assocs, &psd->prev_assocs);

This review is the same as two revisions ago, so I'll just refer to:
https://lore.kernel.org/all/DMQOJPJ4AT7P.3DUQ9O213TZBI@gmail.com/
Technical Details
Message-ID: <DN2LHJ9Y8KM2.1GHH6E9738JCS@gmail.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369344-linux-kernel-netdev=dewy.ru
References: <20261118-psp-v5-1-b9ec840e0296@gmail.com> <179530218118.3135.6547111851222246419@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369344-linux-kernel-netdev=dewy.ru
From: daniel.zahka@gmail.com ("Daniel Zahka")
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v5 1/6] psp: support rx rekey operation
Date: Mon, 23 Nov 2026 07:38:51 -0500
Organization: Usenet Network
Message-ID: <DN2LHJ9Y8KM2.1GHH6E9738JCS@gmail.com>
References: <20261118-psp-v5-1-b9ec840e0296@gmail.com> <179530218118.3135.6547111851222246419@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network; logging-data="3876091"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:CX5m8CM0xz/vNgDSIlqfGbWbDLo= sha256:FwxdwBTVGdqF42pD5ut1PIkWHFZxqrtKwpMc6ryMvng= sha1:MpUq8hycWO2AqwP+dWTFB6KMXdU= sha256:VfLj/A6P43hZG0f9n1cs82I+Qtuz0CLTXUMxDQeJwRM=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 00683125DAD; Mon, 23 Nov 2026 15:39:14 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qLSt_cAwVSd5; Mon, 23 Nov 2026 15:39:09 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-369344-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 2C0C3125DAA; Mon, 23 Nov 2026 15:39:00 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id C8BC325E63; Mon, 23 Nov 2026 12:38:57 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795437534; b=CfaDXaWXHXZvNZyANKS1CdmsTAmVm7hoM1l21ojE5kS4ZXW0jcPUotewkkIeSjbhRynP tSVhuDENLyFswvthyQ2efr1Y/mem+PeBf3glndUuU23SZk6CIxviuCSmyucIypVqK6m9j DJHvkm48A/dCF4wYnnWDSWE/bwnTRXnuX9SwOu/0FOIYzDE6uyySOP3s+UtPDSe525To9 ZOqreaQpkqGUdmZYnsu7LmmoZZyIO+Pa8hXm5pA2wqQnmNzcAiKROdb6dxUwjF8Ob+D6L ThBB0Ifjpu1+C+EPuPyoD5EQD9BZcSEwk4kaoAuPjbCtlYX7AM40p8pLIiLIDuyIk/g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795437534; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature: X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State: X-Gm-Gg:X-Received:Received:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: Mime-Version:Content-Transfer-Encoding:Content-Type:Date:Message-Id: Subject:From:To:Cc:X-Mailer:References:In-Reply-To; bh=59RxTHGvhltoNw2gc0/13upvGG9pwIkmUmOzptR+Lb0=; b=TEtP6WxTaXHWwxlSptAxi6LGaMMLIrq927cHZO6OeqfRhW2/WpAiA1Vc6pyRCVpKObBl 9by4OwayJm/J2wd5/IsfXIg4yjyPaLiD/nfl2iC/uEX8nMv1EKl/uBWemDh6m6aSL+0lK 9KtTNwsEtomwJLvYAMNndYpqIcOj9Cf4qcYCL+o3DFOzPy7dtytSBzEqa9HXfoyqt9PlH D3SfgKeKvw+PkTznmOTGiiIzhlmT+OaieGMyyjVORAnaK9BwFfxbz04rxUaRA78dUTAh3 d3hTX5CIzayZ+bWXvxtzMMkorB3xUqONzVmjr8hulUmjv1jAfT0IaRHCTTQLfPEbWXg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ieGbhYkm; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C1EB8606A687; Mon, 23 Nov 2026 12:38:54 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ieGbhYkm
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.181
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795437534; b=FXyg+dbSYhowrxQzrR+d0seVfFoZySxi3BJjOMyAZ8Lsscz5u321A0hWeDY+TQGc2xFh aJg37o+p6yCZwFj5wv5ILvZwp+3j9Jnen5QkhAYLH31Jl3CC9VzB5pZiKUy/AVuaoO19X 0KxmDfq8t0zQ6atS1tb/1xiJAmiDbg9u0eo80XL0h12pwPKUDiVThyhYjYI9VSOR8NG2n KYA78SjE6cI6RAQTW1k2OvmiuI09cp8jqVqsfb5pJTItINHGgN6gKGPn/Fyzx1zmbLkZ9 DMME0qUzXHfubFK++XN5BmXCpdYG1aRZHRAo8fAGOwtF4iCjwwpi/e3Zr+qCambKOOw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795437534; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Mime-Version:Content-Transfer-Encoding:Content-Type:Date:Message-Id: Subject:From:To:Cc:X-Mailer:References:In-Reply-To; bh=59RxTHGvhltoNw2gc0/13upvGG9pwIkmUmOzptR+Lb0=; b=v5YFbOPQ/QTQVMjm3TeaVa/CeG/zGtbELjgUf0LjHJusXx4ij+O4ht1ZJ/U8nkvxPhHE CwlY6zSwKw/9ToQMA6UTF9NnwqwydOe7V/IKvgfVlPQ21lDa3ss/oFUqsf3s+vSK/eZBa oSOM3cSoq42FBVCvVo4zMlojH0tscQcxgV0qxNehqntnFX57Fgu2bXioc9xZFBQ/UEiWp xfSvZFFSXqlofXARzIzujqq5uP0BMAhdxQ/l1nj2mT2NRkLSgCVOzUkq3KDhslv9KV9xO 9PnO1MRvWsv62kjjEAbJzEZD5WSiNPOHU6zo5m5BKzuAwcAOC2LR5BdL0oFEzOGNCgA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ieGbhYkm; arc=none smtp.remote-ip=209.85.128.181
X-Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8FA05606A327 for <netdev@vger.kernel.org>; Mon, 23 Nov 2026 12:38:53 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8FA05606A327
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-8b51389f58cso32796797b3.3 for <netdev@vger.kernel.org>; Mon, 23 Nov 2026 04:38:53 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795437533; x=1796042333; darn=vger.kernel.org; h=in-reply-to:references:cc:to:from:subject:message-id:date :content-type:content-transfer-encoding:mime-version:from:to:cc :subject:date:message-id:reply-to:content-type; bh=59RxTHGvhltoNw2gc0/13upvGG9pwIkmUmOzptR+Lb0=; b=ieGbhYkmA1tVgB8nYy25uSifUEyfNr8bR6537VLozGv55qw9nCYaRuq9fAxvEmCRMq MTqXrhD+3lp5K8wNSXipcOgFNc/jazfFRTKaErMwRbDBigni1Tb19BJY2WoKKTi0ep9s UjF0IVRN+sVlNPIACAkprYnZ0OvYo5JDiWaty9hcMySXmPn+ddeePMFFVt3Hhb0bwLbb XVSw+IGS2sDadCblffLCz7CnkDF7L4XIR89egfCjJefrxkrx6BgzEkyAcxdenqz4+GnO S9o3fIUHacY7saE0XJ9vYdy8r/BVcuXNE9yh3x5s4FT53/9eTtvj6SiefaVycA4XGlEl FmQA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795437533; x=1796042333; h=in-reply-to:references:cc:to:from:subject:message-id:date :content-type:content-transfer-encoding:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=59RxTHGvhltoNw2gc0/13upvGG9pwIkmUmOzptR+Lb0=; b=O514AOHolQLfNxnA0reJ9LCbZtyOUGBIUqk+rzCJpz6yPMYfBZ9yW0zKpYNscfrB9Y z37ur4ajlf2IZnSv8WVlauajeMt1S5J7w8LWc8l89qyNbwITGgq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iQ=
X-Received: by 2002:a05:690c:3749:b0:8a9:d5f2:f5a6 with SMTP id 00721157ae682-8b5204cd1b8mr37167077b3.67.1795437532672; Mon, 23 Nov 2026 04:38:52 -0800 (PST)
X-Received: from localhost ([2600:1700:4a51:2210::11]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b5201b8cdbsm43605117b3.1.2026.11.23.04.38.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Nov 2026 04:38:52 -0800 (PST)
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-Cc: <kuba@kernel.org>, <willemdebruijn.kernel@gmail.com>, <davem@davemloft.net>, <edumazet@kernel.org>, <pabeni@redhat.com>, <horms@kernel.org>, <corbet@lwn.net>, <skhan@linuxfoundation.org>, <rdunlap@infradead.org>, <donald.hunter@gmail.com>, <andrew+netdev@lunn.ch>, <shuah@kernel.org>, <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-doc@vger.kernel.org>, <linux-kselftest@vger.kernel.org>, <willemb@google.com>
X-Mailer: aerc 0.21.0-threadmapfix
X-In-Reply-To: <179530218118.3135.6547111851222246419@kernel.org>