[PATCH] apparmor: fix query_data() output overlapping the lookup key
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Mon Oct 12 22:06:26 UTC 2026
> In query_data(), buf and query point into the same multi_transaction
> buffer: buf at the start, query a few bytes in, and the lookup key
> right after the label string that query points to. Reusing the buffer
> is by design and is safe as long as the query is fully parsed before
> buf is written to, but the key is not: it is dereferenced on every
> iteration of label_for_each_confined(), after output has already been
> written. So when the label has more than one profile with a data
> table, the data of the first matching profile is written to buf while
> the key is still needed, and overwrites it if the data is large enough.
> The later lookups then run on a corrupted key. Besides, if the data has
> no NUL byte from the key's position to the end of the allocation,
> strhash() -> strlen() -> jhash() reads past the 4096-byte slab object,
> triggering an out-of-bound read:
>
> BUG: KASAN: slab-out-of-bounds in jhash+0x595/0x5e0
> [ ... ]
> Fixes: 317d9a054e1c ("apparmor: update query interface to support label queries")
> Cc: stable at vger.kernel.org # v4.13+
> Cc: Francis Perron <francis at akrites.dev>
> Reported-by: AutonomousCodeSecurity at microsoft.com
> Signed-off-by: Cen Zhang (Microsoft) <cenzhang at linux.microsoft.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261012215703.30592-1-cenzhang@linux.microsoft.com?part=1
More information about the Linux-security-module-archive
mailing list