Skip to content

Commit 86dc969

Browse files
l0kodpcmoore
authored andcommitted
selinux: fix lsm_get_self_attr()
selinux_getselfattr() doesn't properly initialize the string pointer it passes to selinux_lsm_getattr() which can cause a problem when an attribute hasn't been explicitly set; selinux_lsm_getattr() returns 0/success, but does not set or initialize the string label/attribute. Failure to properly initialize the string causes problems later in selinux_getselfattr() when the function attempts to kfree() the string. Cc: Casey Schaufler <[email protected]> Fixes: 762c934 ("SELinux: Add selfattr hooks") Suggested-by: Paul Moore <[email protected]> [PM: description changes as discussed in the thread] Signed-off-by: Mickaël Salaün <[email protected]> Signed-off-by: Paul Moore <[email protected]>
1 parent d8bdd79 commit 86dc969

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

security/selinux/hooks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6559,7 +6559,7 @@ static int selinux_getselfattr(unsigned int attr, struct lsm_ctx __user *ctx,
65596559
size_t *size, u32 flags)
65606560
{
65616561
int rc;
6562-
char *val;
6562+
char *val = NULL;
65636563
int val_len;
65646564

65656565
val_len = selinux_lsm_getattr(attr, current, &val);

0 commit comments

Comments
 (0)