Skip to content

Commit

Permalink
apparmor: fix bind mounts aborting with -ENOMEM
Browse files Browse the repository at this point in the history
With commit df32333 ("apparmor: Use a memory pool instead per-CPU
caches, 2019-05-03"), AppArmor code was converted to use memory pools. In
that conversion, a bug snuck into the code that polices bind mounts that
causes all bind mounts to fail with -ENOMEM, as we erroneously error out
if `aa_get_buffer` returns a pointer instead of erroring out when it
does _not_ return a valid pointer.

Fix the issue by correctly checking for valid pointers returned by
`aa_get_buffer` to fix bind mounts with AppArmor.

Fixes: df32333 ("apparmor: Use a memory pool instead per-CPU caches")
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: John Johansen <john.johansen@canonical.com>
  • Loading branch information
Patrick Steinhardt authored and John Johansen committed Jan 2, 2020
1 parent fd69884 commit 9c95a27
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion security/apparmor/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ int aa_bind_mount(struct aa_label *label, const struct path *path,
buffer = aa_get_buffer(false);
old_buffer = aa_get_buffer(false);
error = -ENOMEM;
if (!buffer || old_buffer)
if (!buffer || !old_buffer)
goto out;

error = fn_for_each_confined(label, profile,
Expand Down

0 comments on commit 9c95a27

Please sign in to comment.