apparmor: backport CVE-2026-45893, CVE-2026-46254
Subsystems (2)
cover apparmor: backport CVE-2026-45893, CVE-2026-46254
Hi Greg, Sasha, and maintainers,
I'm working through the smaller CVE backports still missing from 6.6.y. These 2 upstream changes belong together for CVE-2026-45893, CVE-2026-46254. They must be applied in this order because the later change depends on or completes the earlier one.
The complete series is already present in 6.12.y, 6.18.y, and 7.2.y. These fixes also affect 6.1.y, which will need a separate backport; this series is only for 6.6.y.
Could you please consider this series for 6.6.y?
Thanks,
Artem Dinaburg
Series:
1. AppArmor: Allow apparmor to handle unaligned dfa tables
2. apparmor: Fix & Optimize table creation from possibly unaligned memory
PATCH 1/2 AppArmor: Allow apparmor to handle unaligned dfa tables
From: Helge Deller <[email protected]>
[ Upstream commit 64802f731214a51dfe3c6c27636b3ddafd003eb0 ]
The dfa tables can originate from kernel or userspace and 8-byte alignment isn't always guaranteed and as such may trigger unaligned memory accesses on various architectures. Resulting in the following
[ 73.901376] WARNING: CPU: 0 PID: 341 at security/apparmor/match.c:316 aa_dfa_unpack+0x6cc/0x720
[ 74.015867] Modules linked in: binfmt_misc evdev flash sg drm drm_panel_orientation_quirks backlight i2c_core configfs nfnetlink autofs4 ext4 crc16 mbcache jbd2 hid_generic usbhid sr_mod hid cdrom sd_mod ata_generic ohci_pci ehci_pci ehci_hcd ohci_hcd pata_ali libata sym53c8xx scsi_transport_spi tg3 scsi_mod usbcore libphy scsi_common mdio_bus usb_common
[ 74.428977] CPU: 0 UID: 0 PID: 341 Comm: apparmor_parser Not tainted 6.18.0-rc6+ #9 NONE
[ 74.536543] Call Trace:
[ 74.568561] [<0000000000434c24>] dump_stack+0x8/0x18
[ 74.633757] [<0000000000476438>] __warn+0xd8/0x100
[ 74.696664] [<00000000004296d4>] warn_slowpath_fmt+0x34/0x74
[ 74.771006] [<00000000008db28c>] aa_dfa_unpack+0x6cc/0x720
[ 74.843062] [<00000000008e643c>] unpack_pdb+0xbc/0x7e0
[ 74.910545] [<00000000008e7740>] unpack_profile+0xbe0/0x1300
[ 74.984888] [<00000000008e82e0>] aa_unpack+0xe0/0x6a0
[ 75.051226] [<00000000008e3ec4>] aa_replace_profiles+0x64/0x1160
[ 75.130144] [<00000000008d4d90>] policy_update+0xf0/0x280
[ 75.201057] [<00000000008d4fc8>] profile_replace+0xa8/0x100
[ 75.274258] [<0000000000766bd0>] vfs_write+0x90/0x420
[ 75.340594] [<00000000007670cc>] ksys_write+0x4c/0xe0
[ 75.406932] [<0000000000767174>] sys_write+0x14/0x40
[ 75.472126] [<0000000000406174>] linux_sparc_syscall+0x34/0x44
[ 75.548802] ---[ end trace 0000000000000000 ]---
[ 75.609503] dfa blob stream 0xfff0000008926b96 not aligned.
[ 75.682695] Kernel unaligned access at TPC[8db2a8] aa_dfa_unpack+0x6e8/0x720
Work around it by using the get_unaligned_xx() helpers.
[ Backport to 6.6.y: Use asm/unaligned.h because the target predates
linux/unaligned.h, keeping this first patch independently buildable. ]
---
This is patch 1 of 2 in the ordered 6.6.y backport series. This change addresses CVE-2026-46254. Both DFA unpackers cast blob offsets to aligned big-endian pointers even though policy blobs need not be aligned.
This needed a target-specific adjustment; I called it out in the bracketed backport note above.
The fix is already present in 6.12.y, 6.18.y, and 7.2.y, but not in 6.6.y. This fix also affects 6.1.y, which will need a separate backport; this submission contains only the 6.6.y patch.
security/apparmor/match.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
security/apparmor/match.c +8 -7
@@ -15,6 +15,7 @@#include <linux/vmalloc.h> #include <linux/err.h> #include <linux/kref.h> +#include <asm/unaligned.h> #include "include/lib.h" #include "include/match.h"
@@ -42,11 +43,11 @@ static struct table_header *unpack_table(char *blob, size_t bsize)/* loaded td_id's start at 1, subtract 1 now to avoid doing * it every time we use td_id as an index */ - th.td_id =be16_to_cpu (*(__be16 *) (blob)) -1 ; + th.td_id =get_unaligned_be16 (blob) -1 ;if (th.td_id >YYTD_ID_MAX ) goto out; - th.td_flags =be16_to_cpu (*(__be16 *) (blob +2 )); - th.td_lolen =be32_to_cpu (*(__be32 *) (blob +8 )); + th.td_flags =get_unaligned_be16 (blob +2 ); + th.td_lolen =get_unaligned_be32 (blob +8 ); blob +=sizeof (struct table_header ); if (!(th.td_flags == YYTD_DATA16 || th.td_flags == YYTD_DATA32 ||
@@ -293,14 +294,14 @@ struct aa_dfa *aa_dfa_unpack(void *blob, size_t size, int flags)if (size <sizeof (struct table_set_header )) goto fail; -if (ntohl (*(__be32 *) data) !=YYTH_MAGIC ) +if (get_unaligned_be32 (data) !=YYTH_MAGIC ) goto fail; - hsize =ntohl (*(__be32 *) (data +4 )); + hsize =get_unaligned_be32 (data +4 );if (size < hsize) goto fail; - dfa->flags =ntohs (*(__be16 *) (data +12 )); + dfa->flags =get_unaligned_be16 (data +12 );if (dfa->flags & ~(YYTH_FLAGS )) goto fail;
@@ -309,7 +310,7 @@ struct aa_dfa *aa_dfa_unpack(void *blob, size_t size, int flags)* if (dfa->flags & YYTH_FLAGS_OOB_TRANS) { * if (hsize < 16 + 4) * goto fail; -* dfa->max_oob = ntol(*(__be32 *) (data + 16)); +* dfa->max_oob = get_unaligned_be32(data + 16); * if (dfa->max <= MAX_OOB_SUPPORTED) { * pr_err("AppArmor DFA OOB greater than supported\n"); * goto fail;
Signature · 1 line
2.39.5
PATCH 2/2 apparmor: Fix & Optimize table creation from possibly unaligned memory
In reply to Artem DinaburgFrom: Helge Deller <[email protected]>
[ Upstream commit 6fc367bfd4c8886e6b1742aabbd1c0bdc310db3a ]
Source blob may come from userspace and might be unaligned. Try to optize the copying process by avoiding unaligned memory accesses.
- Added Fixes tag
- Added "Fix &" to description as this doesn't just optimize but fixes a potential unaligned memory access
---
This is patch 2 of 2 in the ordered 6.6.y backport series. This change addresses CVE-2026-45893. The userspace policy blob may be unaligned, so typed __be16 and __be32 array loads can fault. The source diff is identical to upstream.
The fix is already present in 6.12.y, 6.18.y, and 7.2.y, but not in 6.6.y. This fix also affects 6.1.y, which will need a separate backport; this submission contains only the 6.6.y patch.
security/apparmor/include/match.h | 12 +++++++----- security/apparmor/match.c | 7 +++---- 2 files changed, 10 insertions(+), 9 deletions(-)
security/apparmor/include/match.h +7 -5
@@ -102,16 +102,18 @@ struct aa_dfa {struct table_header *tables[YYTD_ID_TSIZE ]; }; -#define byte_to_byte (X ) (X) -#define UNPACK_ARRAY (TABLE ,BLOB ,LEN ,TTYPE ,BTYPE ,NTOHX ) \ do { \ typeof(LEN) __i; \ TTYPE *__t = (TTYPE *) TABLE; \ BTYPE *__b = (BTYPE *) BLOB; \ - for (__i = 0; __i < LEN; __i++) { \ - __t[__i] = NTOHX(__b[__i]); \ - } \ + BUILD_BUG_ON(sizeof(TTYPE) != sizeof(BTYPE)); \ + if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) \ + memcpy(__t, __b, (LEN) * sizeof(BTYPE)); \ + else/* copy & convert from big-endian */ \ +for (__i =0 ; __i <LEN ; __i++) { \ + __t[__i] =NTOHX (&__b[__i]); \ + } \ }while (0 ) static inline size_t table_size(size_t len, size_t el_size)
security/apparmor/match.c +3 -4
@@ -67,14 +67,13 @@ static struct table_header *unpack_table(char *blob, size_t bsize) table->td_flags = th.td_flags; table->td_lolen = th.td_lolen;if (th.td_flags ==YYTD_DATA8 ) -UNPACK_ARRAY (table->td_data, blob, th.td_lolen, - u8, u8, byte_to_byte); +memcpy (table->td_data, blob, th.td_lolen);else if (th.td_flags ==YYTD_DATA16 )UNPACK_ARRAY (table->td_data, blob, th.td_lolen, - u16, __be16, be16_to_cpu); + u16, __be16, get_unaligned_be16);else if (th.td_flags ==YYTD_DATA32 )UNPACK_ARRAY (table->td_data, blob, th.td_lolen, - u32, __be32, be32_to_cpu); + u32, __be32, get_unaligned_be32);else goto fail;/* if table was vmalloced make sure the page tables are synced
Signature · 1 line
2.39.5
[email protected]
AI reviewRe: [PATCH 6.6.y 2/2] apparmor: Fix & Optimize table creation from possibly unaligned memory
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 10 lines
From: Helge Deller <[email protected]>
[ Upstream commit
6fc367bfd4c8886e6b1742aabbd1c0bdc310db3a]Source blob may come from userspace and might be unaligned. Try to optize the copying process by avoiding unaligned memory accesses.
- Added Fixes tag
- Added "Fix &" to description as this doesn't just optimize but fixes a potential unaligned memory access
Quoted 6 lines
Fixes e6e8bf418850d ("apparmor: fix restricted endian type warnings for dfa unpack")Signed-off-by Helge Deller <[email protected]>[jj: remove duplicate word "convert" in comment trigger checkpatch warning]Signed-off-by John Johansen <[email protected]>Assisted-by LLMSigned-off-by Artem Dinaburg <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
[email protected]
AI reviewRe: [PATCH 6.6.y 1/2] AppArmor: Allow apparmor to handle unaligned dfa tables
In reply to Artem DinaburgSashiko has reviewed this patch and found no issues. It looks great!
Quoted 15 lines
From: Helge Deller <[email protected]>
[ Upstream commit
64802f731214a51dfe3c6c27636b3ddafd003eb0]The dfa tables can originate from kernel or userspace and 8-byte alignment isn't always guaranteed and as such may trigger unaligned memory accesses on various architectures. Resulting in the following
[ 73.901376] WARNING: CPU: 0 PID: 341 at
security/apparmor/match.c:316aa_dfa_unpack+0x6cc/0x720
[ 74.015867] Modules linked in:binfmt_miscevdev flash sg drmdrm_panel_orientation_quirksbacklighti2c_coreconfigfs nfnetlink autofs4 ext4 crc16 mbcache jbd2hid_genericusbhidsr_modhid cdromsd_modata_genericohci_pciehci_pciehci_hcdohci_hcdpata_alilibata sym53c8xxscsi_transport_spitg3scsi_modusbcore libphyscsi_commonmdio_bususb_common
[ 74.428977] CPU: 0 UID: 0 PID: 341 Comm:apparmor_parserNot tainted 6.18.0-rc6+ #9 NONE
[ 74.536543] Call Trace:
[ 74.568561] [<0000000000434c24>]dump_stack+0x8/0x18
[ 74.633757] [<0000000000476438>]__warn+0xd8/0x100
Quoted 6 lines
[ ... ]Signed-off-by Helge Deller <[email protected]>Signed-off-by John Johansen <[email protected]>Assisted-by LLMSigned-off-by Artem Dinaburg <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 1 line
Could you please consider this series for 6.6.y?
Queued the series for 6.6, thanks.
Signature · 2 lines
Thanks, Sasha