Skip to content

Commit

Permalink
Merge branch 'keys-fixes' into keys-next
Browse files Browse the repository at this point in the history
Signed-off-by: David Howells <[email protected]>
  • Loading branch information
dhowells committed Jul 22, 2014
2 parents 64724cf + 0d1f64f commit 633706a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 3 deletions.
1 change: 0 additions & 1 deletion crypto/asymmetric_keys/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ config ASYMMETRIC_PUBLIC_KEY_SUBTYPE

config PUBLIC_KEY_ALGO_RSA
tristate "RSA public-key algorithm"
select MPILIB_EXTRA
select MPILIB
help
This option enables support for the RSA algorithm (PKCS#1, RFC3447).
Expand Down
2 changes: 2 additions & 0 deletions fs/nfs/idmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ static struct key *nfs_idmap_request_key(const char *name, size_t namelen,
desc, "", 0, idmap);
mutex_unlock(&idmap->idmap_mutex);
}
if (!IS_ERR(rkey))
set_bit(KEY_FLAG_ROOT_CAN_INVAL, &rkey->flags);

kfree(desc);
return rkey;
Expand Down
1 change: 1 addition & 0 deletions include/linux/key.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ struct key {
#define KEY_FLAG_TRUSTED 8 /* set if key is trusted */
#define KEY_FLAG_TRUSTED_ONLY 9 /* set if keyring only accepts links to trusted keys */
#define KEY_FLAG_BUILTIN 10 /* set if key is builtin */
#define KEY_FLAG_ROOT_CAN_INVAL 11 /* set if key can be invalidated by root without permission */

/* the key type and key description string
* - the desc is used to match a key against search criteria
Expand Down
3 changes: 2 additions & 1 deletion lib/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,8 @@ config MPILIB

config SIGNATURE
tristate
depends on KEYS && CRYPTO
depends on KEYS
select CRYPTO
select CRYPTO_SHA1
select MPILIB
help
Expand Down
1 change: 1 addition & 0 deletions net/dns_resolver/dns_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ int dns_query(const char *type, const char *name, size_t namelen,
}

down_read(&rkey->sem);
set_bit(KEY_FLAG_ROOT_CAN_INVAL, &rkey->flags);
rkey->perm |= KEY_USR_VIEW;

ret = key_validate(rkey);
Expand Down
15 changes: 14 additions & 1 deletion security/keys/keyctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,25 @@ long keyctl_invalidate_key(key_serial_t id)
key_ref = lookup_user_key(id, 0, KEY_NEED_SEARCH);
if (IS_ERR(key_ref)) {
ret = PTR_ERR(key_ref);

/* Root is permitted to invalidate certain special keys */
if (capable(CAP_SYS_ADMIN)) {
key_ref = lookup_user_key(id, 0, 0);
if (IS_ERR(key_ref))
goto error;
if (test_bit(KEY_FLAG_ROOT_CAN_INVAL,
&key_ref_to_ptr(key_ref)->flags))
goto invalidate;
goto error_put;
}

goto error;
}

invalidate:
key_invalidate(key_ref_to_ptr(key_ref));
ret = 0;

error_put:
key_ref_put(key_ref);
error:
kleave(" = %ld", ret);
Expand Down

0 comments on commit 633706a

Please sign in to comment.