[PATCH] apparmor: set xattr_count only after the xattrs array is allocated
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Fri Nov 27 08:07:53 UTC 2026
> unpack_xattrs() sets profile->attach.xattr_count before it allocates
> profile->attach.xattrs with kcalloc(). If the allocation fails, the load
> fails and free_attachment() runs on the profile. It loops over
> xattr_count entries and reads attach->xattrs[i], which is NULL, so it
> dereferences a NULL pointer.
>
> Set xattr_count after the allocation has succeeded.
>
> Fixes: 8e51f9087f40 ("apparmor: Add support for attaching profiles via xattr, presence and value")
> Signed-off-by: Cong Nguyen <congnt264 at gmail.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127080400.275982-1-congnt264@gmail.com?part=1
More information about the Linux-security-module-archive
mailing list