From: Stan Iliev <stani@google.com>
To: Tony Nguyen <anthony.l.nguyen@intel.com>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
intel-wired-lan@lists.osuosl.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
David Decotigny <decot@google.com>,
Madhu Chittim <madhu.chittim@intel.com>,
Emil Tantilov <emil.s.tantilov@intel.com>,
Sridhar Samudrala <sridhar.samudrala@intel.com>,
Brian Vazquez <brianvv@google.com>, Li Li <boolli@google.com>,
Alexander Lobakin <aleksander.lobakin@intel.com>,
Daniel Zahka <daniel.zahka@gmail.com>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
Kees Cook <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
linux-hardening@vger.kernel.org
Subject: [PATCH iwl-next 01/15] libie: wipe copied small send buffers on release
Date: Tue, 17 Nov 2026 14:55:07 +0000 [thread overview]
Message-ID: <20261117145522.1910636-2-stani@google.com> (raw)
In-Reply-To: <20261117145522.1910636-1-stani@google.com>
libie_ctlq_xn_send() copies the messages that fit in LIBIE_CP_TX_COPYBREAK
bytes into a DMA buffer of their transaction, which is reused for later
messages but never cleared. The messages can hold secrets, e.g. the PSP
TX keys that idpf inserts into the SADB of the device.
Wipe the copy once the message was sent, when its send queue entry is
cleaned, and when it couldn't be sent. The transaction can be reused as
soon as that entry is cleared, see libie_ctlq_xn_pop_free(): order the
wipe before it with smp_wmb(), paired with smp_acquire__after_ctrl_dep()
after the check of the entry, so that the wipe can't overwrite the next
message on weakly ordered architectures.
Signed-off-by: Stan Iliev <stani@google.com>
---
drivers/net/ethernet/intel/libie/controlq.c | 28 ++++++++++++++++++---
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/intel/libie/controlq.c b/drivers/net/ethernet/intel/libie/controlq.c
index 6214fc036ce5..c31d3c9e792a 100644
--- a/drivers/net/ethernet/intel/libie/controlq.c
+++ b/drivers/net/ethernet/intel/libie/controlq.c
@@ -694,9 +694,16 @@ libie_ctlq_xn_pop_free(struct libie_ctlq_xn_manager *xnm)
* address is dirty in any way, reuse is already safe.
*/
if (xn->tx_msg &&
- data_race(xn->tx_msg->send_mem.pa) == xn->small_dma_mem.pa)
+ /* READ_ONCE() for the control dependency below */
+ data_race(READ_ONCE(xn->tx_msg->send_mem.pa)) ==
+ xn->small_dma_mem.pa)
continue;
+ /* The small buffer is wiped before the message is cleared,
+ * pairs with the smp_wmb() of libie_ctlq_xn_rel_tx_buf()
+ */
+ smp_acquire__after_ctrl_dep();
+
clear_bit(free_idx, xnm->free_xns_bm);
return xn;
@@ -998,6 +1005,8 @@ int libie_ctlq_xn_process_send(struct libie_ctlq_xn_send_params *params,
if (!libie_ctlq_send_desc_avail(ctlq)) {
if (!libie_cp_can_send_onstack(buf_len))
libie_cp_unmap_dma_mem(dev, dma_mem);
+ else
+ memzero_explicit(dma_mem->va, buf_len);
return -EBUSY;
}
@@ -1132,10 +1141,21 @@ static void libie_ctlq_xn_rel_tx_buf(const void *ctx,
{
const struct libie_ctlq_xn_rel_tx_ctx *rel_ctx = ctx;
- if (!libie_cp_can_send_onstack(dma_mem->size)) {
- libie_cp_unmap_dma_mem(rel_ctx->dev, dma_mem);
- rel_ctx->rel_tx_buf(dma_mem->va);
+ /* Small messages are copied into the buffer of their transaction,
+ * which is reused: wipe the copy, the message may hold secrets, e.g.
+ * crypto keys
+ */
+ if (libie_cp_can_send_onstack(dma_mem->size)) {
+ memzero_explicit(dma_mem->va, dma_mem->size);
+ /* libie_ctlq_send_clean() clears the message next, which lets
+ * libie_ctlq_xn_pop_free() reuse the buffer
+ */
+ smp_wmb();
+ return;
}
+
+ libie_cp_unmap_dma_mem(rel_ctx->dev, dma_mem);
+ rel_ctx->rel_tx_buf(dma_mem->va);
}
/**
--
2.56.0.679.gc527c65306-goog
next prev parent reply other threads:[~2026-11-17 14:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 14:55 [PATCH iwl-next 00/15] idpf: add PSP offload support, part 1 Stan Iliev
2026-11-17 14:55 ` Stan Iliev [this message]
2026-11-17 14:55 ` [PATCH iwl-next 02/15] idpf: wipe mailbox send buffers on release Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 03/15] idpf: make the mailbox workqueue visible in sysfs Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 04/15] idpf: psp: add psp offload initialization Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 05/15] idpf: psp: add support for crypto capabilities Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 06/15] idpf: psp: add support for psp capabilities Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 07/15] idpf: psp: add support for fips compliance status Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 08/15] idpf: psp: add support for psp rx key allocation Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 09/15] idpf: psp: add support for psp key rotation Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 10/15] idpf: psp: add support for psp statistics Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 11/15] idpf: psp: add psp tx key state Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 12/15] idpf: psp: add support for psp tx key deletion Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 13/15] idpf: psp: add psp work and tx key insertion completion Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 14/15] idpf: psp: add support for psp tx key insertion Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 15/15] idpf: psp: add psp tx key registration Stan Iliev
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=20261117145522.1910636-2-stani@google.com \
--to=stani@google.com \
--cc=aleksander.lobakin@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=boolli@google.com \
--cc=brianvv@google.com \
--cc=daniel.zahka@gmail.com \
--cc=davem@davemloft.net \
--cc=decot@google.com \
--cc=edumazet@kernel.org \
--cc=emil.s.tantilov@intel.com \
--cc=gustavoars@kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=madhu.chittim@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=sridhar.samudrala@intel.com \
--cc=willemdebruijn.kernel@gmail.com \
/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