Skip to content

Commit a194c33

Browse files
nickdesaulnierswilldeacon
authored andcommitted
arm64: acpi: fix UBSAN warning
Will reported a UBSAN warning: UBSAN: null-ptr-deref in arch/arm64/kernel/smp.c:596:6 member access within null pointer of type 'struct acpi_madt_generic_interrupt' CPU: 0 PID: 0 Comm: swapper Not tainted 5.7.0-rc6-00124-g96bc42ff0a82 #1 Call trace: dump_backtrace+0x0/0x384 show_stack+0x28/0x38 dump_stack+0xec/0x174 handle_null_ptr_deref+0x134/0x174 __ubsan_handle_type_mismatch_v1+0x84/0xa4 acpi_parse_gic_cpu_interface+0x60/0xe8 acpi_parse_entries_array+0x288/0x498 acpi_table_parse_entries_array+0x178/0x1b4 acpi_table_parse_madt+0xa4/0x110 acpi_parse_and_init_cpus+0x38/0x100 smp_init_cpus+0x74/0x258 setup_arch+0x350/0x3ec start_kernel+0x98/0x6f4 This is from the use of the ACPI_OFFSET in arch/arm64/include/asm/acpi.h. Replace its use with offsetof from include/linux/stddef.h which should implement the same logic using __builtin_offsetof, so that UBSAN wont warn. Reported-by: Will Deacon <[email protected]> Suggested-by: Ard Biesheuvel <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]> Reviewed-by: Jeremy Linton <[email protected]> Acked-by: Lorenzo Pieralisi <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/lkml/20200521100952.GA5360@willie-the-truck/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 625412c commit a194c33

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

arch/arm64/include/asm/acpi.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/efi.h>
1313
#include <linux/memblock.h>
1414
#include <linux/psci.h>
15+
#include <linux/stddef.h>
1516

1617
#include <asm/cputype.h>
1718
#include <asm/io.h>
@@ -31,14 +32,14 @@
3132
* is therefore used to delimit the MADT GICC structure minimum length
3233
* appropriately.
3334
*/
34-
#define ACPI_MADT_GICC_MIN_LENGTH ACPI_OFFSET( \
35+
#define ACPI_MADT_GICC_MIN_LENGTH offsetof( \
3536
struct acpi_madt_generic_interrupt, efficiency_class)
3637

3738
#define BAD_MADT_GICC_ENTRY(entry, end) \
3839
(!(entry) || (entry)->header.length < ACPI_MADT_GICC_MIN_LENGTH || \
3940
(unsigned long)(entry) + (entry)->header.length > (end))
4041

41-
#define ACPI_MADT_GICC_SPE (ACPI_OFFSET(struct acpi_madt_generic_interrupt, \
42+
#define ACPI_MADT_GICC_SPE (offsetof(struct acpi_madt_generic_interrupt, \
4243
spe_interrupt) + sizeof(u16))
4344

4445
/* Basic configuration for ACPI */

0 commit comments

Comments
 (0)