apparmor: fix integer overflow in verify_tags() bounds check
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
| Linux Linux |
|
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
apparmor: fix integer overflow in verify_tags() bounds check
verify_tags() validates the tagset table unpacked from a policy blob. For each set it reads a count and checks that advancing the index by that count stays inside sets.table[]:
u32 cnt = tags->sets.table[i];
if (i+cnt >= tags->sets.size) {
i, cnt and sets.size are all u32, so i+cnt is evaluated modulo 2^32. sets.table[] is filled by unpack_tagsets() with aa_unpack_u32(), so every entry is a raw unbounded 32-bit word taken from the policy blob, and verify_tags() is the function that is supposed to validate it. A count close to U32_MAX makes the sum wrap to a small value, the guard passes, and the inner loop then walks sets.table[++i] past the end of the kcalloc(size, sizeof(u32)) allocation.
Note that sets.size is bounded by 65535, because unpack_tagsets() reads it with aa_unpack_array() as a u16, so the wrap cannot be reached by growing the table; it is reached purely through the attacker-supplied count.
With sets.size = 2 and sets.table = { 0, 0xffffffff }:
From the CVE record · Linux
The Linux kernel’s AppArmor policy loader has an integer overflow in verify_tags() that can cause an out-of-bounds read when loading a crafted policy blob. With the default unprivileged_userns_apparmor_policy=1 setting, an unprivileged task in a matched-level nested namespace can reach this path; no user interaction is described.
Engineers running Linux kernels with AppArmor should check whether their kernel includes the verify_tags() fix; affected versions are not specified.