From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.222.197 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794927341; b=xUAMdXqLTpChenkzBgNJi2aNfWsv+86/kl7BWgHwl93x/b55VmFtQAioupZ8yJG8ALXw cI3iOQswzKa+4cabEcy7ZCSEshPqsyoNnw42fEOFehJ25QTqL7aX/Iweb+xGQJFpq3TTL moeBwSkdPjOmkf6yCYp2iZnYo6inRQvNQp7+LeKsikDOLS20DBLlr3ToXABcxg5pfqSlL i8sOwBUYi7oiVXLOdEqBD+n4W88QIbBCwWVNTgq6LQeAAM4V+a22LO/V/nOqL0Vppq0IX jOa0uIVbb/65B0j87PndeWKWqfju2E0vysEdDRgthUAvUb3UwarPnIXC1Wlc49whthA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794927341; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Received:Date:In-Reply-To:Mime-Version: References:X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=X3DwMEGrZ57pkqE3y7BJjL3MnOYoEVHYkRTWJRAevnQ=; b=u1wXT9p8rIGMb/SgZozTzWq29Kyg0e1GHFepUbpeFDIUNafHJzi3Fb+NRuUKP4mGMTCz UizgkiV1ltmy1ZMGSeA1B7AhH8xWlWPB5NSUyYIxK+2Zh7XJWGIbhruPuFHHs18okxoNY /Ptbm/8REayOsDljkNJFwA56L1SfxiDwD1HZJtOZkx6yMeNtfHWKpPLLfRyjoXOnT4qLZ 7YoagSLeNbJwE+ARPzOeagd/HnJxGmqPK8pkYUQQ0la6Q1uuIUxBILNsVqVWHaQjcp38a frHrgaLQIQQKxgLc0kRibnezV+XdUHIHURBbhm7d2y9JwlUvEHk972t4rPS2/TWfiEA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--stani.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=CGd7BfaT; arc=none smtp.remote-ip=209.85.222.197 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (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 CEEE0606A32A for ; Tue, 17 Nov 2026 14:55:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CEEE0606A32A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--stani.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=CGd7BfaT Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-93f2373e9b4so531550285a.1 for ; Tue, 17 Nov 2026 06:55:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1794927340; x=1795532140; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=X3DwMEGrZ57pkqE3y7BJjL3MnOYoEVHYkRTWJRAevnQ=; b=CGd7BfaTKcEZnmBpM3ZHO6Gng5nLM/htKmuPUXYUy2XlFK/IjORTCW5sZ6VU65q5Ju 9rzj7guEyL8KAEzE02TWHyPaTuH12UK5m7PSAM0vKSkR7C2AkOK52wIMZ0DlAH3uA1pN 7zNcbFMMwkrbNqH7J3HXBHBeMNMTBoAy1LYa+zYr5GNia5l7yjgpIthClr49LfbKL2Pb opYYpEf2QxJhCEn2uJsvEqX0pvavX/+UHvkk1mIIqsASsdYPo964LdRekAO18KihJnZU iuOPWTHoAZS9RfpgsAvkD4axvBHUBAdGFy1NeHZtqRM1G+S3HMEy7maZwzl8uZLpvGvR 1R/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794927340; x=1795532140; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=X3DwMEGrZ57pkqE3y7BJjL3MnOYoEVHYkRTWJRAevnQ=; b=oVJNiIJRTS1Hp1NWfEiROQ7P3Po2X89b8KX9K1IUYkwG62jczDmqWclfBbbKSSMKXK 9ShQCgAPloyaS7OvgJTjmAw7RH+lR0MM78ZcQNJbgBL5wogYY9N0y7AF4jC7Q7L9Exgt 1oNgNs5fjuBLuAZAAYcIE1f2pNTFYhIjheYvPut4ttofKLxzaVXwI5lvO3r/ZDC6XVOr Lv06SLNShCGoaVIHvOYQG0IfmopxWJZr3RisYHw02MifVJKIoTpeP+gQ8jg717+7DpZR 4fVV1WV+05vTo5fjSUjSff4Ht7DfJspBKhQ//I6YQDqLGw7hp+pgAjk73/iLrXGR4tKL uEPA== X-Gm-Message-State: APuU4Z8Facbj4xB3Nwgyv/F6jPFUi2l7RdzoC2ocS6BREuMNMRCoxmYl 6bwYHyWOUwYTuO2iGZMztqOyKdJFFlGzl8opH6cCe3Xcha22vhXaMydRmvfjr6wt3ww1pNffPUz iGw== X-Received: from qknrh21.prod.google.com ([2002:a05:620a:8f15:b0:945:e9b7:7c18]) (user=stani job=prod-delivery.src-stubby-dispatcher) by 2002:a05:620a:870e:20b0:949:8a03:c35e with SMTP id af79cd13be357-9498a03c384mr411244985a.54.1794927339421; Tue, 17 Nov 2026 06:55:39 -0800 (PST) Date: Tue, 17 Nov 2026 14:55:07 +0000 In-Reply-To: <20261117145522.1910636-1-stani@google.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261117145522.1910636-1-stani@google.com> X-Mailer: git-send-email 2.56.0.679.gc527c65306-goog Message-ID: <20261117145522.1910636-2-stani@google.com> Subject: [PATCH iwl-next 01/15] libie: wipe copied small send buffers on release From: Stan Iliev To: Tony Nguyen , Przemek Kitszel , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Decotigny , Madhu Chittim , Emil Tantilov , Sridhar Samudrala , Brian Vazquez , Li Li , Alexander Lobakin , Daniel Zahka , Willem de Bruijn , Kees Cook , "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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 --- 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