KEYS: Reject restricted dest_keyring in construct_alloc_key()
Subsystems (4)
Jarkko Sakkinen
maintainerPATCH 1/1 KEYS: Reject restricted dest_keyring in construct_alloc_key()
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.
--- security/keys/request_key.c | 5 +++++ 1 file changed, 5 insertions(+)
security/keys/request_key.c +5 -0
@@ -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
Jarkko Sakkinen
maintainerPATCH 1/1 KEYS: Reject restricted dest_keyring in construct_alloc_key()
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.
--- security/keys/request_key.c | 5 +++++ 1 file changed, 5 insertions(+)
security/keys/request_key.c +5 -0
@@ -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
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 11 lines
construct_alloc_key()links keys intodest_keyringwithout checkingrestrict_link, allowing keys whosekey->statereachesKEY_IS_POSITIVEto remain in a restricted keyring when instantiated without relinking intodest_keyring. Reject restricted destination keyrings with-EPERMafter__key_link_lock()unlessKEY_ALLOC_BYPASS_RESTRICTIONis set.Fixes 5ac7eace2d00 ("KEYS: Add a facility to restrict new links into a keyring")Reported-by Anvik Loitongbam <[email protected]>Signed-off-by Jarkko Sakkinen <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 11 lines
construct_alloc_key()links keys intodest_keyringwithout checkingrestrict_link, allowing keys whosekey->statereachesKEY_IS_POSITIVEto remain in a restricted keyring when instantiated without relinking intodest_keyring. Reject restricted destination keyrings with-EPERMafter__key_link_lock()unlessKEY_ALLOC_BYPASS_RESTRICTIONis set.Fixes 5ac7eace2d00 ("KEYS: Add a facility to restrict new links into a keyring")Reported-by Anvik Loitongbam <[email protected]>Signed-off-by Jarkko Sakkinen <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Jarkko Sakkinen
maintainerQuoted 11 lines · Jarkko Sakkinen
construct_alloc_key()links keys intodest_keyringwithout checkingrestrict_link, allowing keys whosekey->statereachesKEY_IS_POSITIVEto remain in a restricted keyring when instantiated without relinking intodest_keyring. Reject restricted destination keyrings with-EPERMafter__key_link_lock()unlessKEY_ALLOC_BYPASS_RESTRICTIONis set.Fixes 5ac7eace2d00 ("KEYS: Add a facility to restrict new links into a keyring")Reported-by Anvik Loitongbam <[email protected]>Signed-off-by Jarkko Sakkinen <[email protected]>
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