From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794830699; b=kq6HGdta+MDxLH+qcjS51krJhzzreyNXZaJ2brB9BXkF0Twy+bYAaIxLfQvviL7keLsq SblMhVsIZnw6ilabD2LkFaSDQ3KLwMMA+hP37j/JVl4Nw+dfSxgFWhQtRAFweh9ackfQg kNXEdLAoO0uqOrYLqM9olzDM4R1UIXB8NpEbEbGzeU3bOrvJZUyaSO8+PpUJewUeggvYk GZNU1gbjslEbrM4wgJHfiCmvtIOAwCybpnt24g113IXC2mE8lxDg0krON7bnqIaQ55nqB lcD61TLgzQ/ZbT2o/PI3Y0D/ucIPSLrACHHekXtskoE/yDaxK/0iS09mZfFFqaZS0Iw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794830699; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=T8x2RfWqC4sWMy3tixcc28MUcdJoxePFEMTBw5xM84A=; b=aBu7pNEhe2sEbgKTgFMqAO9sEaZmWQ2v5QVVp31/Ps8Q+RS8ykdP4dtruojNH6TmLKrm Uyz8pVjtse21mBMAMqxGsja9ToXe5RgvXFP21VKmsIWXxOsZwPev3KyCzHhE03r0CVakM uC8opQG1CAhLsn+lWq2QXo/RSMB2MY0qgiHI8D0465pIR7hOKq98dczrrwPdFvFc/74CX 3Tawek750kDGsXKi9uAPxJVhnfsv6I9KWn9gM/I5k6y3Ytibzn5JGUpXgUyBFQEkn3YCa Cm46oF02rP1hRXJwoSia+oZMVlPdOfvevoxF5eBcB6mMd8WAy2Tg9/zJiMPtegBgfBQ== 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=0I5X9Fro; arc=none smtp.remote-ip=74.125.224.48 Received: from mail-yx1-f48.google.com (mail-yx1-f48.google.com [74.125.224.48]) (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 D0C00606A33D for ; Mon, 16 Nov 2026 12:04:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D0C00606A33D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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=0I5X9Fro Received: by mail-yx1-f48.google.com with SMTP id 956f58d0204a3-67db6d4054eso850891d50.1 for ; Mon, 16 Nov 2026 04:04:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794830698; x=1795435498; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=T8x2RfWqC4sWMy3tixcc28MUcdJoxePFEMTBw5xM84A=; b=0I5X9Fro5lTpqrbTIJJvYIobMHUh80nHVy51NkUgs0cZyJk7aueiHYWXPwaLeIOvZN qwJGzc6RrLUvj9I5DLGaQTXn1ewCUUSnKPbTTE7o5Ysx12G9MF3+NIe7DPP1Wtsr6BQa CoqU9SBM+he7p8Sxw0U51krnBadTzBWn+2yiALp24XnEhLwbfT/U3YB6/UFSmsxTSE7D ZSgoMOTZywFZ3HogO+Od+P3dPDl8TBVWHtCJmlWqMbhYbRvw8ansbw2YJ38ttYsXTWpB z0PtVq//0Ehsdgww5oEwRifxndf9H6qlH7wm4/akCrejK2nU/TgL+s4a8vZQFHwHPigH nwVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794830698; x=1795435498; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=T8x2RfWqC4sWMy3tixcc28MUcdJoxePFEMTBw5xM84A=; b=dO8MriiBG/5o581OSgQJQGYvCO5kh6okfSyrTGQbz9KMMBE/bNUvyBZSM2N8xmrdbC zfl64EYCQ/9oF21zg9MgfM/c87gDkrIvSn5p6aV2vHF9OF3eI5h+nmKwuX4/FM3FkBcL PPhC8edoYNcoh+zgWq0YdH4M/W9JlP/6uLPTcLMRO6oxmj70dUz0egAuCouKGXMUKc7H 0YmtPoPYZxWQ7O9ZShyo5RgkUk2RtnLrcCNibkySYNq2ezVphCKuGVGzCQk+7STG35zU JQECnSRmxAiRxqpl7a6k3bQDQPoBEmDIH4IxZXlp4Phm6l3jK5eRG1pnk30ddTMcz2T6 V5fA== X-Forwarded-Encrypted: i=1; AL+hErEv7PS2407+xtDcXr0wPpCm+F20hns8CSEyhXn/ToLvwGy0fWNfKqJLhzz/T3mV6ZJfLvpB243vVa4zUos=@vger.kernel.org X-Gm-Message-State: APuU4Z/rwgLm7Grcwo1wqLyOuZ+6pTuGnGw3NnY13a5OISOVhhoWI4Z5 miMOxqsLgfsSM99/QvzzQC/Emg7kXXDtyMIZ3X8jfzjGIlLeK3BC62V8 X-Gm-Gg: AZFdTZd+PvqyBD/F8XFjxxs5UKigcOD7TWTG+KZdQ0xk8LKrMdyfBULK50KFmrWK6QR Ycx01eZ9uSozrMWN4hyhGT/z8tMwWYlBpRBIY051JRyqT0tieQ48bv1xXEnTbqMaLOZW4gqtWdc LLrUU3k3mddl/DSU+UCUXfq31Jl1CbbqMOhqB8LEKWT1ewBkYWdemOEzr1swkYFBf9/e/19xvi7 Sf/kom6+lzViimZ5/Bv+mRj2zVRL0863Qh5jwlfIF9NcxDrHoX7pj1/zIxBaYVajMnZgGKC15xe 6vq5EEYELvxyL7BSD6ZY1rczcA65aiQOQL+5lX8aIECVjLSRDpTuRIjtKzKHpv3u0wqDftrbgut TREXUDBw3xbW4LxKf7daptX1dAuAQK5BcSYsaP6dXBrRBgrOH9WZOr6sCS9kNgfkHT46COLOiUn g9kPs0uQ1brVrhB2AwaMOnjmWsNwy8Di7ivBsdb145FRxvYALlhR32aQXIv0vfyUkfHl5drCYO9 4gUve/UHXu35imfR7FWkFdNw0yBiYHKVS7e9LXt5ZzNAiDbXSsfrU54un+kCmDkYFRQs8T7oFPr 7KLahEkDHGvhYDvdCQkLCd+itBpr9Dc3qcE/HZH/rs8B2Yo0 X-Received: by 2002:a05:690e:1c1b:b0:67c:b95:6757 with SMTP id 956f58d0204a3-67d897366a7mr6743663d50.80.1794830697852; Mon, 16 Nov 2026 04:04:57 -0800 (PST) Received: from localhost ([2a03:2880:30ff:75::]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-67d8a59e70asm9706309d50.10.2026.11.16.04.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Nov 2026 04:04:55 -0800 (PST) From: Daniel Zahka Date: Mon, 16 Nov 2026 04:04:37 -0800 Subject: [PATCH net-next v4 2/5] psp: support tx rekey operation X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261116-psp-v4-2-1a599df2aefa@gmail.com> References: <20261116-psp-v4-0-1a599df2aefa@gmail.com> In-Reply-To: <20261116-psp-v4-0-1a599df2aefa@gmail.com> To: Jakub Kicinski , Willem de Bruijn , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , Jonathan Corbet , Shuah Khan , Randy Dunlap , Donald Hunter , Andrew Lunn , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Willem de Bruijn X-Mailer: b4 0.13.0 The tx rekey operation creates a new psp_assoc with the same rx state, but with new tx state. The new association is spliced into the socket with RCU to be used immediately in the tx path. Drivers that use on-device tx key storage need additional logic to delay key deletion until after any in-flight users of the key have been drained, so return -EOPNOTSUPP for now. Reviewed-by: Willem de Bruijn Signed-off-by: Daniel Zahka --- v3: - move the replaced assoc to psd->stale_assocs, so a rotation racing with its free doesn't count the socket twice in stale-events - document that the previous rx SPI also stops being accepted once its device key is rotated out - drop the claim that the peer accepts both the old and new SPI after a tx rekey - document tx rekey in the tx-assoc op doc in psp.yaml v2: - place new assoc on pas->assocs list instead of psd->active assocs list - reject tx rekey on SADB devices until deferred tx key deletion lands --- Documentation/netlink/specs/psp.yaml | 4 ++- Documentation/networking/psp.rst | 5 +++- net/psp/psp_sock.c | 57 ++++++++++++++++++++++++++++++++---- 3 files changed, 58 insertions(+), 8 deletions(-) diff --git a/Documentation/netlink/specs/psp.yaml b/Documentation/netlink/specs/psp.yaml index d5713f5d1af7..f6af1a510d17 100644 --- a/Documentation/netlink/specs/psp.yaml +++ b/Documentation/netlink/specs/psp.yaml @@ -283,7 +283,9 @@ operations: post: psp-device-unlock - name: tx-assoc - doc: Add a PSP Tx association. + doc: | + Add a PSP Tx association. + If the socket already has a Tx association, rekey its Tx direction. attribute-set: assoc do: request: diff --git a/Documentation/networking/psp.rst b/Documentation/networking/psp.rst index fab797506b0a..43f222b38d3d 100644 --- a/Documentation/networking/psp.rst +++ b/Documentation/networking/psp.rst @@ -145,7 +145,8 @@ Rekeying A connection which has completed the exchange described above and is in the "PSP Full" state can be rekeyed in place without being torn -down, using the same netlink calls as in connection setup. +down. The Tx and Rx directions are rekeyed separately using the same +netlink calls as in connection setup. ``rx-assoc`` allocates a new Rx key and SPI, which should be passed to the peer exactly as during the initial exchange. The SPI which was @@ -154,6 +155,8 @@ next Rx rekey, or until the device key it was derived from has been rotated out, so packets the peer sent before it learned the new SPI are still received. +``tx-assoc`` installs a new Tx key, which takes effect immediately. + A rekey is rejected with ``-EINVAL`` if it would change the PSP device or the PSP version of the association. It is rejected with ``-EBUSY`` if the socket has not completed its initial exchange in both diff --git a/net/psp/psp_sock.c b/net/psp/psp_sock.c index c1e38845f08c..d497f41c483e 100644 --- a/net/psp/psp_sock.c +++ b/net/psp/psp_sock.c @@ -280,6 +280,53 @@ psp_sock_set_tx_key(struct sock *sk, struct psp_dev *psd, struct psp_assoc *pas, return err; } +static int +psp_sock_tx_rekey(struct sock *sk, struct psp_dev *psd, struct psp_assoc *pas, + struct psp_key_parsed *key, struct netlink_ext_ack *extack) +{ + struct psp_assoc *new; + int err; + + if (psp_dev_has_sadb(psd)) { + NL_SET_ERR_MSG(extack, "Tx rekey not supported on this device"); + return -EOPNOTSUPP; + } + if (!pas->peer_tx) { + NL_SET_ERR_MSG(extack, "Socket PSP state is not fully established"); + return -EBUSY; + } + + new = kzalloc_flex(*new, drv_data, psd->caps->assoc_drv_spc, + GFP_KERNEL_ACCOUNT); + if (!new) + return -ENOMEM; + + new->psd = pas->psd; + new->dev_id = pas->dev_id; + new->generation = pas->generation; + new->version = pas->version; + new->peer_tx = 1; + new->prev_spi = pas->prev_spi; + new->prev_generation = pas->prev_generation; + refcount_set(&new->refcnt, 1); + memcpy(&new->rx, &pas->rx, sizeof(new->rx)); + + err = psp_assoc_set_tx(psd, new, key, extack); + if (err) { + kfree(new); + return err; + } + + psp_dev_get(new->psd); + list_add(&new->assocs_list, &pas->assocs_list); + list_move(&pas->assocs_list, &psd->stale_assocs); + + rcu_assign_pointer(sk->psp_assoc, new); + psp_assoc_put(pas); + + return 0; +} + int psp_sock_assoc_set_tx(struct sock *sk, struct psp_dev *psd, u32 version, struct psp_key_parsed *key, struct netlink_ext_ack *extack) @@ -312,13 +359,11 @@ int psp_sock_assoc_set_tx(struct sock *sk, struct psp_dev *psd, err = -EINVAL; goto exit_unlock; } - if (pas->tx.spi) { - NL_SET_ERR_MSG(extack, "Tx key already set"); - err = -EBUSY; - goto exit_unlock; - } + if (pas->tx.spi) + err = psp_sock_tx_rekey(sk, psd, pas, key, extack); + else + err = psp_sock_set_tx_key(sk, psd, pas, key, extack); - err = psp_sock_set_tx_key(sk, psd, pas, key, extack); exit_unlock: release_sock(sk); return err; -- 2.52.1