Skip to content

Commit f4585bc

Browse files
tyhicksjrjohansen
authored andcommitted
apparmor: Fully initialize aa_perms struct when answering userspace query
Fully initialize the aa_perms struct in profile_query_cb() to avoid the potential of using an uninitialized struct member's value in a response to a query from userspace. Detected by CoverityScan CID#1415126 ("Uninitialized scalar variable") Fixes: 4f3b3f2 ("apparmor: add profile permission query ability") Signed-off-by: Tyler Hicks <[email protected]> Acked-by: Serge Hallyn <[email protected]> Signed-off-by: John Johansen <[email protected]>
1 parent 7f3ebcf commit f4585bc

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

security/apparmor/apparmorfs.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ static const struct file_operations aa_fs_ns_revision_fops = {
603603
static void profile_query_cb(struct aa_profile *profile, struct aa_perms *perms,
604604
const char *match_str, size_t match_len)
605605
{
606-
struct aa_perms tmp;
606+
struct aa_perms tmp = { };
607607
struct aa_dfa *dfa;
608608
unsigned int state = 0;
609609

@@ -613,7 +613,6 @@ static void profile_query_cb(struct aa_profile *profile, struct aa_perms *perms,
613613
dfa = profile->file.dfa;
614614
state = aa_dfa_match_len(dfa, profile->file.start,
615615
match_str + 1, match_len - 1);
616-
tmp = nullperms;
617616
if (state) {
618617
struct path_cond cond = { };
619618

@@ -627,8 +626,6 @@ static void profile_query_cb(struct aa_profile *profile, struct aa_perms *perms,
627626
match_str, match_len);
628627
if (state)
629628
aa_compute_perms(dfa, state, &tmp);
630-
else
631-
tmp = nullperms;
632629
}
633630
aa_apply_modes_to_perms(profile, &tmp);
634631
aa_perms_accum_raw(perms, &tmp);

0 commit comments

Comments
 (0)