Skip to content

Commit 7e4b935

Browse files
committed
Merge branch 'for-linus2' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull security layer fixes from James Morris: "A fix for SELinux policy processing (regression introduced by commit fa1aa14: "selinux: extended permissions for ioctls"), as well as a fix for the user-triggerable oops in the Keys code" * 'for-linus2' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: KEYS: Fix handling of stored error in a negatively instantiated user key selinux: fix bug in conditional rules handling
2 parents c64410f + 6e37592 commit 7e4b935

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

security/keys/encrypted-keys/encrypted.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,8 @@ static int encrypted_update(struct key *key, struct key_preparsed_payload *prep)
845845
size_t datalen = prep->datalen;
846846
int ret = 0;
847847

848+
if (test_bit(KEY_FLAG_NEGATIVE, &key->flags))
849+
return -ENOKEY;
848850
if (datalen <= 0 || datalen > 32767 || !prep->data)
849851
return -EINVAL;
850852

security/keys/trusted.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,13 +1007,16 @@ static void trusted_rcu_free(struct rcu_head *rcu)
10071007
*/
10081008
static int trusted_update(struct key *key, struct key_preparsed_payload *prep)
10091009
{
1010-
struct trusted_key_payload *p = key->payload.data[0];
1010+
struct trusted_key_payload *p;
10111011
struct trusted_key_payload *new_p;
10121012
struct trusted_key_options *new_o;
10131013
size_t datalen = prep->datalen;
10141014
char *datablob;
10151015
int ret = 0;
10161016

1017+
if (test_bit(KEY_FLAG_NEGATIVE, &key->flags))
1018+
return -ENOKEY;
1019+
p = key->payload.data[0];
10171020
if (!p->migratable)
10181021
return -EPERM;
10191022
if (datalen <= 0 || datalen > 32767 || !prep->data)

security/keys/user_defined.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ int user_update(struct key *key, struct key_preparsed_payload *prep)
120120

121121
if (ret == 0) {
122122
/* attach the new data, displacing the old */
123-
zap = key->payload.data[0];
123+
if (!test_bit(KEY_FLAG_NEGATIVE, &key->flags))
124+
zap = key->payload.data[0];
125+
else
126+
zap = NULL;
124127
rcu_assign_keypointer(key, upayload);
125128
key->expiry = 0;
126129
}

security/selinux/ss/conditional.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ void cond_compute_av(struct avtab *ctab, struct avtab_key *key,
638638
{
639639
struct avtab_node *node;
640640

641-
if (!ctab || !key || !avd || !xperms)
641+
if (!ctab || !key || !avd)
642642
return;
643643

644644
for (node = avtab_search_node(ctab, key); node;
@@ -657,7 +657,7 @@ void cond_compute_av(struct avtab *ctab, struct avtab_key *key,
657657
if ((u16)(AVTAB_AUDITALLOW|AVTAB_ENABLED) ==
658658
(node->key.specified & (AVTAB_AUDITALLOW|AVTAB_ENABLED)))
659659
avd->auditallow |= node->datum.u.data;
660-
if ((node->key.specified & AVTAB_ENABLED) &&
660+
if (xperms && (node->key.specified & AVTAB_ENABLED) &&
661661
(node->key.specified & AVTAB_XPERMS))
662662
services_compute_xperms_drivers(xperms, node);
663663
}

0 commit comments

Comments
 (0)