Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: KEYS: Permit key_serial() to be called with a const key pointer keys: fix user_defined key sparse messages ima: fix cred sparse warning MPILIB: Add a missing ENOMEM check
This commit is contained in:
commit
afd290945c
@ -271,7 +271,7 @@ extern int keyring_add_key(struct key *keyring,
|
|||||||
|
|
||||||
extern struct key *key_lookup(key_serial_t id);
|
extern struct key *key_lookup(key_serial_t id);
|
||||||
|
|
||||||
static inline key_serial_t key_serial(struct key *key)
|
static inline key_serial_t key_serial(const struct key *key)
|
||||||
{
|
{
|
||||||
return key ? key->serial : 0;
|
return key ? key->serial : 0;
|
||||||
}
|
}
|
||||||
|
@ -255,6 +255,8 @@ void *mpi_get_buffer(MPI a, unsigned *nbytes, int *sign)
|
|||||||
if (!n)
|
if (!n)
|
||||||
n++; /* avoid zero length allocation */
|
n++; /* avoid zero length allocation */
|
||||||
p = buffer = kmalloc(n, GFP_KERNEL);
|
p = buffer = kmalloc(n, GFP_KERNEL);
|
||||||
|
if (!p)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
for (i = a->nlimbs - 1; i >= 0; i--) {
|
for (i = a->nlimbs - 1; i >= 0; i--) {
|
||||||
alimb = a->d[i];
|
alimb = a->d[i];
|
||||||
|
@ -99,6 +99,7 @@ static bool ima_match_rules(struct ima_measure_rule_entry *rule,
|
|||||||
struct inode *inode, enum ima_hooks func, int mask)
|
struct inode *inode, enum ima_hooks func, int mask)
|
||||||
{
|
{
|
||||||
struct task_struct *tsk = current;
|
struct task_struct *tsk = current;
|
||||||
|
const struct cred *cred = current_cred();
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if ((rule->flags & IMA_FUNC) && rule->func != func)
|
if ((rule->flags & IMA_FUNC) && rule->func != func)
|
||||||
@ -108,7 +109,7 @@ static bool ima_match_rules(struct ima_measure_rule_entry *rule,
|
|||||||
if ((rule->flags & IMA_FSMAGIC)
|
if ((rule->flags & IMA_FSMAGIC)
|
||||||
&& rule->fsmagic != inode->i_sb->s_magic)
|
&& rule->fsmagic != inode->i_sb->s_magic)
|
||||||
return false;
|
return false;
|
||||||
if ((rule->flags & IMA_UID) && rule->uid != tsk->cred->uid)
|
if ((rule->flags & IMA_UID) && rule->uid != cred->uid)
|
||||||
return false;
|
return false;
|
||||||
for (i = 0; i < MAX_LSM_RULES; i++) {
|
for (i = 0; i < MAX_LSM_RULES; i++) {
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
@ -59,7 +59,7 @@ int user_instantiate(struct key *key, const void *data, size_t datalen)
|
|||||||
/* attach the data */
|
/* attach the data */
|
||||||
upayload->datalen = datalen;
|
upayload->datalen = datalen;
|
||||||
memcpy(upayload->data, data, datalen);
|
memcpy(upayload->data, data, datalen);
|
||||||
rcu_assign_pointer(key->payload.data, upayload);
|
rcu_assign_keypointer(key, upayload);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
@ -98,7 +98,7 @@ int user_update(struct key *key, const void *data, size_t datalen)
|
|||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
/* attach the new data, displacing the old */
|
/* attach the new data, displacing the old */
|
||||||
zap = key->payload.data;
|
zap = key->payload.data;
|
||||||
rcu_assign_pointer(key->payload.data, upayload);
|
rcu_assign_keypointer(key, upayload);
|
||||||
key->expiry = 0;
|
key->expiry = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ void user_revoke(struct key *key)
|
|||||||
key_payload_reserve(key, 0);
|
key_payload_reserve(key, 0);
|
||||||
|
|
||||||
if (upayload) {
|
if (upayload) {
|
||||||
rcu_assign_pointer(key->payload.data, NULL);
|
rcu_assign_keypointer(key, NULL);
|
||||||
kfree_rcu(upayload, rcu);
|
kfree_rcu(upayload, rcu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user