* [PATCH] KEYS: Reject restricted dest_keyring in construct_alloc_key()
@ 2026-10-31 9:28 Jarkko Sakkinen
2026-10-31 9:28 ` Jarkko Sakkinen
2026-10-31 9:49 ` Jarkko Sakkinen
0 siblings, 2 replies; 3+ messages in thread
From: Jarkko Sakkinen @ 2026-10-31 9:28 UTC (permalink / raw)
To: David Howells
Cc: Eric Biggers, linux-integrity, Jarkko Sakkinen, stable,
Anvik Loitongbam, Paul Moore, James Morris, Serge E. Hallyn,
Mimi Zohar, open list:KEYS/KEYRINGS, open list:SECURITY SUBSYSTEM,
open list
construct_alloc_key() links keys into dest_keyring without checking
restrict_link, allowing keys whose key->state reaches KEY_IS_POSITIVE to
remain in a restricted keyring when instantiated without relinking into
dest_keyring. Reject restricted destination keyrings with -EPERM after
__key_link_lock() unless KEY_ALLOC_BYPASS_RESTRICTION is set.
Cc: stable@vger.kernel.org
Fixes: 5ac7eace2d00 ("KEYS: Add a facility to restrict new links into a keyring")
Reported-by: Anvik Loitongbam <permissiontogallop@gmail.com>
Closes: https://lore.kernel.org/keyrings/20261030173930.40948-1-permissiontogallop@gmail.com/
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
---
security/keys/request_key.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/security/keys/request_key.c b/security/keys/request_key.c
index 22cd66a44da5..d4611dd7cb49 100644
--- a/security/keys/request_key.c
+++ b/security/keys/request_key.c
@@ -404,6 +404,11 @@ static int construct_alloc_key(struct keyring_search_context *ctx,
ret = __key_link_lock(dest_keyring, &key->index_key);
if (ret < 0)
goto link_lock_failed;
+
+ if (dest_keyring->restrict_link && !(flags & KEY_ALLOC_BYPASS_RESTRICTION)) {
+ ret = -EPERM;
+ goto link_alloc_failed_unlocked;
+ }
}
/*
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH] KEYS: Reject restricted dest_keyring in construct_alloc_key()
2026-10-31 9:28 [PATCH] KEYS: Reject restricted dest_keyring in construct_alloc_key() Jarkko Sakkinen
@ 2026-10-31 9:28 ` Jarkko Sakkinen
2026-10-31 9:49 ` Jarkko Sakkinen
1 sibling, 0 replies; 3+ messages in thread
From: Jarkko Sakkinen @ 2026-10-31 9:28 UTC (permalink / raw)
To: David Howells
Cc: Eric Biggers, linux-integrity, Jarkko Sakkinen, stable,
Anvik Loitongbam, Paul Moore, James Morris, Serge E. Hallyn,
Mimi Zohar, open list:KEYS/KEYRINGS, open list:SECURITY SUBSYSTEM,
open list
construct_alloc_key() links keys into dest_keyring without checking
restrict_link, allowing keys whose key->state reaches KEY_IS_POSITIVE to
remain in a restricted keyring when instantiated without relinking into
dest_keyring. Reject restricted destination keyrings with -EPERM after
__key_link_lock() unless KEY_ALLOC_BYPASS_RESTRICTION is set.
Cc: stable@vger.kernel.org
Fixes: 5ac7eace2d00 ("KEYS: Add a facility to restrict new links into a keyring")
Reported-by: Anvik Loitongbam <permissiontogallop@gmail.com>
Closes: https://lore.kernel.org/keyrings/20261030173930.40948-1-permissiontogallop@gmail.com/
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
---
security/keys/request_key.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/security/keys/request_key.c b/security/keys/request_key.c
index 22cd66a44da5..d4611dd7cb49 100644
--- a/security/keys/request_key.c
+++ b/security/keys/request_key.c
@@ -404,6 +404,11 @@ static int construct_alloc_key(struct keyring_search_context *ctx,
ret = __key_link_lock(dest_keyring, &key->index_key);
if (ret < 0)
goto link_lock_failed;
+
+ if (dest_keyring->restrict_link && !(flags & KEY_ALLOC_BYPASS_RESTRICTION)) {
+ ret = -EPERM;
+ goto link_alloc_failed_unlocked;
+ }
}
/*
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] KEYS: Reject restricted dest_keyring in construct_alloc_key()
2026-10-31 9:28 [PATCH] KEYS: Reject restricted dest_keyring in construct_alloc_key() Jarkko Sakkinen
2026-10-31 9:28 ` Jarkko Sakkinen
@ 2026-10-31 9:49 ` Jarkko Sakkinen
1 sibling, 0 replies; 3+ messages in thread
From: Jarkko Sakkinen @ 2026-10-31 9:49 UTC (permalink / raw)
To: David Howells
Cc: Eric Biggers, linux-integrity, stable, Anvik Loitongbam,
Paul Moore, James Morris, Serge E. Hallyn, Mimi Zohar,
open list:KEYS/KEYRINGS, open list:SECURITY SUBSYSTEM, open list
On Sat, Oct 31, 2026 at 11:28:18AM +0200, Jarkko Sakkinen wrote:
> construct_alloc_key() links keys into dest_keyring without checking
> restrict_link, allowing keys whose key->state reaches KEY_IS_POSITIVE to
> remain in a restricted keyring when instantiated without relinking into
> dest_keyring. Reject restricted destination keyrings with -EPERM after
> __key_link_lock() unless KEY_ALLOC_BYPASS_RESTRICTION is set.
>
> Cc: stable@vger.kernel.org
> Fixes: 5ac7eace2d00 ("KEYS: Add a facility to restrict new links into a keyring")
> Reported-by: Anvik Loitongbam <permissiontogallop@gmail.com>
> Closes: https://lore.kernel.org/keyrings/20261030173930.40948-1-permissiontogallop@gmail.com/
> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
I don't understand why this came out twice. I must have forgot to add
--dry-run when I trialed it. Sorry about that; was unintended.
Br, Jarkko
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-31 9:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-31 9:28 [PATCH] KEYS: Reject restricted dest_keyring in construct_alloc_key() Jarkko Sakkinen
2026-10-31 9:28 ` Jarkko Sakkinen
2026-10-31 9:49 ` Jarkko Sakkinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox