Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

apparmor: use get_unaligned() only for multi-byte words

Using get_unaligned() on a u8 pointer is pointless, and will
result in a compiler warning after a planned cleanup:

In file included from arch/x86/include/generated/asm/unaligned.h:1,
from security/apparmor/policy_unpack.c:16:
security/apparmor/policy_unpack.c: In function 'unpack_u8':
include/asm-generic/unaligned.h:13:15: error: 'packed' attribute ignored for field of type 'u8' {aka 'unsigned char'} [-Werror=attributes]
13 | const struct { type x __packed; } *__pptr = (typeof(__pptr))(ptr); \
| ^

Simply dereference this pointer directly.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: John Johansen <john.johansen@canonical.com>

+1 -1
+1 -1
security/apparmor/policy_unpack.c
··· 304 304 if (!inbounds(e, sizeof(u8))) 305 305 goto fail; 306 306 if (data) 307 - *data = get_unaligned((u8 *)e->pos); 307 + *data = *((u8 *)e->pos); 308 308 e->pos += sizeof(u8); 309 309 return true; 310 310 }