From nobody Sat Oct 3 03:56:20 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0BAB38AC68 for ; Wed, 5 Aug 2026 14:36:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785940600; cv=none; b=qezmuDG4pm9L28TP0cPqIXgrTDKiQTqKophLysHWEQy/jxpC2GXXptB13Ig3ji6f9dte/mQKWSvyP69T+vpm3r/XEtU3VSxNeRK7HHL7YhcMmGmVTjONSjYWGQGLSJw1kqzXKud/nP0fQMBi7/ck6VjXZDzjZPr+zE5uxZsEHBQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785940600; c=relaxed/simple; bh=duW19IgJsAZJrRbXwEO0zEH2t8L/hVDfEvkJX44DDOM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CH1pjG59z+2B2mxl8bGVd/3RSJCbeQLXEZI76l01oNCtvixyWDFxL7l3RbgmESKN9r59XZS7N2OyfaaxR9dSqG+oy2oBX+xLceL28j6eygyt+PlJfRPwzQ58lXUDwVRdFUnL6hSIdmUHCbaSmBOa4dX+sKdXYdYVzW/jEEJ9fe8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=O+XRpe1H; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="O+XRpe1H" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785940593; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yei7OHfAGHdMIi/iQ/Eh6Hu6W5UwksEC5q06wHwkLjE=; b=O+XRpe1HgOS8Omogd9gSK1aLRrMtYBR/agHvkgn8oFHOr5ZS9ZHgARTWJ6TSyGjXdl1SSN ONUlDJKTJ9OKTKeyTV21LyiDvE1EbAqe165pjPQk0tVGYHMGprRfPulvp7gdJ62XL459pA mvZZQORWiiw6twKUCt+TVi9BiJUSZhc= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-500-7Nyd_fOAPNykH5qV9j9BZg-1; Wed, 05 Aug 2026 10:36:19 -0400 X-MC-Unique: 7Nyd_fOAPNykH5qV9j9BZg-1 X-Mimecast-MFC-AGG-ID: 7Nyd_fOAPNykH5qV9j9BZg_1785940578 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5C78319560A7; Wed, 5 Aug 2026 14:36:18 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.44.48.209]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 37F031800598; Wed, 5 Aug 2026 14:36:15 +0000 (UTC) From: Thomas Huth To: Herbert Xu , "David S. Miller" , Eric Biggers Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/6] crypto: Provide wrapper functions for zeroizing aes_cmac_key and aes_cmac_ctx Date: Wed, 5 Aug 2026 16:36:04 +0200 Message-ID: <20260805143611.818559-2-thuth@redhat.com> In-Reply-To: <20260805143611.818559-1-thuth@redhat.com> References: <20260805143611.818559-1-thuth@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" From: Thomas Huth Code that uses AES-CMAC might need to zeroize their local aes_cmac_key and/or aes_cmac_ctx structures after use to avoid leaking sensitive material on the stack. Provide an aes_cmac_zeroize_key() and an aes_cmac_zeroize_ctx() helper function that can be used with __cleanup() to automatically clear the key and context when they go out of scope. Signed-off-by: Thomas Huth --- include/crypto/aes-cbc-macs.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/crypto/aes-cbc-macs.h b/include/crypto/aes-cbc-macs.h index e61df108b926d..b2f3b8be7886b 100644 --- a/include/crypto/aes-cbc-macs.h +++ b/include/crypto/aes-cbc-macs.h @@ -109,6 +109,32 @@ void aes_cmac_update(struct aes_cmac_ctx *ctx, const u= 8 *data, size_t data_len); */ void aes_cmac_final(struct aes_cmac_ctx *ctx, u8 out[at_least AES_BLOCK_SI= ZE]); =20 +/** + * aes_cmac_zeroize_key - Clear a aes_cmac_key structure + * @ctx: The location of the key structure that should be zeroized + * + * Explicitly fills the aes_cmac_key with zeroes. This should be done once + * the key is not required anymore to avoid that its contents are leaked + * on the stack or heap. + */ +static inline void aes_cmac_zeroize_key(struct aes_cmac_key *key) +{ + memzero_explicit(key, sizeof(*key)); +} + +/** + * aes_cmac_zeroize_ctx - Clear a aes_cmac_ctx structure + * @ctx: The location of the context that should be zeroized + * + * Explicitly fills the aes_cmac_ctx with zeroes. This should be done once + * the context is not required anymore to avoid that its contents are + * leaked on the stack or heap. Only required if not using aes_cmac_final(= ). + */ +static inline void aes_cmac_zeroize_ctx(struct aes_cmac_ctx *ctx) +{ + memzero_explicit(ctx, sizeof(*ctx)); +} + /** * aes_cmac() - Compute AES-CMAC or AES-XCBC-MAC in one shot * @key: The key to use --=20 2.55.0 From nobody Sat Oct 3 03:56:20 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0A8438A73B for ; Wed, 5 Aug 2026 14:36:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785940601; cv=none; b=PnJVXhxv4G2omyo4yNewXo0JImrM/pFRoAVm+/lOh53/HYuu+/IeqM2XOFQ1cZDi+nwcgdvLxDNo9wtR2wHk6O9/Nqk9oaPDMk0sbobNrbKYO4m9RMcK6PmUUsiQinVPhimjyu9memc98SO/QHIm/U63c0kbb3FHOtSf1fSVERc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785940601; c=relaxed/simple; bh=4rCgqeuHEy9E5A8LTGid6IlJZItGQ4fk034XPhbIATk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R3dBfIbyouTuYfelJJ05gJUqltrBIynDMlRt2m3nUO2XzMgUIvB9qQzGPeVjAFGs5pm83Eeg1QzPsWGk77FKG0tuFLHHB5s1pvOi2RP1+7jA3gfBJWL0XLFR9s5gaTjCbSCkctJ5vzduysdjqq5wsEzCDNxYRqx4j3GQfDNYVvQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=fYFtwNRA; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fYFtwNRA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785940593; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SdbllWlXb3ri7lSNaZ11zlDq0wjdTEQ2mDG3hzZ4lUk=; b=fYFtwNRAOi52jskQBY1qR6LwcwSyzB7XA1vvcifsQMpLYPK4DTqlkFZwOJLdz4WACkUAHQ jtKx/H0yploJSXS3TR/R/Ee/WC6p2EPlCDnwJJdjqRQgORL+mAY4V8irKiccTOlpiZ+Qvz OpUfOfNkmhuQVkSh8FLde7fBoWtcHGE= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-230-YV8rJ0xiOzGhfOWY9BrAnw-1; Wed, 05 Aug 2026 10:36:26 -0400 X-MC-Unique: YV8rJ0xiOzGhfOWY9BrAnw-1 X-Mimecast-MFC-AGG-ID: YV8rJ0xiOzGhfOWY9BrAnw_1785940584 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 28E0B1955F7A; Wed, 5 Aug 2026 14:36:24 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.44.48.209]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 49AFB1800598; Wed, 5 Aug 2026 14:36:19 +0000 (UTC) From: Thomas Huth To: Herbert Xu , "David S. Miller" , Eric Biggers , Steve French , Namjae Jeon Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Bharath SM , Sergey Senozhatsky , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org Subject: [PATCH 2/6] smb: clear the aes_cmac_key and aes_cmac_ctx when done Date: Wed, 5 Aug 2026 16:36:05 +0200 Message-ID: <20260805143611.818559-3-thuth@redhat.com> In-Reply-To: <20260805143611.818559-1-thuth@redhat.com> References: <20260805143611.818559-1-thuth@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" From: Thomas Huth Clear the local crypto-related structures via __cleanup() functions when we're done with them to avoid that sensitive data could leak on the stack. Note: cmac_ctx in ksmbd_sign_smb3_pdu() gets cleared in aes_cmac_final() already, so this does not need a __cleanup() marker. Signed-off-by: Thomas Huth --- fs/smb/client/smb2transport.c | 4 ++-- fs/smb/server/auth.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/smb/client/smb2transport.c b/fs/smb/client/smb2transport.c index 1143ee52470a7..d23566da2ac81 100644 --- a/fs/smb/client/smb2transport.c +++ b/fs/smb/client/smb2transport.c @@ -464,8 +464,8 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_S= erver_Info *server) unsigned char smb3_signature[SMB2_CMACAES_SIZE]; struct kvec *iov =3D rqst->rq_iov; struct smb2_hdr *shdr =3D (struct smb2_hdr *)iov[0].iov_base; - struct aes_cmac_key cmac_key; - struct aes_cmac_ctx cmac_ctx; + struct aes_cmac_key cmac_key __cleanup(aes_cmac_zeroize_key); + struct aes_cmac_ctx cmac_ctx __cleanup(aes_cmac_zeroize_ctx); struct smb_rqst drqst; u8 key[SMB3_SIGN_KEY_SIZE]; =20 diff --git a/fs/smb/server/auth.c b/fs/smb/server/auth.c index 86f521e849d5e..f123e6cf9c424 100644 --- a/fs/smb/server/auth.c +++ b/fs/smb/server/auth.c @@ -505,7 +505,7 @@ void ksmbd_sign_smb2_pdu(struct ksmbd_conn *conn, char = *key, struct kvec *iov, void ksmbd_sign_smb3_pdu(struct ksmbd_conn *conn, char *key, struct kvec *= iov, int n_vec, char *sig) { - struct aes_cmac_key cmac_key; + struct aes_cmac_key cmac_key __cleanup(aes_cmac_zeroize_key); struct aes_cmac_ctx cmac_ctx; int i; =20 --=20 2.55.0 From nobody Sat Oct 3 03:56:20 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F407B3515D1 for ; Wed, 5 Aug 2026 14:36:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785940604; cv=none; b=OqIFk35AOAvwcO0087btapuAwaDlqCEr4SFkqVZ7f6l9jvyEB72maM6SCjcE2PozbnMO4c4/1+cjU3W+TvBfJJLZ5TRjRvCf1MWuGWlxJPIVnEpAKqxqU6/zwWWxylbjMlO9/iuC8DJpnwTFwbwCsKiIJvPCq7slp8Kpmm0QjrQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785940604; c=relaxed/simple; bh=Va4ivm8VFtFpcxvPb6V6ItS1fIrbnCGVzIWgl1id4oQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pGU7w/WWcgD/z72Hk50nu4PioY34qGiQsJdXusbITbuboecGZRCmGdlXiZaaojUeMN670iI0qRJi+rOD9aIdR8iLvY83VizDC/CyITkcMCVLRzyyUafCTKrBbMZ7uNqIRsU5KNlx5qHnLbZC9g7MFIomEDzumHl2rVq04bNDU68= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=G4zHL0tn; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="G4zHL0tn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785940596; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EEtweso52u7DPd5Sbq00gxh4t8XgpNwiiYdVWx3jMpU=; b=G4zHL0tnxOqQVmqNHnqcUZy9lmITM0ZNzMcKsKeDRa4XpjUx7dfj3bapsBC+rwbbWpNe64 7kQ8d2MuSKhPPyzTb0571z/JgbBflCTachi722crWIY3qAASuc+2KDxyFeLUFheHFT7W/x hvbx1Y0vzwRcVi1aTXTVMlccGuKV04I= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-524-NHoGUniKNH-wvTHsUNYRTg-1; Wed, 05 Aug 2026 10:36:30 -0400 X-MC-Unique: NHoGUniKNH-wvTHsUNYRTg-1 X-Mimecast-MFC-AGG-ID: NHoGUniKNH-wvTHsUNYRTg_1785940588 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 77B011955F24; Wed, 5 Aug 2026 14:36:28 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.44.48.209]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D311D1800598; Wed, 5 Aug 2026 14:36:24 +0000 (UTC) From: Thomas Huth To: Herbert Xu , "David S. Miller" , Eric Biggers , Eric Dumazet , Neal Cardwell , Jakub Kicinski , Paolo Abeni Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Kuniyuki Iwashima , Simon Horman , netdev@vger.kernel.org Subject: [PATCH 3/6] net/tcp-ao: clear the aes_cmac_key when done Date: Wed, 5 Aug 2026 16:36:06 +0200 Message-ID: <20260805143611.818559-4-thuth@redhat.com> In-Reply-To: <20260805143611.818559-1-thuth@redhat.com> References: <20260805143611.818559-1-thuth@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" From: Thomas Huth Clear the local aes_cmac_key structure via __cleanup() function when we're done with it to avoid that sensitive data could leak on the stack. Signed-off-by: Thomas Huth --- net/ipv4/tcp_ao.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/tcp_ao.c b/net/ipv4/tcp_ao.c index a56bb79e15e0e..12c724fed8a26 100644 --- a/net/ipv4/tcp_ao.c +++ b/net/ipv4/tcp_ao.c @@ -141,7 +141,7 @@ void tcp_ao_calc_traffic_key(const struct tcp_ao_key *m= kt, u8 *traffic_key, traffic_key); return; case TCP_AO_ALGO_AES_128_CMAC: { - struct aes_cmac_key k; + struct aes_cmac_key k __cleanup(aes_cmac_zeroize_key); =20 aes_cmac_preparekey(&k, mkt->key, AES_KEYSIZE_128); aes_cmac(&k, input, input_len, traffic_key); --=20 2.55.0 From nobody Sat Oct 3 03:56:20 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6547138D3FC for ; Wed, 5 Aug 2026 14:36:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785940609; cv=none; b=ejPmTWcqWI8vTNfZOVJ7QZ+LUqjNHByk9QlSmeIuCCcS2PiE6XD/oRJYQzNSM3SiQVaPxptfy79C3SoMYtLH3bjVQ7U3XuCStJPhR0DMPsymzHCl/BE2FoDkJIm3WSNAr8T2mw61o/FqSKJOmCP3oIqG3PDECvBNX4o0kzHpP5A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785940609; c=relaxed/simple; bh=GWQOgUmGaCnW/7J1hwEvhzsgx1F8Z9pgSpV7rwx1RuQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dSmtFgwBPibhoB06v4QAGPLmTe1nNIk/cty+oZbMX5UGDpntsvL7NWyUaPGb83/r88Dt44/eYkVRluPEEHNiANH1UPY2AgmH53hxpGPFbw5a3u6NQXQM65eQex3GOAdy9yjoC5TVBF9ts8O62rGNgYWrn7z8L0Gnt9cgOHZG8+g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=NZhSCJs3; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NZhSCJs3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785940597; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oQdZ/4Ujf8RSEA8hIdmgFuDrtIelJbLig2Mv6B2/+tw=; b=NZhSCJs3dRSoH2bZmZfTCcp+BqWXXSntkOr5mmBoEYWWTUxp/FKIxb7IcATfSaaDmDy4Re MC9Go3TNhJ/+c0a1h+uHIZqdis9thGEBPVMFWSR5Vpsc5qUqf8/264urmB87Xi4wJwlCBl lZdtZAJVCoQxXQjBDXgJuToLGxE8EUQ= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-287-JfPA_c8AOhe6fu5NQ65d_Q-1; Wed, 05 Aug 2026 10:36:33 -0400 X-MC-Unique: JfPA_c8AOhe6fu5NQ65d_Q-1 X-Mimecast-MFC-AGG-ID: JfPA_c8AOhe6fu5NQ65d_Q_1785940592 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 062081800115; Wed, 5 Aug 2026 14:36:32 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.44.48.209]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 467BE180049F; Wed, 5 Aug 2026 14:36:29 +0000 (UTC) From: Thomas Huth To: Herbert Xu , "David S. Miller" , Eric Biggers , Marcel Holtmann , Luiz Augusto von Dentz Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org Subject: [PATCH 4/6] Bluetooth: SMP: clear the aes_cmac_key when done Date: Wed, 5 Aug 2026 16:36:07 +0200 Message-ID: <20260805143611.818559-5-thuth@redhat.com> In-Reply-To: <20260805143611.818559-1-thuth@redhat.com> References: <20260805143611.818559-1-thuth@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" From: Thomas Huth Clear the local aes_cmac_key structure via __cleanup() function when we're done with it to avoid that sensitive data could leak on the stack. Signed-off-by: Thomas Huth --- net/bluetooth/smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 031d3022cb1e5..ed30ca0d773f1 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -164,7 +164,7 @@ static inline void swap_buf(const u8 *src, u8 *dst, siz= e_t len) static int smp_aes_cmac(const u8 k[16], const u8 *m, size_t len, u8 mac[16= ]) { uint8_t tmp[16], mac_msb[16], msg_msb[CMAC_MSG_MAX]; - struct aes_cmac_key key; + struct aes_cmac_key key __cleanup(aes_cmac_zeroize_key); int err; =20 if (len > CMAC_MSG_MAX) --=20 2.55.0 From nobody Sat Oct 3 03:56:20 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9EEE38DC58 for ; Wed, 5 Aug 2026 14:36:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785940605; cv=none; b=FOcmBt9emqmPmlfe7XyIhF6liY9HrY1qRroujAAHVKO6uVgCig5LodAXBZevtuLNP3HcZA/hvHwYWPGttWLT77Z2Vjd1oeqQQ1gI3wGqE9DeJdRZQ59huOyDMHLn4oE9+5vMsLrDIEL2xz8+INGtjHHxS39PUFuEal24m4lUKNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785940605; c=relaxed/simple; bh=LmpijrFU5VnQEBfjJ8Gl/AStXuoZjWEwdsCP9ODIWXA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gkwy4A5TD9eClZBq9X+WNmN+1fvoxLXBLeM9LJm00K3+qQ2dwRLL6VV15NWwEpQ8tjr8Zt7sR4ak5HYYSDqQDWOuTWtFWEz83hqDOzUWmHNj+7VIUHiy8yMwCBR6oI+cztLBvyOEYGX9aBnF8pCcYLKvjGcOPT85+YZq6d5A+r8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=BgqU76fy; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BgqU76fy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785940598; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fwwpqQsgkBaEc2CC3i/V5A9RM+6KRyNvVsbwOuZjf0k=; b=BgqU76fy7eog6GV3gRQc7UViBPEcsrxqK1v/1uE5hjF4ye3tpAgb1V8dKia6LtlFEH+btN aGJUd/GsJEkhqvTPiYC+gRtUPuWGEqUmqo3l8HmAZ0EimRj3qoyJj8365wDxA1s+m2QqVW VqcBbkwQeIN1TaDyCxlqvn8yoe9hGcU= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-648-WPdFBf9uMPS3kYj9pFV7Pw-1; Wed, 05 Aug 2026 10:36:36 -0400 X-MC-Unique: WPdFBf9uMPS3kYj9pFV7Pw-1 X-Mimecast-MFC-AGG-ID: WPdFBf9uMPS3kYj9pFV7Pw_1785940595 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 548B31955F15; Wed, 5 Aug 2026 14:36:35 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.44.48.209]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CE7B01800598; Wed, 5 Aug 2026 14:36:32 +0000 (UTC) From: Thomas Huth To: Herbert Xu , "David S. Miller" , Eric Biggers , "Jason A. Donenfeld" , Ard Biesheuvel Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] lib/crypto: aes: Use _cleanup() for aes_cmac_key instead of memzero_explicit() Date: Wed, 5 Aug 2026 16:36:08 +0200 Message-ID: <20260805143611.818559-6-thuth@redhat.com> In-Reply-To: <20260805143611.818559-1-thuth@redhat.com> References: <20260805143611.818559-1-thuth@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" From: Thomas Huth By using __cleanup(aes_cmac_zeroize_key) for clearing the key data, we can save one line of code here. Signed-off-by: Thomas Huth --- lib/crypto/aes.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/crypto/aes.c b/lib/crypto/aes.c index ca733f15b2a8f..895f8dffa44ae 100644 --- a/lib/crypto/aes.c +++ b/lib/crypto/aes.c @@ -720,7 +720,7 @@ EXPORT_SYMBOL_NS_GPL(aes_cbcmac_final, "CRYPTO_INTERNAL= "); */ static void __init aes_cmac_fips_test(void) { - struct aes_cmac_key key; + struct aes_cmac_key key __cleanup(aes_cmac_zeroize_key); u8 mac[AES_BLOCK_SIZE]; =20 if (aes_cmac_preparekey(&key, fips_test_key, sizeof(fips_test_key)) !=3D @@ -729,7 +729,6 @@ static void __init aes_cmac_fips_test(void) aes_cmac(&key, fips_test_data, sizeof(fips_test_data), mac); if (memcmp(fips_test_aes_cmac_value, mac, sizeof(mac)) !=3D 0) panic("aes: CMAC FIPS self-test failed (wrong MAC)\n"); - memzero_explicit(&key, sizeof(key)); } #else /* CONFIG_CRYPTO_LIB_AES_CBC_MACS */ static inline void aes_cmac_fips_test(void) --=20 2.55.0 From nobody Sat Oct 3 03:56:20 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB51D3515F0 for ; Wed, 5 Aug 2026 14:36:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785940615; cv=none; b=BLLt1fRDMTIExYBGXjjRFN0XTsKpftfzJTM2D6hVDOdXHVPl/qfTUQTlN6JFJww/tZetzWNjox1odv7qim1VN+X2Vd18ZZuz1BHCD0/DP5Ca8Mp71ACsL4eyPDnukSfmqnlRRKfA1kVnaLRyQNTSrPlOL6UcfP8xIndoqIakdlw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785940615; c=relaxed/simple; bh=c+Obj3KxZAXJqJFX2X9E/Kyv+qj00penHJsYWag3Dkc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WIkW2KMs9PfXFfwUzAe8AuBcsVEVKySMSo94lPWcPYltl3uf+PJ0SoeD3ps2CtiYjy8Izr/iKJoDY0fUoElVFzyVyOrCCa1Ij+LbmSaKgFUAIDkNRR3055FhbaiSUTXq4bUxL4XRSfqXfgCofaswMczL+jlOTLLiIuwfaIqMZxw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=CUfuoyXU; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CUfuoyXU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785940605; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4Ce3mbn9VnBLWH5P+vwgYp9VLPRTWUW0aQvMbeGeCrI=; b=CUfuoyXUjsE1Tp8EtqqPubQZha+T2UbpTBFC/kaG2ka+AvGS30FawLOZbhnUBJF2hvzv8R uo4ukkLCjtYlVZODYVAdz+If58Dv+nt0awAy9Ljklhh43kGw7zKeeg6TEzA1+mgW/RKD2g 3gw9Vzsu1X+XfCseRHnysBRpWbjcAaA= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-583-U6v6dCt1Mu6Wv-I9a0_Piw-1; Wed, 05 Aug 2026 10:36:41 -0400 X-MC-Unique: U6v6dCt1Mu6Wv-I9a0_Piw-1 X-Mimecast-MFC-AGG-ID: U6v6dCt1Mu6Wv-I9a0_Piw_1785940599 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E6EB21955E7C; Wed, 5 Aug 2026 14:36:38 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.44.48.209]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 22D4D1800598; Wed, 5 Aug 2026 14:36:35 +0000 (UTC) From: Thomas Huth To: Herbert Xu , "David S. Miller" , Eric Biggers , Johannes Berg Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH 6/6] mac80211: fils_aead: Use _cleanup for aes_cmac_key instead of memzero_explicit Date: Wed, 5 Aug 2026 16:36:09 +0200 Message-ID: <20260805143611.818559-7-thuth@redhat.com> In-Reply-To: <20260805143611.818559-1-thuth@redhat.com> References: <20260805143611.818559-1-thuth@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" From: Thomas Huth By using __cleanup(aes_cmac_zeroize_key) for clearing the key data, we can save one line of code here. Signed-off-by: Thomas Huth --- net/mac80211/fils_aead.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/mac80211/fils_aead.c b/net/mac80211/fils_aead.c index d2f4a17eab990..293590976489a 100644 --- a/net/mac80211/fils_aead.c +++ b/net/mac80211/fils_aead.c @@ -24,7 +24,7 @@ static int aes_s2v(const u8 *in_key, size_t key_len, size_t num_elem, const u8 *addr[], size_t len[], u8 *v) { u8 d[AES_BLOCK_SIZE], tmp[AES_BLOCK_SIZE] =3D {}; - struct aes_cmac_key key; + struct aes_cmac_key key __cleanup(aes_cmac_zeroize_key); struct aes_cmac_ctx ctx; size_t i; int res; @@ -62,7 +62,6 @@ static int aes_s2v(const u8 *in_key, size_t key_len, aes_cmac_update(&ctx, d, AES_BLOCK_SIZE); aes_cmac_final(&ctx, v); =20 - memzero_explicit(&key, sizeof(key)); return 0; } =20 --=20 2.55.0