Thread (15 messages) 15 messages, 3 authors, 2d ago

[RFC PATCH 11/41] fscrypt: show the whole uid in the description of user key claims

flat view
WARM2d

From: Jan Koester <hidden>
Date: 2026-10-18 18:02:11
Also in: keyrings, linux-arch, linux-cifs, linux-ext4, linux-fsdevel, linux-nfs, linux-security-module, lkml, netdev
Subsystem: filesystems (vfs and infrastructure), fscrypt: file system level encryption support, the rest · Maintainers: Alexander Viro, Christian Brauner, Eric Biggers, Theodore Y. Ts'o, Jaegeuk Kim, Linus Torvalds

The ".fscrypt" keys that account a master key to a user are described
as "<identifier>.uid.<uid>". For a UUID or GUID uid that printed -1;
use kuid_str() so /proc/keys shows who the claim belongs to. Lookups
compare the kuid itself and are not affected.

Assisted-by: Claude:claude-opus-5-5

Signed-off-by: Jan Koester <redacted>
---
 fs/crypto/keyring.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/fs/crypto/keyring.c b/fs/crypto/keyring.c
index 76e28d1e00..080166267f 100644
--- a/fs/crypto/keyring.c
+++ b/fs/crypto/keyring.c
@@ -178,7 +178,7 @@ static struct key_type key_type_fscrypt_user = {
 };
 
 #define FSCRYPT_MK_USER_DESCRIPTION_SIZE	\
-	(2 * FSCRYPT_KEY_IDENTIFIER_SIZE + CONST_STRLEN(".uid.") + 10 + 1)
+	(2 * FSCRYPT_KEY_IDENTIFIER_SIZE + CONST_STRLEN(".uid.") + KID_STR_LEN)
 
 /* Create ->s_master_keys if needed.  Synchronized by fscrypt_add_key_mutex. */
 static int allocate_filesystem_keyring(struct super_block *sb)
@@ -338,13 +338,14 @@ static int add_master_key_user(struct fscrypt_master_key *mk)
 {
 	kuid_t uid = current_fsuid();
 	char description[FSCRYPT_MK_USER_DESCRIPTION_SIZE];
+	char uidbuf[KID_STR_LEN];
 	struct key *quota_key;
 	struct fscrypt_master_key_user *mk_user;
 	int err;
 
-	snprintf(description, sizeof(description), "%*phN.uid.%u",
+	snprintf(description, sizeof(description), "%*phN.uid.%s",
 		 FSCRYPT_KEY_IDENTIFIER_SIZE, mk->mk_spec.u.identifier,
-		 __kuid_val(uid));
+		 kuid_str(uid, uidbuf));
 	quota_key = key_alloc(&key_type_fscrypt_user, description, uid,
 			      current_gid(), current_cred(),
 			      KEY_POS_SEARCH | KEY_USR_VIEW, 0, NULL);
-- 
2.56.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help