Skip to content

Commit 172f993

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull security subsystem bugfixes from James Morris. * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: selinux: fix selinux_inode_setxattr oops KEYS: linux/key-type.h needs linux/errno.h smack: off by one error
2 parents 7272c30 + e3fea3f commit 172f993

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

‎include/linux/key-type.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define _LINUX_KEY_TYPE_H
1414

1515
#include <linux/key.h>
16+
#include <linux/errno.h>
1617

1718
#ifdef CONFIG_KEYS
1819

‎security/selinux/hooks.c‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2791,11 +2791,16 @@ static int selinux_inode_setxattr(struct dentry *dentry, const char *name,
27912791

27922792
/* We strip a nul only if it is at the end, otherwise the
27932793
* context contains a nul and we should audit that */
2794-
str = value;
2795-
if (str[size - 1] == '\0')
2796-
audit_size = size - 1;
2797-
else
2798-
audit_size = size;
2794+
if (value) {
2795+
str = value;
2796+
if (str[size - 1] == '\0')
2797+
audit_size = size - 1;
2798+
else
2799+
audit_size = size;
2800+
} else {
2801+
str = "";
2802+
audit_size = 0;
2803+
}
27992804
ab = audit_log_start(current->audit_context, GFP_ATOMIC, AUDIT_SELINUX_ERR);
28002805
audit_log_format(ab, "op=setxattr invalid_context=");
28012806
audit_log_n_untrustedstring(ab, value, audit_size);

‎security/smack/smackfs.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,11 @@ static int smk_parse_long_rule(const char *data, struct smack_rule *rule,
323323
int datalen;
324324
int rc = -1;
325325

326-
/*
327-
* This is probably inefficient, but safe.
328-
*/
326+
/* This is inefficient */
329327
datalen = strlen(data);
330-
subject = kzalloc(datalen, GFP_KERNEL);
328+
329+
/* Our first element can be 64 + \0 with no spaces */
330+
subject = kzalloc(datalen + 1, GFP_KERNEL);
331331
if (subject == NULL)
332332
return -1;
333333
object = kzalloc(datalen, GFP_KERNEL);

0 commit comments

Comments
 (0)