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

From: Jan Koester

Date: Sun Oct 18 2026 - 14:09:43 EST


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 <jan.koester@xxxxxxx>
---
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