From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.41 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795010984; b=P6fYTfbbMk37l6f5pMV3aeJ6J7kcFZTWiomw4AyEMSKCSV1Hx5oDE55vKpJYN/quLc82 IYs0SaFG6u0pc0ugWhWOY7tbuDsnn8uQhsl+Ej4w20EiiRRoM6/KkoIGP345e+exc/2Np zQMxZ0q1TzOAmGIam2fPkTcq0zTaMVOFB3WUz+SJ/7D2BdIJwtevTK37rRVjsvbw0bCpm +HtIO6gfUy3schauM9GW4+eOXR2lkpywUszulKlfrpk/gDBmw0oX8q7ypGLcG8IA0FA00 vwQLUfbtktml4ImnIrbW/VbjODnCNvt+m67T6MCceAR3kGRlYCAErXZTsrmLGMjBikA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795010984; 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=aEQVrHNS4qhZDwAhTjBmVqqfvVI4mm+KFSqmVh+ZsQZAK7xZr8LkY3YVp12/Q1Qkb1Hg 3lCD4uEs6BTmGaM2fyJAxUujJDsBFxTCSd7dck77nPp3+bK+Psv24pPfKTyyKmUcGnQsg 2wIZjUMPSJyCgfePyABahpmF+k8JK5TWLfGTEXgtKmEZFkcmE7SaKUWp4BLbfFMcOYzCa GKl3DJgUC0aIDSHDA17irB2kqLw59CVqCF7dNURsngZiJcRxMDtaWzwDSrP+iGdaCsQiJ cnZQ3vCRSixVtmGlTwu9P0tzgv9vtOcyLaROY/75v+PcK21+FlRwdIXptzoq/2dllbA== 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=sFFEWmQg; arc=none smtp.remote-ip=209.85.210.41 Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (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 9A37460A2605 for ; Wed, 18 Nov 2026 14:09:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9A37460A2605 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=sFFEWmQg Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-86103aaac12so1164868a34.0 for ; Wed, 18 Nov 2026 06:09:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795010982; x=1795615782; 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=sFFEWmQg7vNncfij1+tYVntU7ZjPo939n/lJjHpag/VXJRS5tBG7d8b4tAJJp08jTb sh8dYBYB2qEXxquBGgNARaSIrh4qDIYt//KoeIZd9rtWBc0jRPG04n4ZJ82nZ3ysHvgO /t7EWdSPRYUU2mz28gcHoXIPwVq+1ZEGj/fwH3Ke7aVeIVj9Gw/x33Ng/pVigk83WoaZ JWioVHcEds7pr6A3hGszhC2qrbRMO8tCCODs2vo+5jrBKDK7gEh7c77N0CqDkoI7gBXQ 97hc53aWENm4x/9aZJwCjTIum5+1CxLPJVi/Qg3H80lg5AQWtLhrOjL6dwILGkHjDiVK tsaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795010982; x=1795615782; 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=HdvbIwgp9KVVs31zlwgx1WIQ5zei7SrKqx9TjT0InfmKUuXcTd5XK1KR0SHPmsNITH aa+JvZM3aIt1egRpjGkg+xeu84sFWFnKvxINh3pCuAus/MmV7cuEtyQf9qym9S5BCNvn I5oFndHIjBhjGHHggkfLEAdnCzaIPnFyOtItT7SYs8OXUt2swba1HouDFpiAmdPWV79k qQwyeCiF9nbwMjeN3VDwPUtM67xmKfk9GfgM3EVWlz1AlSiDaynNBB05Bj4qoGoKRzPf cY5eR1EB2i2h+99K4sgvPANEOziC+WwRROthieDPZBAZElxZPaItzDSr8F6SZ30s9lfp fgjg== X-Forwarded-Encrypted: i=1; AL+hErHoj+EXIwX8/Q3S5dOlnZmr47J0qofvAHgnA432U3LHUxp8DqnzW0wEC8qZQPHqKMhDLB1JRHQd52w=@vger.kernel.org X-Gm-Message-State: APuU4Z/MaNt/jGW0ukomDzQa7wWm9MJpd1hFqj2EXHkyeomxJmqIyrV3 muTSBxaO4lVd0rcGQ3DDnHZz8+FHYrox+KYDjGgX0fTVWc0TidP5IWEs X-Gm-Gg: AYBFou20xiT9wVvWm8ZqhVecLC2VUUf6QqiGhCg5bvnvnLkItg/ffqqlyedFy+IMv45 s/0m6BKqjMnK3NgHhZ8oO/tFjmm/pshDvmv/zZWYU34W3roKgYFWgbXeIoW8icJRKHVqoyO/dkO 6JG06kIXQ6N9vJpXiozcabgT1KLdGeuUApWRJZWWj4hN5yrUowRMeDtiVf2nCTRcLjgmcNXL2Ro l+ocTyHsXkQ2aPSgp+SjXpLlhDWFnHGieA78huaxTuIw3LhfGiCokEKrr36zc6UFcAVKdqMrus/ 1NklRETPDY+gMYeY2rc7zx3W6tBu1299nMqjs7MrUiVg9+hRoUEoAqVv5mT+sEEO6Vm2KSlxH4f xK3bqEhGqhJNYLeF7Jj4SGusdn1tnPWGFYglGkiZTnfiulNKv8iPQS8S34V23Z/KlsDq0/un8nT RZsnrA0HZfBQ2Jj4XjnT/L6b32MGJu124Oxk940VZlH0z4uj4FsUyhPFzyvwDTOdgtxqwCwAa+L JlTvdIDisoYue2k542fespUJSBFn2HT+Y00SA4hWK9fZtfLaFHwTt3GRRbQejzblyG5lCjxVhdW lb1inU7jU4z+OxxwMvOeASubXIHsKPOLpP+cfU/9qV5VBnxS X-Received: by 2002:a05:6830:b13:b0:862:a6c5:8f12 with SMTP id 46e09a7af769-862ddc4b53amr4063814a34.11.1795010982542; Wed, 18 Nov 2026 06:09:42 -0800 (PST) Received: from localhost ([2a03:2880:30ff:41::]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-862f0239a3fsm2126877a34.20.2026.11.18.06.09.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2026 06:09:42 -0800 (PST) From: Daniel Zahka Date: Wed, 18 Nov 2026 06:08:04 -0800 Subject: [PATCH net-next v5 2/6] psp: support tx rekey operation X-Mailing-List: linux-doc@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: <20261118-psp-v5-2-b9ec840e0296@gmail.com> References: <20261118-psp-v5-0-b9ec840e0296@gmail.com> In-Reply-To: <20261118-psp-v5-0-b9ec840e0296@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: Daniel Zahka , 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