Skip to content

Commit

Permalink
keys: consider user namespace in key_permission
Browse files Browse the repository at this point in the history
If a key is owned by another user namespace, then treat the
key as though it is owned by both another uid and gid.

Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: James Morris <jmorris@namei.org>
  • Loading branch information
Serge E. Hallyn authored and James Morris committed Feb 27, 2009
1 parent 1d1e975 commit 8ff3bc3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions security/keys/permission.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ int key_task_permission(const key_ref_t key_ref, const struct cred *cred,

key = key_ref_to_ptr(key_ref);

if (key->user->user_ns != cred->user->user_ns)
goto use_other_perms;

/* use the second 8-bits of permissions for keys the caller owns */
if (key->uid == cred->fsuid) {
kperm = key->perm >> 16;
Expand All @@ -56,6 +59,8 @@ int key_task_permission(const key_ref_t key_ref, const struct cred *cred,
}
}

use_other_perms:

/* otherwise use the least-significant 8-bits */
kperm = key->perm;

Expand Down

0 comments on commit 8ff3bc3

Please sign in to comment.