]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commit
apparmor: fix race on rawdata dereference
authorJohn Johansen <john.johansen@canonical.com>
Tue, 24 Feb 2026 18:20:02 +0000 (10:20 -0800)
committerJohn Johansen <john.johansen@canonical.com>
Mon, 9 Mar 2026 23:05:44 +0000 (16:05 -0700)
commita0b7091c4de45a7325c8780e6934a894f92ac86b
treeca6aeb988d078924c277f8def6cf2a695c74211a
parent39440b137546a3aa383cfdabc605fb73811b6093
apparmor: fix race on rawdata dereference

There is a race condition that leads to a use-after-free situation:
because the rawdata inodes are not refcounted, an attacker can start
open()ing one of the rawdata files, and at the same time remove the
last reference to this rawdata (by removing the corresponding profile,
for example), which frees its struct aa_loaddata; as a result, when
seq_rawdata_open() is reached, i_private is a dangling pointer and
freed memory is accessed.

The rawdata inodes weren't refcounted to avoid a circular refcount and
were supposed to be held by the profile rawdata reference.  However
during profile removal there is a window where the vfs and profile
destruction race, resulting in the use after free.

Fix this by moving to a double refcount scheme. Where the profile
refcount on rawdata is used to break the circular dependency. Allowing
for freeing of the rawdata once all inode references to the rawdata
are put.

Fixes: 5d5182cae401 ("apparmor: move to per loaddata files, instead of replicating in profiles")
Reported-by: Qualys Security Advisory <qsa@qualys.com>
Reviewed-by: Georgia Garcia <georgia.garcia@canonical.com>
Reviewed-by: Maxime Bélair <maxime.belair@canonical.com>
Reviewed-by: Cengiz Can <cengiz.can@canonical.com>
Tested-by: Salvatore Bonaccorso <carnil@debian.org>
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/apparmorfs.c
security/apparmor/include/policy_unpack.h
security/apparmor/policy.c
security/apparmor/policy_unpack.c