Skip to content

Commit

Permalink
apparmor: Fully initialize aa_perms struct when answering userspace q…
Browse files Browse the repository at this point in the history
…uery

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 <tyhicks@canonical.com>
Acked-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
  • Loading branch information
Tyler Hicks authored and John Johansen committed Jul 19, 2018
1 parent 7f3ebcf commit f4585bc
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions security/apparmor/apparmorfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ static const struct file_operations aa_fs_ns_revision_fops = {
static void profile_query_cb(struct aa_profile *profile, struct aa_perms *perms,
const char *match_str, size_t match_len)
{
struct aa_perms tmp;
struct aa_perms tmp = { };
struct aa_dfa *dfa;
unsigned int state = 0;

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

Expand All @@ -627,8 +626,6 @@ static void profile_query_cb(struct aa_profile *profile, struct aa_perms *perms,
match_str, match_len);
if (state)
aa_compute_perms(dfa, state, &tmp);
else
tmp = nullperms;
}
aa_apply_modes_to_perms(profile, &tmp);
aa_perms_accum_raw(perms, &tmp);
Expand Down

0 comments on commit f4585bc

Please sign in to comment.