Skip to content

Commit

Permalink
apparmor: fix invalid reference to index variable of iterator line 836
Browse files Browse the repository at this point in the history
Once the loop on lines 836-853 is complete and exits normally, ent is a
pointer to the dummy list head value.  The derefernces accessible from eg
the goto fail on line 860 or the various goto fail_lock's afterwards thus
seem incorrect.

Reported-by: Julia Lawall <[email protected]>
Signed-off-by: John Johansen <[email protected]>
Signed-off-by: James Morris <[email protected]>
  • Loading branch information
John Johansen authored and James Morris committed Apr 6, 2017
1 parent 9814448 commit b9b144b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions security/apparmor/policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -876,9 +876,11 @@ ssize_t aa_replace_profiles(struct aa_ns *view, struct aa_profile *profile,
if (ns_name) {
ns = aa_prepare_ns(view, ns_name);
if (IS_ERR(ns)) {
op = OP_PROF_LOAD;
info = "failed to prepare namespace";
error = PTR_ERR(ns);
ns = NULL;
ent = NULL;
goto fail;
}
} else
Expand Down Expand Up @@ -1013,7 +1015,7 @@ ssize_t aa_replace_profiles(struct aa_ns *view, struct aa_profile *profile,
/* audit cause of failure */
op = (!ent->old) ? OP_PROF_LOAD : OP_PROF_REPL;
fail:
audit_policy(profile, op, ns_name, ent->new->base.hname,
audit_policy(profile, op, ns_name, ent ? ent->new->base.hname : NULL,
info, error);
/* audit status that rest of profiles in the atomic set failed too */
info = "valid profile in failed atomic policy load";
Expand All @@ -1023,7 +1025,7 @@ ssize_t aa_replace_profiles(struct aa_ns *view, struct aa_profile *profile,
/* skip entry that caused failure */
continue;
}
op = (!ent->old) ? OP_PROF_LOAD : OP_PROF_REPL;
op = (!tmp->old) ? OP_PROF_LOAD : OP_PROF_REPL;
audit_policy(profile, op, ns_name,
tmp->new->base.hname, info, error);
}
Expand Down

0 comments on commit b9b144b

Please sign in to comment.