trusted-keys: move pr_fmt out of trusted-type.h
Subsystems (6)
PATCH 1/1 trusted-keys: move pr_fmt out of trusted-type.h
Defining pr_fmt in a widely-included header leaks the "trusted_key: " prefix into every translation unit that transitively includes <keys/trusted-type.h>. dm-crypt, for example, ends up printing
trusted_key: device-mapper: crypt: dm-10: INTEGRITY AEAD ERROR ...
dm-crypt began including <keys/trusted-type.h> in commit 363880c4eb36 ("dm crypt: support using trusted keys"), which predates the pr_fmt addition, so the regression has been live from the moment the header gained its own pr_fmt definition.
Move the pr_fmt definition into the trusted-keys source files that actually want the prefix.
--- include/keys/trusted-type.h | 6 ------ security/keys/trusted-keys/trusted_caam.c | 2 ++ security/keys/trusted-keys/trusted_core.c | 2 ++ security/keys/trusted-keys/trusted_dcp.c | 2 ++ security/keys/trusted-keys/trusted_pkwm.c | 2 ++ security/keys/trusted-keys/trusted_tpm1.c | 2 ++ security/keys/trusted-keys/trusted_tpm2.c | 2 ++ 7 files changed, 12 insertions(+), 6 deletions(-)
include/keys/trusted-type.h +0 -6
@@ -11,12 +11,6 @@#include <linux/rcupdate.h> #include <linux/tpm.h> -#ifdef pr_fmt -#undef pr_fmt -#endif - -#define pr_fmt (fmt) "trusted_key: " fmt -#define MIN_KEY_SIZE 32#define MAX_KEY_SIZE 128#if IS_ENABLED (CONFIG_TRUSTED_KEYS_PKWM )
security/keys/trusted-keys/trusted_caam.c +2 -0
@@ -4,6 +4,8 @@* Copyright 2025 NXP */ +#define pr_fmt (fmt) "trusted_key: " fmt +#include <keys/trusted_caam.h> #include <keys/trusted-type.h> #include <linux/build_bug.h>
security/keys/trusted-keys/trusted_core.c +2 -0
@@ -6,6 +6,8 @@* See Documentation/security/keys/trusted-encrypted.rst */ +#define pr_fmt (fmt) "trusted_key: " fmt +#include <keys/user-type.h> #include <keys/trusted-type.h> #include <keys/trusted_tee.h>
security/keys/trusted-keys/trusted_dcp.c +2 -0
@@ -3,6 +3,8 @@* Copyright (C) 2021 sigma star gmbh */ +#define pr_fmt (fmt) "trusted_key: " fmt +#include <crypto/aead.h> #include <crypto/aes.h> #include <crypto/algapi.h>
security/keys/trusted-keys/trusted_pkwm.c +2 -0
@@ -3,6 +3,8 @@* Copyright (C) 2025 IBM Corporation, Srish Srinivasan <[email protected]> */ +#define pr_fmt (fmt) "trusted_key: " fmt +#include <keys/trusted_pkwm.h> #include <keys/trusted-type.h> #include <linux/build_bug.h>
security/keys/trusted-keys/trusted_tpm1.c +2 -0
@@ -6,6 +6,8 @@* See Documentation/security/keys/trusted-encrypted.rst */ +#define pr_fmt (fmt) "trusted_key: " fmt +#include <crypto/hash_info.h> #include <crypto/sha1.h> #include <crypto/utils.h>
security/keys/trusted-keys/trusted_tpm2.c +2 -0
@@ -4,6 +4,8 @@* Copyright (C) 2014 Intel Corporation */ +#define pr_fmt (fmt) "trusted_key: " fmt +#include <linux/asn1_encoder.h> #include <linux/oid_registry.h> #include <linux/string.h>
---
base-commit: cc13002a9f984d37906e9476f3e532a8cdd126f5
change-id: 20260411-trusted-key-header-a544a4f149d2
Best regards,
Signature · 1 line
Josh
Hi Josh,
Quoted 49 lines · Josh Snyder
Defining
pr_fmtin a widely-included header leaks the "trusted_key: " prefix into every translation unit that transitively includes <keys/trusted-type.h>. dm-crypt, for example, ends up printing
trusted_key: device-mapper: crypt: dm-10: INTEGRITY AEAD ERROR ...dm-crypt began including <
keys/trusted-type.h> in commit363880c4eb36("dm crypt: support using trusted keys"), which predates thepr_fmtaddition, so the regression has been live from the moment the header gained its ownpr_fmtdefinition.Move the
pr_fmtdefinition into the trusted-keys source files that actually want the prefix.Fixes 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")Assisted-by Claude:claude-opus-4-6Signed-off-by Josh Snyder <[email protected]>--- include/keys/trusted-type.h | 6 ------ security/keys/trusted-keys/trusted_caam.c | 2 ++ security/keys/trusted-keys/trusted_core.c | 2 ++ security/keys/trusted-keys/trusted_dcp.c | 2 ++ security/keys/trusted-keys/trusted_pkwm.c | 2 ++ security/keys/trusted-keys/trusted_tpm1.c | 2 ++ security/keys/trusted-keys/trusted_tpm2.c | 2 ++ 7 files changed, 12 insertions(+), 6 deletions(-)include/keys/trusted-type.h +0
-6@@ -11,12 +11,6 @@#include <linux/rcupdate.h> #include <linux/tpm.h> -#ifdef pr_fmt -#undef pr_fmt -#endif - -#define pr_fmt (fmt) "trusted_key: " fmt -#define MIN_KEY_SIZE 32#define MAX_KEY_SIZE 128#if IS_ENABLED (CONFIG_TRUSTED_KEYS_PKWM )security/keys/trusted-keys/trusted_caam.c +0
-0
security/keys/trusted-keys/trusted_caam.c line 7
Quoted 4 lines
security/keys/trusted-keys/trusted_caam.c +1
-0@@ -4,6 +4,8 @@* Copyright 2025 NXP */ +#define pr_fmt (fmt) "trusted_key: " fmt
Can we adapt this patch further to include the trusted-key type as well? E.g. 'trusted_key-caam'.
Regards,
Marco
Ahmad Fatoum
maintainerHi,
Quoted 55 lines · Marco Felsch
Hi Josh,
Quoted 52 lines · Josh Snyder
Defining
pr_fmtin a widely-included header leaks the "trusted_key: " prefix into every translation unit that transitively includes <keys/trusted-type.h>. dm-crypt, for example, ends up printing
trusted_key: device-mapper: crypt: dm-10: INTEGRITY AEAD ERROR ...dm-crypt began including <
keys/trusted-type.h> in commit363880c4eb36("dm crypt: support using trusted keys"), which predates thepr_fmtaddition, so the regression has been live from the moment the header gained its ownpr_fmtdefinition.Move the
pr_fmtdefinition into the trusted-keys source files that actually want the prefix.Fixes 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")Assisted-by Claude:claude-opus-4-6Signed-off-by Josh Snyder <[email protected]>--- include/keys/trusted-type.h | 6 ------ security/keys/trusted-keys/trusted_caam.c | 2 ++ security/keys/trusted-keys/trusted_core.c | 2 ++ security/keys/trusted-keys/trusted_dcp.c | 2 ++ security/keys/trusted-keys/trusted_pkwm.c | 2 ++ security/keys/trusted-keys/trusted_tpm1.c | 2 ++ security/keys/trusted-keys/trusted_tpm2.c | 2 ++ 7 files changed, 12 insertions(+), 6 deletions(-)include/keys/trusted-type.h +0
-6@@ -11,12 +11,6 @@#include <linux/rcupdate.h> #include <linux/tpm.h> -#ifdef pr_fmt -#undef pr_fmt -#endif - -#define pr_fmt (fmt) "trusted_key: " fmt -#define MIN_KEY_SIZE 32#define MAX_KEY_SIZE 128#if IS_ENABLED (CONFIG_TRUSTED_KEYS_PKWM )security/keys/trusted-keys/trusted_caam.c +0
-0@@ -4,6 +4,8 @@* Copyright 2025 NXP */
Quoted 4 lines
security/keys/trusted-keys/trusted_caam.c line 7
Quoted 1 line
security/keys/trusted-keys/trusted_caam.c +1
-0+#define pr_fmt (fmt) "trusted_key: " fmtCan we adapt this patch further to include the trusted-key type as well? E.g. 'trusted_key-caam'.
Agreed, if we move it into the individual files, we can use the occasion to make it a bit more descriptive.
I would suggest "trusted_key: caam: ", so the prefix stays the same.
Cheers,
Ahmad
Quoted 4 lines
Regards,
Marco
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Jarkko Sakkinen
maintainerQuoted 63 lines · Ahmad Fatoum
Hi,
Quoted 55 lines · Marco Felsch
Hi Josh,
Quoted 52 lines · Josh Snyder
Defining
pr_fmtin a widely-included header leaks the "trusted_key: " prefix into every translation unit that transitively includes <keys/trusted-type.h>. dm-crypt, for example, ends up printing
trusted_key: device-mapper: crypt: dm-10: INTEGRITY AEAD ERROR ...dm-crypt began including <
keys/trusted-type.h> in commit363880c4eb36("dm crypt: support using trusted keys"), which predates thepr_fmtaddition, so the regression has been live from the moment the header gained its ownpr_fmtdefinition.Move the
pr_fmtdefinition into the trusted-keys source files that actually want the prefix.Fixes 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")Assisted-by Claude:claude-opus-4-6Signed-off-by Josh Snyder <[email protected]>--- include/keys/trusted-type.h | 6 ------ security/keys/trusted-keys/trusted_caam.c | 2 ++ security/keys/trusted-keys/trusted_core.c | 2 ++ security/keys/trusted-keys/trusted_dcp.c | 2 ++ security/keys/trusted-keys/trusted_pkwm.c | 2 ++ security/keys/trusted-keys/trusted_tpm1.c | 2 ++ security/keys/trusted-keys/trusted_tpm2.c | 2 ++ 7 files changed, 12 insertions(+), 6 deletions(-)include/keys/trusted-type.h +0
-6@@ -11,12 +11,6 @@#include <linux/rcupdate.h> #include <linux/tpm.h> -#ifdef pr_fmt -#undef pr_fmt -#endif - -#define pr_fmt (fmt) "trusted_key: " fmt -#define MIN_KEY_SIZE 32#define MAX_KEY_SIZE 128#if IS_ENABLED (CONFIG_TRUSTED_KEYS_PKWM )security/keys/trusted-keys/trusted_caam.c +0
-0@@ -4,6 +4,8 @@* Copyright 2025 NXP */ Quoted 4 lines
security/keys/trusted-keys/trusted_caam.c line 7
Quoted 1 line
security/keys/trusted-keys/trusted_caam.c +1
-0+#define pr_fmt (fmt) "trusted_key: " fmtCan we adapt this patch further to include the trusted-key type as well? E.g. 'trusted_key-caam'.
Quoted 7 lines
Agreed, if we move it into the individual files, we can use the occasion to make it a bit more descriptive.
I would suggest "
trusted_key: caam: ", so the prefix stays the same.Cheers,
Ahmad
+1
BR, Jarkko