Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 4f3b3f2d79a4 ("apparmor: add profile permission query ability")
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>

authored by

Tyler Hicks and committed by
John Johansen
f4585bc2 7f3ebcf2

+1 -4
+1 -4
security/apparmor/apparmorfs.c
··· 603 603 static void profile_query_cb(struct aa_profile *profile, struct aa_perms *perms, 604 604 const char *match_str, size_t match_len) 605 605 { 606 - struct aa_perms tmp; 606 + struct aa_perms tmp = { }; 607 607 struct aa_dfa *dfa; 608 608 unsigned int state = 0; 609 609 ··· 613 613 dfa = profile->file.dfa; 614 614 state = aa_dfa_match_len(dfa, profile->file.start, 615 615 match_str + 1, match_len - 1); 616 - tmp = nullperms; 617 616 if (state) { 618 617 struct path_cond cond = { }; 619 618 ··· 626 627 match_str, match_len); 627 628 if (state) 628 629 aa_compute_perms(dfa, state, &tmp); 629 - else 630 - tmp = nullperms; 631 630 } 632 631 aa_apply_modes_to_perms(profile, &tmp); 633 632 aa_perms_accum_raw(perms, &tmp);