security/keys: remove possessor verify after key permission check
Quoted 11 lines · Alexey Krasikov
In
security/keys/keyctl.c:keyctl_read_key()afterkey_permission()check is calledis_key_possessed(). According to the current logic, if the caller is a possessor, then it can read the key regardless of whether it has rights to do so.if I remove the possessor read rights:
keyctl_setperm(key, KEY_POS_ALL & (~KEY_POS_SETATTR));the calling process will still be able to read the key if it is possessor.
In other words, if the possessor doesn't have read rights, it doesn't matter.
Quoted 8 lines
---
I may be misunderstanding the logic behind it, but here's the patch to stir the discussion.Signed-off-by Alexey Krasikov <[email protected]>--- security/keys/keyctl.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
Hmm, looks like this still didn't make it to the keyrings@ list :(
On the off-chance that my reply /does/ make it, I've left the whole of the patch intact below. Please can somebody have a look?
Will
--->8
Quoted 31 lines
security/keys/keyctl.c +1
-14@@ -845,22 +845,9 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen)/* see if we can read it directly */ ret =key_permission (key_ref,KEY_NEED_READ ); -if (ret =0 ) - goto can_read_key; -if (ret != -EACCES ) +if (ret !=0 ) goto key_put_out; -/* we can't; see if it's searchable from this process's keyrings -* - we automatically take account of the fact that it may be -* dangling off an instantiation key -*/ -if (!is_key_possessed (key_ref)) { - ret = -EACCES ; - goto key_put_out; - } - -/* the key is probably readable - now try to read it */ -can_read_key:if (!key->type->read) { ret = -EOPNOTSUPP ; goto key_put_out;Signature · 1 line
2.17.1
Quoted 21 lines · Will Deacon
Quoted 11 lines · Alexey Krasikov
In
security/keys/keyctl.c:keyctl_read_key()afterkey_permission()check is calledis_key_possessed(). According to the current logic, if the caller is a possessor, then it can read the key regardless of whether it has rights to do so.if I remove the possessor read rights:
keyctl_setperm(key, KEY_POS_ALL & (~KEY_POS_SETATTR));the calling process will still be able to read the key if it is possessor.
In other words, if the possessor doesn't have read rights, it doesn't matter.
Quoted 8 lines
---
I may be misunderstanding the logic behind it, but here's the patch to stir the discussion.Signed-off-by Alexey Krasikov <[email protected]>--- security/keys/keyctl.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
Quoted 6 lines
Hmm, looks like this still didn't make it to the keyrings@ list :(
On the off-chance that my reply /does/ make it, I've left the whole of the patch intact below. Please can somebody have a look?
Will
Hi, I'm on this. Just didn't have time last week. Looking it through on *some* day this week properly.
/Jarkko
Quoted 9 lines · Alexey Krasikov
In
security/keys/keyctl.c:keyctl_read_key()afterkey_permission()check is calledis_key_possessed(). According to the current logic, if the caller is a possessor, then it can read the key regardless of whether it has rights to do so.if I remove the possessor read rights:
keyctl_setperm(key, KEY_POS_ALL & (~KEY_POS_SETATTR));the calling process will still be able to read the key if it is possessor.
Quoted 7 lines
In other words, if the possessor doesn't have read rights, it doesn't matter.
---
I may be misunderstanding the logic behind it, but here's the patch to stir the discussion.Signed-off-by Alexey Krasikov <[email protected]>
Tried this:
$ KEYID=$(keyctl add user john smith @u) $ keyctl setperm $KEYID 0x20000000 $ keyctl read $KEYID keyctl_read_alloc: Permission denied
You did not provide a full example like this so I have to assume that this is what you meant.
/Jarkko
Quoted 5 lines · Алексей Красиков
You've removed all the attributes except the reading. Nothing can be done with the key if it can't be found. Try this:
Quoted 7 lines
$ KEYID=$(keyctl add user john smith @u) $ keyctl describe $KEYID $ keyctl setperm $KEYID 0x3d000000 $ keyctl describe $KEYID $ keyctl print $KEYID /Alexey
Hi please re-respond with plain text.
HTML mails do not go to vger.kernel.org. Also please try to avoid top posting (i.e. quote and respond inline).
/Jarkko
Quoted 29 lines · Alexey Krasikov
14.05.2020 12:46, Alexey Krasikov пишет:
Quoted 21 lines
Quoted 10 lines
07.05.2020, 10:24, "Jarkko Sakkinen" <[email protected]>:
Tried this:
$ KEYID=$(keyctl add user john smith @u)
$ keyctl setperm $KEYID0x20000000
$ keyctl read $KEYID
keyctl_read_alloc: Permission deniedQuoted 7 lines
You did not provide a full example like this so I have to assume
that
this is what you meant./Jarkko
You've removed all the attributes except the reading. Nothing can be done with the key if it can't be found. Try this:
Quoted 6 lines
$ KEYID=$(keyctl add user john smith @u) $ keyctl describe $KEYID $ keyctl setperm $KEYID 0x3d000000 $ keyctl describe $KEYID $ keyctl print $KEYID /Alexey
Quoted 1 line
ping
Please send a new version with a full example of the scenario that you are referring. This thread became too messy to follow with the HTML emails included (that do no reach vger).
/Jarkko
On Wed, 2020-05-27 at 22:47 +0300, Jarkko Sakkinen wrote:
[...]
Quoted 5 lines
Quoted 1 line
ping
Please send a new version with a full example of the scenario that you are referring. This thread became too messy to follow with the HTML emails included (that do no reach vger).
Yes, please ... I'm missing most of the emails because of the vger and html problem. I think the request is to remove the possessor check in keyctl_read, but just done blindly that would completely destroy our namespaced security system for keys, so it doesn't sound like a good idea at all. What's the actual problem this is trying to solve? It's annoying that root has to join the session keyring to read a key, but the reason for it is well justified and the fact that even root can't reach some session keyrings is a feature not a bug.
James