arm64/acpi: NULL dereference reports from UBSAN at boot
Subsystems (4)
Will Deacon
maintainerHi folks,
I just tried booting the arm64 for-kernelci branch under QEMU (version 4.2.50 (v4.2.0-779-g4354edb6dcc7)) with UBSAN enabled, and I see a couple of NULL pointer dereferences reported at boot. I think they're both GIC related (log below). I don't see a panic with UBSAN disabled, so something's fishy here.
Please can you take a look when you get a chance? I haven't had time to see if this is a regression or not, but I don't think it's particularly serious as I have all sorts of horrible stuff enabled in my .config, since I'm trying to chase down another bug:
(on top of defconfig)
CONFIG_FAIL_PAGE_ALLOC may be to blame.
Cheers,
Will
--->8
[ 0.000000][ T0] ================================================================================ [ 0.000000][ T0] UBSAN: null-ptr-deref in drivers/acpi/acpica/tbfadt.c:459:37 [ 0.000000][ T0] member access within null pointer of type 'struct acpi_table_fadt' [ 0.000000][ T0] CPU: 0 PID: 0 Comm: swapper Not tainted 5.7.0-rc6-00124-g96bc42ff0a82 #1 [ 0.000000][ T0] Call trace: [ 0.000000][ T0] dump_backtrace+0x0/0x384 [ 0.000000][ T0] show_stack+0x28/0x38 [ 0.000000][ T0] dump_stack+0xec/0x174 [ 0.000000][ T0] handle_null_ptr_deref+0x134/0x174 [ 0.000000][ T0] __ubsan_handle_type_mismatch_v1+0x84/0xa4 [ 0.000000][ T0] acpi_tb_create_local_fadt+0x1d4/0x1418 [ 0.000000][ T0] acpi_tb_parse_fadt+0x108/0x4b8 [ 0.000000][ T0] acpi_tb_parse_root_table+0x380/0x578 [ 0.000000][ T0] acpi_initialize_tables+0x140/0x194 [ 0.000000][ T0] acpi_table_init+0x90/0xcc [ 0.000000][ T0] acpi_boot_table_init+0xfc/0x1c8 [ 0.000000][ T0] setup_arch+0x2b4/0x3ec [ 0.000000][ T0] start_kernel+0x98/0x6f4 [ 0.000000][ T0] ================================================================================
[ 0.000000][ T0] ================================================================================ [ 0.000000][ T0] UBSAN: null-ptr-deref in arch/arm64/kernel/smp.c:596:6 [ 0.000000][ T0] member access within null pointer of type 'struct acpi_madt_generic_interrupt' [ 0.000000][ T0] CPU: 0 PID: 0 Comm: swapper Not tainted 5.7.0-rc6-00124-g96bc42ff0a82 #1 [ 0.000000][ T0] Call trace: [ 0.000000][ T0] dump_backtrace+0x0/0x384 [ 0.000000][ T0] show_stack+0x28/0x38 [ 0.000000][ T0] dump_stack+0xec/0x174 [ 0.000000][ T0] handle_null_ptr_deref+0x134/0x174 [ 0.000000][ T0] __ubsan_handle_type_mismatch_v1+0x84/0xa4 [ 0.000000][ T0] acpi_parse_gic_cpu_interface+0x60/0xe8 [ 0.000000][ T0] acpi_parse_entries_array+0x288/0x498 [ 0.000000][ T0] acpi_table_parse_entries_array+0x178/0x1b4 [ 0.000000][ T0] acpi_table_parse_madt+0xa4/0x110 [ 0.000000][ T0] acpi_parse_and_init_cpus+0x38/0x100 [ 0.000000][ T0] smp_init_cpus+0x74/0x258 [ 0.000000][ T0] setup_arch+0x350/0x3ec [ 0.000000][ T0] start_kernel+0x98/0x6f4 [ 0.000000][ T0] ================================================================================
Quoted 7 lines · Will Deacon
Hi folks,
I just tried booting the arm64 for-kernelci branch under QEMU (version 4.2.50 (v4.2.0-779-g4354edb6dcc7)) with UBSAN enabled, and I see a couple of NULL pointer dereferences reported at boot. I think they're both GIC related (log below). I don't see a panic with UBSAN disabled, so something's fishy here.
May I ask you the QEMU command line please - just to make sure I can replicate it.
Quoted 10 lines
Please can you take a look when you get a chance? I haven't had time to see if this is a regression or not, but I don't think it's particularly serious as I have all sorts of horrible stuff enabled in my .config, since I'm trying to chase down another bug:
(on top of defconfig)
CONFIG_FAIL_PAGE_ALLOCmay be to blame.
Not sure about that, they are both quite cryptic, I wonder if UBSAN is not tricked by the ACPI_OFFSET macro - need to debug it further to understand what's going on here.
Thanks,
Lorenzo
Quoted 45 lines
Cheers,
Will
--->8
[ 0.000000][ T0] ================================================================================ [ 0.000000][ T0] UBSAN: null-ptr-deref in drivers/acpi/acpica/tbfadt.c:459:37 [ 0.000000][ T0] member access within null pointer of type 'struct acpi_table_fadt' [ 0.000000][ T0] CPU: 0 PID: 0 Comm: swapper Not tainted 5.7.0-rc6-00124-g96bc42ff0a82 #1 [ 0.000000][ T0] Call trace: [ 0.000000][ T0] dump_backtrace+0x0/0x384 [ 0.000000][ T0] show_stack+0x28/0x38 [ 0.000000][ T0] dump_stack+0xec/0x174 [ 0.000000][ T0] handle_null_ptr_deref+0x134/0x174 [ 0.000000][ T0] __ubsan_handle_type_mismatch_v1+0x84/0xa4 [ 0.000000][ T0] acpi_tb_create_local_fadt+0x1d4/0x1418 [ 0.000000][ T0] acpi_tb_parse_fadt+0x108/0x4b8 [ 0.000000][ T0] acpi_tb_parse_root_table+0x380/0x578 [ 0.000000][ T0] acpi_initialize_tables+0x140/0x194 [ 0.000000][ T0] acpi_table_init+0x90/0xcc [ 0.000000][ T0] acpi_boot_table_init+0xfc/0x1c8 [ 0.000000][ T0] setup_arch+0x2b4/0x3ec [ 0.000000][ T0] start_kernel+0x98/0x6f4 [ 0.000000][ T0] ================================================================================[ 0.000000][ T0] ================================================================================ [ 0.000000][ T0] UBSAN: null-ptr-deref in arch/arm64/kernel/smp.c:596:6 [ 0.000000][ T0] member access within null pointer of type 'struct acpi_madt_generic_interrupt' [ 0.000000][ T0] CPU: 0 PID: 0 Comm: swapper Not tainted 5.7.0-rc6-00124-g96bc42ff0a82 #1 [ 0.000000][ T0] Call trace: [ 0.000000][ T0] dump_backtrace+0x0/0x384 [ 0.000000][ T0] show_stack+0x28/0x38 [ 0.000000][ T0] dump_stack+0xec/0x174 [ 0.000000][ T0] handle_null_ptr_deref+0x134/0x174 [ 0.000000][ T0] __ubsan_handle_type_mismatch_v1+0x84/0xa4 [ 0.000000][ T0] acpi_parse_gic_cpu_interface+0x60/0xe8 [ 0.000000][ T0] acpi_parse_entries_array+0x288/0x498 [ 0.000000][ T0] acpi_table_parse_entries_array+0x178/0x1b4 [ 0.000000][ T0] acpi_table_parse_madt+0xa4/0x110 [ 0.000000][ T0] acpi_parse_and_init_cpus+0x38/0x100 [ 0.000000][ T0] smp_init_cpus+0x74/0x258 [ 0.000000][ T0] setup_arch+0x350/0x3ec [ 0.000000][ T0] start_kernel+0x98/0x6f4 [ 0.000000][ T0] ================================================================================
Will Deacon
maintainerHi Lorenzo, Hanjun, [+Nick]
Quoted 11 lines · Lorenzo Pieralisi
Quoted 7 lines · Will Deacon
Hi folks,
I just tried booting the arm64 for-kernelci branch under QEMU (version 4.2.50 (v4.2.0-779-g4354edb6dcc7)) with UBSAN enabled, and I see a couple of NULL pointer dereferences reported at boot. I think they're both GIC related (log below). I don't see a panic with UBSAN disabled, so something's fishy here.
May I ask you the QEMU command line please - just to make sure I can replicate it.
As it turns out, I'm only able to reproduce this when building with Clang, but I don't know whether that's because GCC is missing something of Clang is signalling a false positive. You also don't need all of those whacky fuzzing options enabled.
Anyway, to reproduce:
$ git checkout for-next/kernelci $ make ARCH=arm64 CC=clang CROSS_COMPILE=aarch64-linux-gnu- defconfig <then do a menuconfig and enable UBSAN> $ make ARCH=arm64 CC=clang CROSS_COMPILE=aarch64-linux-gnu- Image
I throw that at QEMU using:
qemu-system-aarch64 -M virt -machine virtualization=true \ -machine virt,gic-version=3 \ -cpu max,sve=off -smp 2 -m 4096 \ -drive if=pflash,format=raw,file=efi.img,readonly \ -drive if=pflash,format=raw,file=varstore.img \ -drive if=virtio,format=raw,file=disk.img \ -device virtio-scsi-pci,id=scsi0 \ -device virtio-rng-pci \ -device virtio-net-pci,netdev=net0 \ -netdev user,id=net0,hostfwd=tcp::8222-:22 \ -nographic \ -kernel ~/work/linux/arch/arm64/boot/Image \ -append "earlycon root=/dev/vda2"
I built QEMU a while ago according to:
https://mirrors.edge.kernel.org/pub/linux/kernel/people/will/docs/qemu/qemu-arm64-howto.html
and its version 4.2.50 (v4.2.0-779-g4354edb6dcc7).
My clang is version 11.0.1.
Will
Quoted 43 lines · Will Deacon
Hi Lorenzo, Hanjun, [+Nick]
Quoted 11 lines · Lorenzo Pieralisi
Quoted 7 lines · Will Deacon
Hi folks,
I just tried booting the arm64 for-kernelci branch under QEMU (version 4.2.50 (v4.2.0-779-g4354edb6dcc7)) with UBSAN enabled, and I see a couple of NULL pointer dereferences reported at boot. I think they're both GIC related (log below). I don't see a panic with UBSAN disabled, so something's fishy here.
May I ask you the QEMU command line please - just to make sure I can replicate it.
As it turns out, I'm only able to reproduce this when building with Clang, but I don't know whether that's because GCC is missing something of Clang is signalling a false positive. You also don't need all of those whacky fuzzing options enabled.
Anyway, to reproduce:
$ git checkout for-next/kernelci $ make ARCH=arm64 CC=clang CROSS_COMPILE=aarch64-linux-gnu- defconfig <then do a menuconfig and enable UBSAN> $ make ARCH=arm64 CC=clang CROSS_COMPILE=aarch64-linux-gnu- ImageI throw that at QEMU using:
qemu-system-aarch64 -M virt -machine virtualization=true \ -machine virt,gic-version=3 \ -cpu max,sve=off -smp 2 -m 4096 \ -drive if=pflash,format=raw,file=efi.img,readonly \ -drive if=pflash,format=raw,file=varstore.img \ -drive if=virtio,format=raw,file=disk.img \ -device virtio-scsi-pci,id=scsi0 \ -device virtio-rng-pci \ -device virtio-net-pci,netdev=net0 \ -netdev user,id=net0,hostfwd=tcp::8222-:22 \ -nographic \ -kernel ~/work/linux/arch/arm64/boot/Image \ -append "earlycon root=/dev/vda2"
Quoted 7 lines
I built QEMU a while ago according to:
https://mirrors.edge.kernel.org/pub/linux/kernel/people/will/docs/qemu/qemu-arm64-howto.html
and its version 4.2.50 (v4.2.0-779-g4354edb6dcc7).
My clang is version 11.0.1.
Thanks a lot Will.
I *think* I was right - it is the ACPI_OFFSET() macro:
#define ACPI_OFFSET(d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0)
that triggers the warnings (I suspected it because at least in one of the warnings I could not see any dereference of any dynamically allocated data).
Now on what to do with it - thoughts welcome.
Lorenzo
Will Deacon
maintainerQuoted 54 lines · Lorenzo Pieralisi
Quoted 43 lines · Will Deacon
Hi Lorenzo, Hanjun, [+Nick]
Quoted 11 lines · Lorenzo Pieralisi
Quoted 7 lines · Will Deacon
Hi folks,
I just tried booting the arm64 for-kernelci branch under QEMU (version 4.2.50 (v4.2.0-779-g4354edb6dcc7)) with UBSAN enabled, and I see a couple of NULL pointer dereferences reported at boot. I think they're both GIC related (log below). I don't see a panic with UBSAN disabled, so something's fishy here.
May I ask you the QEMU command line please - just to make sure I can replicate it.
As it turns out, I'm only able to reproduce this when building with Clang, but I don't know whether that's because GCC is missing something of Clang is signalling a false positive. You also don't need all of those whacky fuzzing options enabled.
Anyway, to reproduce:
$ git checkout for-next/kernelci $ make ARCH=arm64 CC=clang CROSS_COMPILE=aarch64-linux-gnu- defconfig <then do a menuconfig and enable UBSAN> $ make ARCH=arm64 CC=clang CROSS_COMPILE=aarch64-linux-gnu- ImageI throw that at QEMU using:
qemu-system-aarch64 -M virt -machine virtualization=true \ -machine virt,gic-version=3 \ -cpu max,sve=off -smp 2 -m 4096 \ -drive if=pflash,format=raw,file=efi.img,readonly \ -drive if=pflash,format=raw,file=varstore.img \ -drive if=virtio,format=raw,file=disk.img \ -device virtio-scsi-pci,id=scsi0 \ -device virtio-rng-pci \ -device virtio-net-pci,netdev=net0 \ -netdev user,id=net0,hostfwd=tcp::8222-:22 \ -nographic \ -kernel ~/work/linux/arch/arm64/boot/Image \ -append "earlycon root=/dev/vda2"Quoted 7 lines
I built QEMU a while ago according to:
https://mirrors.edge.kernel.org/pub/linux/kernel/people/will/docs/qemu/qemu-arm64-howto.html
and its version 4.2.50 (v4.2.0-779-g4354edb6dcc7).
My clang is version 11.0.1.
Thanks a lot Will.
Quoted 7 lines
I *think* I was right - it is the
ACPI_OFFSET()macro:#define
ACPI_OFFSET(d, f)ACPI_PTR_DIFF(&(((d *) 0)->f), (void *) 0)that triggers the warnings (I suspected it because at least in one of the warnings I could not see any dereference of any dynamically allocated data).
Cheers, Lorenzo.
Quoted 1 line
Now on what to do with it - thoughts welcome.
Nick -- any idea what to do about the above? The '#define' pasted by Lorenzo is causing a couple of spurious UBSAN splats when compiling with clang 11.
Cheers,
Will
Quoted 64 lines · Will Deacon
Quoted 54 lines · Lorenzo Pieralisi
Quoted 43 lines · Will Deacon
Hi Lorenzo, Hanjun, [+Nick]
Quoted 11 lines · Lorenzo Pieralisi
Quoted 7 lines · Will Deacon
Hi folks,
I just tried booting the arm64 for-kernelci branch under QEMU (version 4.2.50 (v4.2.0-779-g4354edb6dcc7)) with UBSAN enabled, and I see a couple of NULL pointer dereferences reported at boot. I think they're both GIC related (log below). I don't see a panic with UBSAN disabled, so something's fishy here.
May I ask you the QEMU command line please - just to make sure I can replicate it.
As it turns out, I'm only able to reproduce this when building with Clang, but I don't know whether that's because GCC is missing something of Clang is signalling a false positive. You also don't need all of those whacky fuzzing options enabled.
Anyway, to reproduce:
$ git checkout for-next/kernelci $ make ARCH=arm64 CC=clang CROSS_COMPILE=aarch64-linux-gnu- defconfig <then do a menuconfig and enable UBSAN> $ make ARCH=arm64 CC=clang CROSS_COMPILE=aarch64-linux-gnu- ImageI throw that at QEMU using:
qemu-system-aarch64 -M virt -machine virtualization=true \ -machine virt,gic-version=3 \ -cpu max,sve=off -smp 2 -m 4096 \ -drive if=pflash,format=raw,file=efi.img,readonly \ -drive if=pflash,format=raw,file=varstore.img \ -drive if=virtio,format=raw,file=disk.img \ -device virtio-scsi-pci,id=scsi0 \ -device virtio-rng-pci \ -device virtio-net-pci,netdev=net0 \ -netdev user,id=net0,hostfwd=tcp::8222-:22 \ -nographic \ -kernel ~/work/linux/arch/arm64/boot/Image \ -append "earlycon root=/dev/vda2"Quoted 7 lines
I built QEMU a while ago according to:
https://mirrors.edge.kernel.org/pub/linux/kernel/people/will/docs/qemu/qemu-arm64-howto.html
and its version 4.2.50 (v4.2.0-779-g4354edb6dcc7).
My clang is version 11.0.1.
Thanks a lot Will.
Quoted 7 lines
I *think* I was right - it is the
ACPI_OFFSET()macro:#define
ACPI_OFFSET(d, f)ACPI_PTR_DIFF(&(((d *) 0)->f), (void *) 0)that triggers the warnings (I suspected it because at least in one of the warnings I could not see any dereference of any dynamically allocated data).
Quoted 7 lines
Cheers, Lorenzo.
Quoted 1 line
Now on what to do with it - thoughts welcome.
Nick -- any idea what to do about the above? The '#define' pasted by Lorenzo is causing a couple of spurious UBSAN splats when compiling with clang 11.
If there's undefined behavior from that macro soup, we should be able to reproduce it outside of the kernel and regardless of target architecture, right? The macros aren't too much to throw into a file:
```foo.c
#define acpi_uintptr_t void *
#define ACPI_CAST_PTR(t, p) ((t *) (acpi_uintptr_t) (p))
typedef unsigned char u8;
typedef unsigned long u64;
typedef u64 acpi_size;
#define ACPI_PTR_DIFF(a, b) ((acpi_size) (ACPI_CAST_PTR (u8, (a)) -
ACPI_CAST_PTR (u8, (b))))
#define ACPI_OFFSET(d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0)
struct foo {
unsigned char bar;
int baz;
};
int main() {
return ACPI_OFFSET(struct foo, baz);
}
```
I think looks right. If we run that through -E, and clean that up
further, we get:
```bar.c
typedef unsigned char u8;
typedef unsigned long u64;
struct foo {
unsigned char bar;
int baz;
};
int main() {
return ((u64) (((u8 *) (void *) ((&(((struct foo *) 0)->baz)))) - ((u8
*) (void *) (((void *) 0)))));
}
```I may be miscounting my parentheses, but how do you take the address of type->member? What does that even mean?
+ some more sanitizer folks and Ard for ACPI.
anyways, running foo.c through a compiler:
$ clang -O2 foo.c -fsanitize=undefined $ ./a.out foo.c:15:12: runtime error: member access within null pointer of type 'struct foo' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior foo.c:15:12 in
(msg looks truncated, wtf)
Anyways, it looks like the address of member from NULL subexpression looks problematic. I wonder if offsetof can be used here?
#define ACPI_OFFSET(d, f) ACPI_PTR_DIFF (offsetof(d, f), (void *) 0)
Seems to work in my basic test case. Untested in the kernel.
IIUC, ACPI_OFFSET is trying to calculate the difference between the offset of a member of a struct and 0? Isn't that the tautology x - 0 == x?
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 130 lines · Nick Desaulniers
Quoted 64 lines · Will Deacon
Quoted 54 lines · Lorenzo Pieralisi
Quoted 43 lines · Will Deacon
Hi Lorenzo, Hanjun, [+Nick]
Quoted 11 lines · Lorenzo Pieralisi
Quoted 7 lines · Will Deacon
Hi folks,
I just tried booting the arm64 for-kernelci branch under QEMU (version 4.2.50 (v4.2.0-779-g4354edb6dcc7)) with UBSAN enabled, and I see a couple of NULL pointer dereferences reported at boot. I think they're both GIC related (log below). I don't see a panic with UBSAN disabled, so something's fishy here.
May I ask you the QEMU command line please - just to make sure I can replicate it.
As it turns out, I'm only able to reproduce this when building with Clang, but I don't know whether that's because GCC is missing something of Clang is signalling a false positive. You also don't need all of those whacky fuzzing options enabled.
Anyway, to reproduce:
$ git checkout for-next/kernelci $ make ARCH=arm64 CC=clang CROSS_COMPILE=aarch64-linux-gnu- defconfig <then do a menuconfig and enable UBSAN> $ make ARCH=arm64 CC=clang CROSS_COMPILE=aarch64-linux-gnu- ImageI throw that at QEMU using:
qemu-system-aarch64 -M virt -machine virtualization=true \ -machine virt,gic-version=3 \ -cpu max,sve=off -smp 2 -m 4096 \ -drive if=pflash,format=raw,file=efi.img,readonly \ -drive if=pflash,format=raw,file=varstore.img \ -drive if=virtio,format=raw,file=disk.img \ -device virtio-scsi-pci,id=scsi0 \ -device virtio-rng-pci \ -device virtio-net-pci,netdev=net0 \ -netdev user,id=net0,hostfwd=tcp::8222-:22 \ -nographic \ -kernel ~/work/linux/arch/arm64/boot/Image \ -append "earlycon root=/dev/vda2"Quoted 7 lines
I built QEMU a while ago according to:
https://mirrors.edge.kernel.org/pub/linux/kernel/people/will/docs/qemu/qemu-arm64-howto.html
and its version 4.2.50 (v4.2.0-779-g4354edb6dcc7).
My clang is version 11.0.1.
Thanks a lot Will.
Quoted 7 lines
I *think* I was right - it is the
ACPI_OFFSET()macro:#define
ACPI_OFFSET(d, f)ACPI_PTR_DIFF(&(((d *) 0)->f), (void *) 0)that triggers the warnings (I suspected it because at least in one of the warnings I could not see any dereference of any dynamically allocated data).
Quoted 7 lines
Cheers, Lorenzo.
Quoted 1 line
Now on what to do with it - thoughts welcome.
Nick -- any idea what to do about the above? The '#define' pasted by Lorenzo is causing a couple of spurious UBSAN splats when compiling with clang 11.
If there's undefined behavior from that macro soup, we should be able to reproduce it outside of the kernel and regardless of target architecture, right? The macros aren't too much to throw into a file:
```foo.c #define acpi_uintptr_t void * #define ACPI_CAST_PTR(t, p) ((t *) (acpi_uintptr_t) (p)) typedef unsigned char u8; typedef unsigned long u64; typedef u64 acpi_size; #define ACPI_PTR_DIFF(a, b) ((acpi_size) (ACPI_CAST_PTR (u8, (a)) - ACPI_CAST_PTR (u8, (b)))) #define ACPI_OFFSET(d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0) struct foo { unsigned char bar; int baz; }; int main() { return ACPI_OFFSET(struct foo, baz); } ``` I think looks right. If we run that through -E, and clean that up further, we get: ```bar.c typedef unsigned char u8; typedef unsigned long u64; struct foo { unsigned char bar; int baz; }; int main() { return ((u64) (((u8 *) (void *) ((&(((struct foo *) 0)->baz)))) - ((u8 *) (void *) (((void *) 0))))); } ```I may be miscounting my parentheses, but how do you take the address of
type->member? What does that even mean?+ some more sanitizer folks and Ard for ACPI.
anyways, running
foo.cthrough a compiler:$ clang -O2 foo.c -fsanitize=undefined $ ./a.out foo.c:15:12: runtime error: member access within null pointer of type 'struct foo' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior foo.c:15:12 in(msg looks truncated, wtf)
Anyways, it looks like the address of member from NULL subexpression looks problematic. I wonder if offsetof can be used here?
Quoted 7 lines
#define
ACPI_OFFSET(d, f)ACPI_PTR_DIFF(offsetof(d, f), (void *) 0)Seems to work in my basic test case. Untested in the kernel.
IIUC,
ACPI_OFFSETis trying to calculate the difference between the offset of a member of a struct and 0? Isn't that the tautologyx - 0 == x?
No. ACPI_OFFSET() is just a poor person's version of offsetof().
(Note that it calculates the difference between &(((d *) 0)->f) and (void *)0x0, so the 0x0 term is there on both sides)
Quoted 10 lines · Ard Biesheuvel
Quoted 8 lines · Nick Desaulniers
Anyways, it looks like the address of member from NULL subexpression looks problematic. I wonder if offsetof can be used here?
#define
ACPI_OFFSET(d, f)ACPI_PTR_DIFF(offsetof(d, f), (void *) 0)Seems to work in my basic test case. Untested in the kernel.
Quoted 8 lines
Quoted 3 lines
IIUC,
ACPI_OFFSETis trying to calculate the difference between the offset of a member of a struct and 0? Isn't that the tautologyx - 0 == x?No.
ACPI_OFFSET()is just a poor person's version ofoffsetof().(Note that it calculates the difference between &(((d *) 0)->f) and (void *)0x0, so the
0x0term is there on both sides)
Got it. So we're trying to avoid including stddef.h? Can __builtin_offsetof be used here?
#define ACPI_OFFSET(d, f) ACPI_PTR_DIFF (__builtin_offsetof(d, f), (void *) 0) The oldest version of GCC in godbolt.org (4.1) supports this builtin.
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 16 lines · Nick Desaulniers
Quoted 14 lines · Ard Biesheuvel
Quoted 11 lines · Nick Desaulniers
Anyways, it looks like the address of member from NULL subexpression looks problematic. I wonder if offsetof can be used here?
#define
ACPI_OFFSET(d, f)ACPI_PTR_DIFF(offsetof(d, f), (void *) 0)Seems to work in my basic test case. Untested in the kernel.
IIUC,
ACPI_OFFSETis trying to calculate the difference between the offset of a member of a struct and 0? Isn't that the tautologyx - 0 == x?
Quoted 8 lines
Quoted 4 lines
No.
ACPI_OFFSET()is just a poor person's version ofoffsetof().(Note that it calculates the difference between &(((d *) 0)->f) and (void *)0x0, so the
0x0term is there on both sides)Got it. So we're trying to avoid including
stddef.h? Can__builtin_offsetofbe used here?
#defineACPI_OFFSET(d, f)ACPI_PTR_DIFF(__builtin_offsetof(d, f), (void *) 0)
Drop the 0x0:
#define ACPI_OFFSET __builtin_offsetof
should be all we need.
Quoted 1 line
The oldest version of GCC in godbolt.org (4.1) supports this builtin.
Yeah I think that should be fine.
Alternatively, using any arbitrary address other than 0x0 on both sides should work as well to get rid of the undefined behavior (assuming the use of NULL pointers is what is causing it), but I don't see why we need to invent our own helper here.
BTW some other macros looks dodgy as well. 761f0b82393353507930b6721ae4311a9df2ca36 provides a nice set of candidates to go and clean up.
PATCH 1/1 ACPICA: fix UBSAN warning using __builtin_offsetof
Will reported UBSAN warnings:
UBSAN: null-ptr-deref in drivers/acpi/acpica/tbfadt.c:459:37 UBSAN: null-ptr-deref in arch/arm64/kernel/smp.c:596:6
Looks like the emulated offsetof macro ACPI_OFFSET is causing these. We can avoid this by using the compiler builtin, __builtin_offsetof.
The non-kernel runtime of UBSAN would print:
runtime error: member access within null pointer of type for this macro.
--- include/acpi/actypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/acpi/actypes.h +1 -1
@@ -508,7 +508,7 @@ typedef u64 acpi_integer;#define ACPI_TO_POINTER (i) ACPI_CAST_PTR (void, (acpi_size) (i))#define ACPI_TO_INTEGER (p) ACPI_PTR_DIFF (p, (void *) 0) -#define ACPI_OFFSET (d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0) +#define ACPI_OFFSET (d, f) __builtin_offsetof(d, f)#define ACPI_PHYSADDR_TO_PTR (i) ACPI_TO_POINTER(i)#define ACPI_PTR_TO_PHYSADDR (i) ACPI_TO_INTEGER(i)
Signature · 1 line
2.27.0.rc2.251.g90737beb825-goog
Re: [PATCH] ACPICA: fix UBSAN warning using __builtin_offsetof
Quoted 7 lines · Nick Desaulniers
Will reported UBSAN warnings:
UBSAN: null-ptr-deref in drivers/acpi/acpica/tbfadt.c:459:37 UBSAN: null-ptr-deref in arch/arm64/kernel/smp.c:596:6Looks like the emulated offsetof macro
ACPI_OFFSETis causing these. We can avoid this by using the compiler builtin,__builtin_offsetof.
Would it be better to s/ACPI_OFFSET/offsetof/g the existing users of this macro and remove it? It looks like offsetof is already being used pervasively in the kernel, and its definition comes from <linux/stddef.h>.
Peter
Peter
Quoted 29 lines
The non-kernel runtime of UBSAN would print:
runtime error: member access within null pointer of type for this macro.Reported-by Will Deacon <[email protected]>Suggested-by Ard Biesheuvel <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>--- include/acpi/actypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/acpi/actypes.h +1
-2@@ -508,7 +508,7 @@ typedef u64 acpi_integer;#define ACPI_TO_POINTER (i) ACPI_CAST_PTR (void, (acpi_size) (i))#define ACPI_TO_INTEGER (p) ACPI_PTR_DIFF (p, (void *) 0) -#define ACPI_OFFSET (d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0) +#define ACPI_OFFSET (d, f) __builtin_offsetof(d, f)#define ACPI_PHYSADDR_TO_PTR (i) ACPI_TO_POINTER(i)#define ACPI_PTR_TO_PHYSADDR (i) ACPI_TO_INTEGER(i) --2.27.0.rc2.251.g90737beb825-goog
Re: [PATCH] ACPICA: fix UBSAN warning using __builtin_offsetof
Quoted 7 lines · Peter Collingbourne
Quoted 5 lines · Nick Desaulniers
Will reported UBSAN warnings:
UBSAN: null-ptr-deref in drivers/acpi/acpica/tbfadt.c:459:37 UBSAN: null-ptr-deref in arch/arm64/kernel/smp.c:596:6
Quoted 7 lines
Quoted 2 lines
Looks like the emulated offsetof macro
ACPI_OFFSETis causing these. We can avoid this by using the compiler builtin,__builtin_offsetof.Would it be better to s/ACPI_OFFSET/offsetof/g the existing users of this macro and remove it? It looks like offsetof is already being used pervasively in the kernel, and its definition comes from <
linux/stddef.h>.
I count only 9 uses in the tree, so not too bad a yak shave. Good idea; I'll send tomorrow short of any other feedback. I still think we want the builtin, since we don't want to include stddef.h in the kernel, I think.
Signature · 2 lines
Thanks, ~Nick Desaulniers
RE: [PATCH] ACPICA: fix UBSAN warning using __builtin_offsetof
In reply to Nick DesaulniersQuoted 17 lines
-----Original Message-----
From: Nick Desaulniers <[email protected]>
Sent: Monday, June 1, 2020 4:18 PM
To: Moore, Robert <[email protected]>; Kaneda, Erik <[email protected]>; Wysocki, Rafael J <[email protected]>; Len Brown <[email protected]>
Cc: Ard Biesheuvel <[email protected]>; [email protected]; [email protected]; [email protected]; linux-arm- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH] ACPICA: fix UBSAN warning using__builtin_offsetof
Hi,
Quoted 6 lines
Will reported UBSAN warnings:
UBSAN: null-ptr-deref in drivers/acpi/acpica/tbfadt.c:459:37 UBSAN: null-ptr-deref in arch/arm64/kernel/smp.c:596:6Looks like the emulated offsetof macro
ACPI_OFFSETis causing these. We can avoid this by using the compiler builtin,__builtin_offsetof.
I'll take a look at this tomorrow
Quoted 3 lines
The non-kernel runtime of UBSAN would print:
runtime error: member access within null pointer of type for this macro.
actypes.h is owned by ACPICA so we typically do not allow compiler-specific extensions because the code is intended to be compiled using the C99 standard without compiler extensions. We could allow this sort of thing in a Linux-specific header file like include/acpi/platform/aclinux.h but I'll take a look at the error as well..
Erik
Quoted 25 lines
Reported-by Will Deacon <[email protected]>Suggested-by Ard Biesheuvel <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>--- include/acpi/actypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/acpi/actypes.h index renamed from include/acpi/actypes.h +0
-0
4defed58ea33..04359c70b198100644include/acpi/actypes.h +1
-2@@ -508,7 +508,7 @@ typedef u64 acpi_integer;#define ACPI_TO_POINTER (i) ACPI_CAST_PTR (void, (acpi_size) (i))#define ACPI_TO_INTEGER (p) ACPI_PTR_DIFF (p, (void *) 0) -#define ACPI_OFFSET (d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0) +#define ACPI_OFFSET (d, f) __builtin_offsetof(d, f)#define ACPI_PHYSADDR_TO_PTR (i) ACPI_TO_POINTER(i)#define ACPI_PTR_TO_PHYSADDR (i) ACPI_TO_INTEGER(i) --
Quoted 1 line
2.27.0.rc2.251.g90737beb825-goog
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH] ACPICA: fix UBSAN warning using __builtin_offsetof
Quoted 13 lines · Erik
Hi,
Quoted 6 lines
Will reported UBSAN warnings:
UBSAN: null-ptr-deref in drivers/acpi/acpica/tbfadt.c:459:37 UBSAN: null-ptr-deref in arch/arm64/kernel/smp.c:596:6Looks like the emulated offsetof macro
ACPI_OFFSETis causing these. We can avoid this by using the compiler builtin,__builtin_offsetof.I'll take a look at this tomorrow
Quoted 1 line
Quoted 7 lines
Quoted 2 lines
The non-kernel runtime of UBSAN would print:
runtime error: member access within null pointer of type for this macro.
actypes.his owned by ACPICA so we typically do not allow compiler-specific extensions because the code is intended to be compiled using the C99 standard without compiler extensions. We could allow this sort of thing in a Linux-specific header file likeinclude/acpi/platform/aclinux.hbut I'll take a look at the error as well..
If I'm not allowed to touch that header, it looks like I can include <linux/stddef.h> (rather than my host's <stddef.h>) to get a definition of offsetof thats implemented in terms of __builtin_offsetof. I should be able to use that to replace uses of ACPI_OFFSET. Are any of these off limits?
$ grep -rn ACPI_OFFSET arch/arm64/include/asm/acpi.h:34:#define ACPI_MADT_GICC_MIN_LENGTH ACPI_OFFSET( \ arch/arm64/include/asm/acpi.h:41:#define ACPI_MADT_GICC_SPE (ACPI_OFFSET(struct acpi_madt_generic_interrupt, \ include/acpi/actbl.h:376:#define ACPI_FADT_OFFSET(f) (u16) ACPI_OFFSET (struct acpi_table_fadt, f) drivers/acpi/acpica/acresrc.h:84:#define ACPI_RS_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_resource,f) drivers/acpi/acpica/acresrc.h:85:#define AML_OFFSET(f) (u8) ACPI_OFFSET (union aml_resource,f) drivers/acpi/acpica/acinterp.h:17:#define ACPI_EXD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_operand_object,f) drivers/acpi/acpica/acinterp.h:18:#define ACPI_EXD_NSOFFSET(f) (u8) ACPI_OFFSET (struct acpi_namespace_node,f) drivers/acpi/acpica/rsdumpinfo.c:16:#define ACPI_RSD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_resource_data,f) drivers/acpi/acpica/rsdumpinfo.c:17:#define ACPI_PRT_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_pci_routing_table,f)
Signature · 2 lines
Thanks, ~Nick Desaulniers
Will Deacon
maintainerRe: [PATCH] ACPICA: fix UBSAN warning using __builtin_offsetof
Hey Nick,
Quoted 18 lines · Nick Desaulniers
Quoted 9 lines · Erik
Quoted 6 lines
Will reported UBSAN warnings:
UBSAN: null-ptr-deref in drivers/acpi/acpica/tbfadt.c:459:37 UBSAN: null-ptr-deref in arch/arm64/kernel/smp.c:596:6Looks like the emulated offsetof macro
ACPI_OFFSETis causing these. We can avoid this by using the compiler builtin,__builtin_offsetof.I'll take a look at this tomorrow
Quoted 1 line
Quoted 7 lines
Quoted 2 lines
The non-kernel runtime of UBSAN would print:
runtime error: member access within null pointer of type for this macro.
actypes.his owned by ACPICA so we typically do not allow compiler-specific extensions because the code is intended to be compiled using the C99 standard without compiler extensions. We could allow this sort of thing in a Linux-specific header file likeinclude/acpi/platform/aclinux.hbut I'll take a look at the error as well..
Quoted 5 lines
If I'm not allowed to touch that header, it looks like I can include <
linux/stddef.h> (rather than my host's <stddef.h>) to get a definition ofoffsetofthats implemented in terms of__builtin_offsetof. I should be able to use that to replace uses ofACPI_OFFSET. Are any of these off limits?
It's not so much about not being allowed to touch the header, but rather that the kernel imports the code from a different project:
Quoted 5 lines
$ grep -rn ACPI_OFFSET arch/arm64/include/asm/acpi.h:34:#define ACPI_MADT_GICC_MIN_LENGTH ACPI_OFFSET( \ arch/arm64/include/asm/acpi.h:41:#define ACPI_MADT_GICC_SPE (ACPI_OFFSET(struct acpi_madt_generic_interrupt, \
I'm happy to take patches to the stuff under arch/arm64/, fwiw.
Will
Re: [PATCH] ACPICA: fix UBSAN warning using __builtin_offsetof
Quoted 33 lines · Will Deacon
Hey Nick,
Quoted 18 lines · Nick Desaulniers
Quoted 9 lines · Erik
Quoted 6 lines
Will reported UBSAN warnings:
UBSAN: null-ptr-deref in drivers/acpi/acpica/tbfadt.c:459:37 UBSAN: null-ptr-deref in arch/arm64/kernel/smp.c:596:6Looks like the emulated offsetof macro
ACPI_OFFSETis causing these. We can avoid this by using the compiler builtin,__builtin_offsetof.I'll take a look at this tomorrow
Quoted 1 line
Quoted 7 lines
Quoted 2 lines
The non-kernel runtime of UBSAN would print:
runtime error: member access within null pointer of type for this macro.
actypes.his owned by ACPICA so we typically do not allow compiler-specific extensions because the code is intended to be compiled using the C99 standard without compiler extensions. We could allow this sort of thing in a Linux-specific header file likeinclude/acpi/platform/aclinux.hbut I'll take a look at the error as well..Quoted 5 lines
If I'm not allowed to touch that header, it looks like I can include <
linux/stddef.h> (rather than my host's <stddef.h>) to get a definition ofoffsetofthats implemented in terms of__builtin_offsetof. I should be able to use that to replace uses ofACPI_OFFSET. Are any of these off limits?It's not so much about not being allowed to touch the header, but rather that the kernel imports the code from a different project:
Quoted 7 lines
Quoted 5 lines
$ grep -rn ACPI_OFFSET arch/arm64/include/asm/acpi.h:34:#define ACPI_MADT_GICC_MIN_LENGTH ACPI_OFFSET( \ arch/arm64/include/asm/acpi.h:41:#define ACPI_MADT_GICC_SPE (ACPI_OFFSET(struct acpi_madt_generic_interrupt, \I'm happy to take patches to the stuff under
arch/arm64/, fwiw.
Not really sure how to untangle this. Those two cases under arch/arm64/ are straightforward to fix:
```
diff --git a/arch/arm64/include/asm/acpi.h
b/arch/arm64/include/asm/acpi.h
index b263e239cb59..a45366c3909b 100644
--- a/arch/arm64/include/asm/acpi.h
+++ b/arch/arm64/include/asm/acpi.h
@@ -12,6 +12,7 @@
#include <linux/efi.h>
#include <linux/memblock.h>
#include <linux/psci.h>
+#include <linux/stddef.h>
#include <asm/cputype.h>
#include <asm/io.h>
@@ -31,14 +32,14 @@
* is therefore used to delimit the MADT GICC structure minimum length
* appropriately.
*/
-#define ACPI_MADT_GICC_MIN_LENGTH ACPI_OFFSET( \
+#define ACPI_MADT_GICC_MIN_LENGTH offsetof( \
struct acpi_madt_generic_interrupt, efficiency_class)
#define BAD_MADT_GICC_ENTRY(entry, end)
\
(!(entry) || (entry)->header.length < ACPI_MADT_GICC_MIN_LENGTH || \
(unsigned long)(entry) + (entry)->header.length > (end))
-#define ACPI_MADT_GICC_SPE (ACPI_OFFSET(struct acpi_madt_generic_interrupt, \
+#define ACPI_MADT_GICC_SPE (offsetof(struct acpi_madt_generic_interrupt, \
spe_interrupt) + sizeof(u16))
/* Basic configuration for ACPI */
```But for one of the warnings you reported, as an example:
UBSAN: null-ptr-deref in drivers/acpi/acpica/tbfadt.c:459:37
```
$ ag ACPI_FADT_V2_SIZE
include/acpi/actbl.h
394:#define ACPI_FADT_V2_SIZE (u32) (ACPI_FADT_OFFSET
(minor_revision) + 1)
drivers/acpi/acpica/tbfadt.c
459: if (acpi_gbl_FADT.header.length <= ACPI_FADT_V2_SIZE) {
$ ag ACPI_FADT_OFFSET
...
include/acpi/actbl.h
376:#define ACPI_FADT_OFFSET(f) (u16) ACPI_OFFSET (struct
acpi_table_fadt, f)
...
```So the use of ACPI_FADT_V2_SIZE in drivers/acpi/acpica/tbfadt.c is triggering one of the warnings. ACPI_FADT_V2_SIZE is defined in terms of ACPI_FADT_OFFSET which is defined in terms of ACPI_OFFSET in include/acpi/actbl.h. From the link you posted, include/acpi/actbl.h is from the project under source/include/.
Further, drivers/acpi/acpica/tbfadt.c seems to also be from the upstream project under source/components/tables/tbfadt.c.
Regardless, the second of the two warnings is definitely fixed by my above diff, so let me rephrase the previous commit message with that diff and resend.
Signature · 2 lines
Thanks, ~Nick Desaulniers
PATCH v2 1/1 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.
---
Changes V1 -> V2:
* Just fix one of the two warnings, specific to arm64.
* Put warning in commit message.
arch/arm64/include/asm/acpi.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm64/include/asm/acpi.h +3 -2
@@ -12,6 +12,7 @@#include <linux/efi.h> #include <linux/memblock.h> #include <linux/psci.h> +#include <linux/stddef.h> #include <asm/cputype.h> #include <asm/io.h>
@@ -31,14 +32,14 @@* is therefore used to delimit the MADT GICC structure minimum length * appropriately. */ -#define ACPI_MADT_GICC_MIN_LENGTH ACPI_OFFSET( \ +#define ACPI_MADT_GICC_MIN_LENGTH offsetof( \ struct acpi_madt_generic_interrupt, efficiency_class)#define BAD_MADT_GICC_ENTRY (entry, end) \ (!(entry) || (entry)->header.length < ACPI_MADT_GICC_MIN_LENGTH || \ (unsigned long)(entry) + (entry)->header.length > (end)) -#define ACPI_MADT_GICC_SPE (ACPI_OFFSET(struct acpi_madt_generic_interrupt, \ +#define ACPI_MADT_GICC_SPE (offsetof(struct acpi_madt_generic_interrupt, \ spe_interrupt) + sizeof(u16))/* Basic configuration for ACPI */
Signature · 1 line
2.27.0.278.ge193c7cf3a9-goog
Re: [PATCH v2] arm64: acpi: fix UBSAN warning
Quoted 30 lines · Nick Desaulniers
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/0x6f4This is from the use of the
ACPI_OFFSETinarch/arm64/include/asm/acpi.h. Replace its use with offsetof frominclude/linux/stddef.hwhich should implement the same logic using__builtin_offsetof, so that UBSAN wont warn.
Quoted 7 lines
---
Changes V1 -> V2:
* Just fix one of the two warnings, specific to arm64.
* Put warning in commit message.arch/arm64/include/asm/acpi.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 32 lines
arch/arm64/include/asm/acpi.h +3
-2@@ -12,6 +12,7 @@#include <linux/efi.h> #include <linux/memblock.h> #include <linux/psci.h> +#include <linux/stddef.h> #include <asm/cputype.h> #include <asm/io.h> @@ -31,14 +32,14 @@* is therefore used to delimit the MADT GICC structure minimum length * appropriately. */ -#define ACPI_MADT_GICC_MIN_LENGTH ACPI_OFFSET( \ +#define ACPI_MADT_GICC_MIN_LENGTH offsetof( \ struct acpi_madt_generic_interrupt, efficiency_class)#define BAD_MADT_GICC_ENTRY (entry, end) \ (!(entry) || (entry)->header.length < ACPI_MADT_GICC_MIN_LENGTH || \ (unsigned long)(entry) + (entry)->header.length > (end)) -#define ACPI_MADT_GICC_SPE (ACPI_OFFSET(struct acpi_madt_generic_interrupt, \ +#define ACPI_MADT_GICC_SPE (offsetof(struct acpi_madt_generic_interrupt, \ spe_interrupt) + sizeof(u16))/* Basic configuration for ACPI */ Signature · 1 line
2.27.0.278.ge193c7cf3a9-goog
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v2] arm64: acpi: fix UBSAN warning
In reply to Nick DesaulniersHi,
Quoted 20 lines · Nick Desaulniers
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
Quoted 4 lines
This is from the use of the
ACPI_OFFSETinarch/arm64/include/asm/acpi.h. Replace its use with offsetof frominclude/linux/stddef.hwhich should implement the same logic using__builtin_offsetof, so that UBSAN wont warn.
I looked at the longer thread about this, given that it appears to be a false positive with respect to the macro, I tend to prefer Ard's suggestion of just changing the offset value (1 should be sufficient rather than 0) to avoid this kind of problem in the future.
But either way, this change looks fine too.
Thanks,
Quoted 44 lines
Reported-by Will Deacon <[email protected]>Suggested-by Ard Biesheuvel <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>---
Changes V1 -> V2:
* Just fix one of the two warnings, specific to arm64.
* Put warning in commit message.arch/arm64/include/asm/acpi.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)arch/arm64/include/asm/acpi.h +3
-2@@ -12,6 +12,7 @@#include <linux/efi.h> #include <linux/memblock.h> #include <linux/psci.h> +#include <linux/stddef.h> #include <asm/cputype.h> #include <asm/io.h> @@ -31,14 +32,14 @@* is therefore used to delimit the MADT GICC structure minimum length * appropriately. */ -#define ACPI_MADT_GICC_MIN_LENGTH ACPI_OFFSET( \ +#define ACPI_MADT_GICC_MIN_LENGTH offsetof( \ struct acpi_madt_generic_interrupt, efficiency_class)#define BAD_MADT_GICC_ENTRY (entry, end) \ (!(entry) || (entry)->header.length < ACPI_MADT_GICC_MIN_LENGTH || \ (unsigned long)(entry) + (entry)->header.length > (end)) -#define ACPI_MADT_GICC_SPE (ACPI_OFFSET(struct acpi_madt_generic_interrupt, \ +#define ACPI_MADT_GICC_SPE (offsetof(struct acpi_madt_generic_interrupt, \ spe_interrupt) + sizeof(u16))/* Basic configuration for ACPI */
Re: [PATCH v2] arm64: acpi: fix UBSAN warning
In reply to Nick DesaulniersQuoted 20 lines · Nick Desaulniers
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
Quoted 1 line
[...]
Applied to arm64 (for-next/core), thanks!
[1/1] arm64: acpi: fix UBSAN warning
https://git.kernel.org/arm64/c/a194c33f45f8
Cheers,
Signature · 5 lines
Will https://fixes.arm64.dev https://next.arm64.dev https://will.arm64.dev
RE: [PATCH] ACPICA: fix UBSAN warning using __builtin_offsetof
In reply to Nick DesaulniersQuoted 31 lines
-----Original Message-----
From: Nick Desaulniers <[email protected]>
Sent: Tuesday, June 2, 2020 11:47 AM
To: Kaneda, Erik <[email protected]>
Cc: Moore, Robert <[email protected]>; Wysocki, Rafael J <[email protected]>; Len Brown <[email protected]>; Ard Biesheuvel <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] ACPICA: fix UBSAN warning using__builtin_offsetofQuoted 13 lines · Erik
Hi,
Quoted 6 lines
Will reported UBSAN warnings:
UBSAN: null-ptr-deref in drivers/acpi/acpica/tbfadt.c:459:37 UBSAN: null-ptr-deref in arch/arm64/kernel/smp.c:596:6Looks like the emulated offsetof macro
ACPI_OFFSETis causing these. We can avoid this by using the compiler builtin,__builtin_offsetof.I'll take a look at this tomorrow
Quoted 1 line
Quoted 9 lines
Quoted 7 lines
Quoted 2 lines
The non-kernel runtime of UBSAN would print:
runtime error: member access within null pointer of type for this macro.
actypes.his owned by ACPICA so we typically do not allow compiler-specific extensions because the code is intended to be compiled using the C99 standard without compiler extensions. We could allow this sort of thing in a Linux-specific header file like
include/acpi/platform/aclinux.hbut I'll take a look at the error as well..
Hi,
Quoted 2 lines
If I'm not allowed to touch that header, it looks like I can include <
linux/stddef.h> (rather than my host's <stddef.h>) to get a definition of
Why not use your host's stddef.h?
Quoted 2 lines
offsetofthats implemented in terms of__builtin_offsetof. I should be able to use that to replace uses ofACPI_OFFSET. Are any of these off limits?
Yes, the idea is to define ACPI_OFFSET in a way that you want so that we don't touch the uses below.
Erik
Quoted 21 lines
$ grep -rn ACPI_OFFSET arch/arm64/include/asm/acpi.h:34:#define ACPI_MADT_GICC_MIN_LENGTH ACPI_OFFSET( \ arch/arm64/include/asm/acpi.h:41:#define ACPI_MADT_GICC_SPE (ACPI_OFFSET(struct acpi_madt_generic_interrupt, \ include/acpi/actbl.h:376:#define ACPI_FADT_OFFSET(f) (u16) ACPI_OFFSET (struct acpi_table_fadt, f) drivers/acpi/acpica/acresrc.h:84:#define ACPI_RS_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_resource,f) drivers/acpi/acpica/acresrc.h:85:#define AML_OFFSET(f) (u8) ACPI_OFFSET (union aml_resource,f) drivers/acpi/acpica/acinterp.h:17:#define ACPI_EXD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_operand_object,f) drivers/acpi/acpica/acinterp.h:18:#define ACPI_EXD_NSOFFSET(f) (u8) ACPI_OFFSET (struct acpi_namespace_node,f) drivers/acpi/acpica/rsdumpinfo.c:16:#define ACPI_RSD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_resource_data,f) drivers/acpi/acpica/rsdumpinfo.c:17:#define ACPI_PRT_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_pci_routing_table,f)
Quoted 3 lines
--
Thanks,
~Nick Desaulniers
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
RE: [PATCH] ACPICA: fix UBSAN warning using __builtin_offsetof
In reply to Nick Desaulniers+JKim (for FreeBSD's perspective)
Quoted 15 lines
-----Original Message-----
From: Nick Desaulniers <[email protected]>
Sent: Monday, June 1, 2020 4:18 PM
To: Moore, Robert <[email protected]>; Kaneda, Erik <[email protected]>; Wysocki, Rafael J <[email protected]>; Len Brown <[email protected]>
Cc: Ard Biesheuvel <[email protected]>; [email protected]; [email protected]; [email protected]; linux-arm- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH] ACPICA: fix UBSAN warning using__builtin_offsetof
Quoted 4 lines
Will reported UBSAN warnings:
UBSAN: null-ptr-deref in drivers/acpi/acpica/tbfadt.c:459:37 UBSAN: null-ptr-deref in arch/arm64/kernel/smp.c:596:6
Hi,
Quoted 3 lines
Looks like the emulated offsetof macro
ACPI_OFFSETis causing these. We can avoid this by using the compiler builtin,__builtin_offsetof.
This doesn't really fly because __builtin_offsetof is a compiler extension.
It looks like a lot of stddef.h files do this:
#define offsetof(a,b) __builtin_offset(a,b)
So does anyone have objections to ACPI_OFFSET being defined to offsetof()?
This will allow a host OS project project to use their own definitions of offsetof in place of ACPICA's. If they don't have a definition for offsetof, we can supply the old one as a fallback.
Here's a patch:
include/acpi/actypes.h +7 -1
@@ -504,11 +504,17 @@ typedef u64 acpi_integer;#define ACPI_SUB_PTR (t, a, b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (u8, (a)) - (acpi_size)(b)))#define ACPI_PTR_DIFF (a, b) ((acpi_size) (ACPI_CAST_PTR (u8, (a)) - ACPI_CAST_PTR (u8, (b)))) +/* Use an existing definiton for offsetof */ + +#ifndef offsetof +#define offsetof (d,f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0) +#endif +/* Pointer/Integer type conversions */ #define ACPI_TO_POINTER (i) ACPI_CAST_PTR (void, (acpi_size) (i))#define ACPI_TO_INTEGER (p) ACPI_PTR_DIFF (p, (void *) 0) -#define ACPI_OFFSET (d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0) +#define ACPI_OFFSET (d, f) offsetof (d,f)#define ACPI_PHYSADDR_TO_PTR (i) ACPI_TO_POINTER(i)#define ACPI_PTR_TO_PHYSADDR (i) ACPI_TO_INTEGER(i)
Thanks,
Erik
Quoted 28 lines
The non-kernel runtime of UBSAN would print:
runtime error: member access within null pointer of type for this macro.Reported-by Will Deacon <[email protected]>Suggested-by Ard Biesheuvel <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>--- include/acpi/actypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/acpi/actypes.h index renamed from include/acpi/actypes.h +0
-0
4defed58ea33..04359c70b198100644include/acpi/actypes.h +1
-2@@ -508,7 +508,7 @@ typedef u64 acpi_integer;#define ACPI_TO_POINTER (i) ACPI_CAST_PTR (void, (acpi_size) (i))#define ACPI_TO_INTEGER (p) ACPI_PTR_DIFF (p, (void *) 0) -#define ACPI_OFFSET (d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0) +#define ACPI_OFFSET (d, f) __builtin_offsetof(d, f)#define ACPI_PHYSADDR_TO_PTR (i) ACPI_TO_POINTER(i)#define ACPI_PTR_TO_PHYSADDR (i) ACPI_TO_INTEGER(i) --2.27.0.rc2.251.g90737beb825-goog
Re: [PATCH] ACPICA: fix UBSAN warning using __builtin_offsetof
Quoted 43 lines · Erik
+JKim (for FreeBSD's perspective)
Quoted 15 lines
-----Original Message-----
From: Nick Desaulniers <[email protected]>
Sent: Monday, June 1, 2020 4:18 PM
To: Moore, Robert <[email protected]>; Kaneda, Erik <[email protected]>; Wysocki, Rafael J <[email protected]>; Len Brown <[email protected]>
Cc: Ard Biesheuvel <[email protected]>; [email protected]; [email protected]; [email protected]; linux-arm- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH] ACPICA: fix UBSAN warning using__builtin_offsetofQuoted 4 lines
Will reported UBSAN warnings:
UBSAN: null-ptr-deref in drivers/acpi/acpica/tbfadt.c:459:37 UBSAN: null-ptr-deref in arch/arm64/kernel/smp.c:596:6Hi,
Quoted 3 lines
Looks like the emulated offsetof macro
ACPI_OFFSETis causing these. We can avoid this by using the compiler builtin,__builtin_offsetof.This doesn't really fly because
__builtin_offsetofis a compiler extension.It looks like a lot of
stddef.hfiles do this:#define
offsetof(a,b)__builtin_offset(a,b)So does anyone have objections to
ACPI_OFFSETbeing defined tooffsetof()?This will allow a host OS project project to use their own definitions of offsetof in place of ACPICA's. If they don't have a definition for offsetof, we can supply the old one as a fallback.
Here's a patch:
include/acpi/actypes.h typedef u64 acpi_integer; · line 507
Quoted 4 lines
include/acpi/actypes.h +1
-0@@ -504,11 +504,17 @@ typedef u64 acpi_integer;#define ACPI_SUB_PTR (t, a, b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (u8, (a)) - (acpi_size)(b)))#define ACPI_PTR_DIFF (a, b) ((acpi_size) (ACPI_CAST_PTR (u8, (a)) - ACPI_CAST_PTR (u8, (b)))) +/* Use an existing definiton for offsetof */
s/definiton/definition/
include/acpi/actypes.h typedef u64 acpi_integer; · line 511
Quoted 4 lines
include/acpi/actypes.h +4
-0+ +#ifndef offsetof +#define offsetof (d,f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0) +#endif
If this header doesn't explicitly include <stddef.h> or <linux/stddef.h>, won't translation units that include <acpi/actypes.h> get different definitions of ACPI_OFFSET based on whether they explicitly or transitively included <stddef.h> before including <acpi/actypes.h>? Theoretically, a translation unit in the kernel could include actypes.h, have no includes of linux/stddef.h, then get UBSAN errors again from using this definition?
I don't mind using offsetof in place of the builtin (since it typically will be implemented in terms of the builtin, or is at least for the case specific to the Linux kernel). But if it's used, we should include the header that defines it properly, and we should not use the host's <stddef.h> IMO. Is there a platform specific way to include the platform's stddef.h here?
Maybe linux/stddef.h should be included in include/acpi/platform/aclinux.h, then include/acpi/platform/acenv.h included in include/acpi/actypes.h, such that ACPI_OFFSET is defined in terms of offsetof defined from that transitive dependency of headers? (or do we get a circular inclusion trying to do that?)
Quoted 42 lines
include/acpi/actypes.h +2
-1+/* Pointer/Integer type conversions */ #define ACPI_TO_POINTER (i) ACPI_CAST_PTR (void, (acpi_size) (i))#define ACPI_TO_INTEGER (p) ACPI_PTR_DIFF (p, (void *) 0) -#define ACPI_OFFSET (d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0) +#define ACPI_OFFSET (d, f) offsetof (d,f)#define ACPI_PHYSADDR_TO_PTR (i) ACPI_TO_POINTER(i)#define ACPI_PTR_TO_PHYSADDR (i) ACPI_TO_INTEGER(i)Thanks,
ErikQuoted 28 lines
The non-kernel runtime of UBSAN would print:
runtime error: member access within null pointer of type for this macro.Reported-by Will Deacon <[email protected]>Suggested-by Ard Biesheuvel <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>--- include/acpi/actypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/acpi/actypes.h index renamed from include/acpi/actypes.h +0
-0
4defed58ea33..04359c70b198100644include/acpi/actypes.h +1
-2@@ -508,7 +508,7 @@ typedef u64 acpi_integer;#define ACPI_TO_POINTER (i) ACPI_CAST_PTR (void, (acpi_size) (i))#define ACPI_TO_INTEGER (p) ACPI_PTR_DIFF (p, (void *) 0) -#define ACPI_OFFSET (d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0) +#define ACPI_OFFSET (d, f) __builtin_offsetof(d, f)#define ACPI_PHYSADDR_TO_PTR (i) ACPI_TO_POINTER(i)#define ACPI_PTR_TO_PHYSADDR (i) ACPI_TO_INTEGER(i) --2.27.0.rc2.251.g90737beb825-goog
Signature · 2 lines
Thanks, ~Nick Desaulniers
Re: [PATCH] ACPICA: fix UBSAN warning using __builtin_offsetof
Quoted 71 lines · Nick Desaulniers
Quoted 43 lines · Erik
+JKim (for FreeBSD's perspective)
Quoted 15 lines
-----Original Message-----
From: Nick Desaulniers <ndesaulniers(a)google.com>
Sent: Monday, June 1, 2020 4:18 PM
To: Moore, Robert <robert.moore(a)intel.com>; Kaneda, Erik <erik.kaneda(a)intel.com>; Wysocki, Rafael J <rafael.j.wysocki(a)intel.com>; Len Brown <lenb(a)kernel.org>
Cc: Ard Biesheuvel <ardb(a)kernel.org>; dvyukov(a)google.com; glider(a)google.com; guohanjun(a)huawei.com; linux-arm- kernel(a)lists.infradead.org; linux-kernel(a)vger.kernel.org; lorenzo.pieralisi(a)arm.com; mark.rutland(a)arm.com; ndesaulniers(a)google.com; pcc(a)google.com; rjw(a)rjwysocki.net; will(a)kernel.org; stable(a)vger.kernel.org; linux-acpi(a)vger.kernel.org; devel(a)acpica.org
Subject: [PATCH] ACPICA: fix UBSAN warning using__builtin_offsetofQuoted 4 lines
Will reported UBSAN warnings:
UBSAN: null-ptr-deref in drivers/acpi/acpica/tbfadt.c:459:37 UBSAN: null-ptr-deref in arch/arm64/kernel/smp.c:596:6Hi,
Quoted 3 lines
Looks like the emulated offsetof macro
ACPI_OFFSETis causing these. We can avoid this by using the compiler builtin,__builtin_offsetof.This doesn't really fly because
__builtin_offsetofis a compiler extension.It looks like a lot of
stddef.hfiles do this:#define
offsetof(a,b)__builtin_offset(a,b)So does anyone have objections to
ACPI_OFFSETbeing defined tooffsetof()?This will allow a host OS project project to use their own definitions of offsetof in place of ACPICA's. If they don't have a definition for offsetof, we can supply the old one as a fallback.
Here's a patch:
include/acpi/actypes.h typedef u64 acpi_integer; · line 507
Quoted 4 lines
include/acpi/actypes.h +1
-0@@ -504,11 +504,17 @@ typedef u64 acpi_integer;#define ACPI_SUB_PTR (t, a, b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (u8, (a)) - (acpi_size)(b)))#define ACPI_PTR_DIFF (a, b) ((acpi_size) (ACPI_CAST_PTR (u8, (a)) - ACPI_CAST_PTR (u8, (b)))) +/* Use an existing definiton for offsetof */ s/definiton/definition/
include/acpi/actypes.h typedef u64 acpi_integer; · line 511
Quoted 4 lines
include/acpi/actypes.h +4
-0+ +#ifndef offsetof +#define offsetof (d,f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0) +#endif If this header doesn't explicitly include <
stddef.h> or <linux/stddef.h>, won't translation units that include <acpi/actypes.h> get different definitions ofACPI_OFFSETbased on whether they explicitly or transitively included <stddef.h> before including <acpi/actypes.h>? Theoretically, a translation unit in the kernel could includeactypes.h, have no includes oflinux/stddef.h, then get UBSAN errors again from using this definition?I don't mind using offsetof in place of the builtin (since it typically will be implemented in terms of the builtin, or is at least for the case specific to the Linux kernel). But if it's used, we should include the header that defines it properly, and we should not use the host's <
stddef.h> IMO. Is there a platform specific way to include the platform'sstddef.hhere?
Quoted 5 lines
Maybe
linux/stddef.hshould be included ininclude/acpi/platform/aclinux.h, theninclude/acpi/platform/acenv.hincluded ininclude/acpi/actypes.h, such thatACPI_OFFSETis defined in terms of offsetof defined from that transitive dependency of headers? (or do we get a circular inclusion trying to do that?)
Actually, I think we should let platform-specific acfoo.h decide what to do here, i.e.,
#ifndef ACPI_OFFSET
#define ACPI_OFFSET(d, f) ...
#endif
Jung-uk Kim
Quoted 41 lines
Quoted 41 lines
include/acpi/actypes.h +2
-1+/* Pointer/Integer type conversions */ #define ACPI_TO_POINTER (i) ACPI_CAST_PTR (void, (acpi_size) (i))#define ACPI_TO_INTEGER (p) ACPI_PTR_DIFF (p, (void *) 0) -#define ACPI_OFFSET (d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0) +#define ACPI_OFFSET (d, f) offsetof (d,f)#define ACPI_PHYSADDR_TO_PTR (i) ACPI_TO_POINTER(i)#define ACPI_PTR_TO_PHYSADDR (i) ACPI_TO_INTEGER(i)Thanks,
ErikQuoted 28 lines
The non-kernel runtime of UBSAN would print:
runtime error: member access within null pointer of type for this macro.Cc stable(a)vger.kernel.orgReported-by Will Deacon <will(a)kernel.org>Suggested-by Ard Biesheuvel <ardb(a)kernel.org>Signed-off-by Nick Desaulniers <ndesaulniers(a)google.com>--- include/acpi/actypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/acpi/actypes.h index renamed from include/acpi/actypes.h +0
-0
4defed58ea33..04359c70b198100644include/acpi/actypes.h +1
-2@@ -508,7 +508,7 @@ typedef u64 acpi_integer;#define ACPI_TO_POINTER (i) ACPI_CAST_PTR (void, (acpi_size) (i))#define ACPI_TO_INTEGER (p) ACPI_PTR_DIFF (p, (void *) 0) -#define ACPI_OFFSET (d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0) +#define ACPI_OFFSET (d, f) __builtin_offsetof(d, f)#define ACPI_PHYSADDR_TO_PTR (i) ACPI_TO_POINTER(i)#define ACPI_PTR_TO_PHYSADDR (i) ACPI_TO_INTEGER(i) --2.27.0.rc2.251.g90737beb825-goog
RE: [Devel] Re: [PATCH] ACPICA: fix UBSAN warning using __builtin_offsetof
Quoted 72 lines
-----Original Message-----
From: Jung-uk Kim <[email protected]>
Sent: Wednesday, June 10, 2020 4:46 PM
To: Nick Desaulniers <[email protected]>; Kaneda, Erik <[email protected]>
Cc: Wysocki, Rafael J <[email protected]>; Ard Biesheuvel <[email protected]>; [email protected]; [email protected]; linux-arm- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]
Subject: [Devel] Re: [PATCH] ACPICA: fix UBSAN warning using__builtin_offsetofQuoted 1 line · Nick Desaulniers
On Wed, Jun 10, 2020 at 4:07 PM Kaneda, Erik <[email protected]>
Quoted 8 lines · wrote:
Quoted 8 lines
+JKim (for FreeBSD's perspective)
Quoted 5 lines
-----Original Message-----
From: Nick Desaulniers <[email protected]>
Sent: Monday, June 1, 2020 4:18 PM
To: Moore, Robert <[email protected]>; Kaneda, Erik <[email protected]>; Wysocki, Rafael JQuoted 10 lines
Quoted 10 lines
Quoted 10 lines
Len Brown <[email protected]>
Cc: Ard Biesheuvel <[email protected]>; [email protected]; [email protected]; [email protected]; linux-arm- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH] ACPICA: fix UBSAN warning using__builtin_offsetofQuoted 7 lines
Quoted 7 lines
Quoted 4 lines
Will reported UBSAN warnings:
UBSAN: null-ptr-deref in drivers/acpi/acpica/tbfadt.c:459:37 UBSAN: null-ptr-deref in arch/arm64/kernel/smp.c:596:6Hi,
Quoted 1 line
Looks like the emulated offsetof macro
ACPI_OFFSETis causing these.We
Quoted 9 lines
Quoted 9 lines
Quoted 2 lines
can avoid this by using the compiler builtin,
__builtin_offsetof.This doesn't really fly because
__builtin_offsetofis a compiler extension.It looks like a lot of
stddef.hfiles do this:#define
offsetof(a,b)__builtin_offset(a,b)So does anyone have objections to
ACPI_OFFSETbeing defined to
offsetof()?Quoted 2 lines
Quoted 2 lines
This will allow a host OS project project to use their own definitions of
offsetof in place of ACPICA's.
Quoted 1 line
Quoted 1 line
If they don't have a definition for offsetof, we can supply the old one as a
fallback.
Quoted 7 lines
include/acpi/actypes.h typedef u64 acpi_integer; · line 504
Quoted 7 lines
Here's a patch:
include/acpi/actypes.h +0
-0@@ -504,11 +504,17 @@ typedef u64 acpi_integer;#define ACPI_SUB_PTR (t, a, b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR(u8, (a)) - (acpi_size)(b)))
Quoted 1 line
include/acpi/actypes.h typedef u64 acpi_integer; · line 505
Quoted 1 line
include/acpi/actypes.h +0
-0#define ACPI_PTR_DIFF (a, b) ((acpi_size) (ACPI_CAST_PTR (u8, (a))-
ACPI_CAST_PTR(u8, (b))))Quoted 1 line
Quoted 1 line
Quoted 31 lines
Quoted 7 lines
Quoted 1 line
+/* Use an existing definiton for offsetof */
s/definiton/definition/
include/acpi/actypes.h
Quoted 3 lines
include/acpi/actypes.h +3
-0+ +#ifndef offsetof +#define offsetof (d,f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *)0)
Quoted 22 lines
Quoted 1 line
+#endif
If this header doesn't explicitly include <
stddef.h> or <linux/stddef.h>, won't translation units that include <acpi/actypes.h> get different definitions ofACPI_OFFSETbased on whether they explicitly or transitively included <stddef.h> before including <acpi/actypes.h>? Theoretically, a translation unit in the kernel could includeactypes.h, have no includes oflinux/stddef.h, then get UBSAN errors again from using this definition?I don't mind using offsetof in place of the builtin (since it typically will be implemented in terms of the builtin, or is at least for the case specific to the Linux kernel). But if it's used, we should include the header that defines it properly, and we should not use the host's <
stddef.h> IMO. Is there a platform specific way to include the platform'sstddef.hhere?Maybe
linux/stddef.hshould be included ininclude/acpi/platform/aclinux.h, theninclude/acpi/platform/acenv.hincluded ininclude/acpi/actypes.h, such thatACPI_OFFSETis defined in terms of offsetof defined from that transitive dependency of headers? (or do we get a circular inclusion trying to do that?)
Hi,
Quoted 2 lines
Actually, I think we should let platform-specific
acfoo.hdecide what to do here, i.e.,
That's a better solution. For Linux, it would look something like this:
include/acpi/actypes.h +6 -1
@@ -508,10 +508,15 @@ typedef u64 acpi_integer;#define ACPI_TO_POINTER (i) ACPI_CAST_PTR (void, (acpi_size) (i))#define ACPI_TO_INTEGER (p) ACPI_PTR_DIFF (p, (void *) 0) -#define ACPI_OFFSET (d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0)#define ACPI_PHYSADDR_TO_PTR (i) ACPI_TO_POINTER(i)#define ACPI_PTR_TO_PHYSADDR (i) ACPI_TO_INTEGER(i) +/* Platforms may want to define their own ACPI_OFFSET */ + +#ifndef ACPI_OFFSET +#define ACPI_OFFSET (d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0) +#endif +/* Optimizations for 4-character (32-bit) acpi_name manipulation */ #ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
include/acpi/platform/aclinux.h +5 -0
@@ -71,6 +71,11 @@#undef ACPI_DEBUG_DEFAULT#define ACPI_DEBUG_DEFAULT (ACPI_LV_INFO | ACPI_LV_REPAIR) +/* Use gcc's builtin offset instead of the default */ + +#undef ACPI_OFFSET +#define ACPI_OFFSET (a,b) __builtin_offsetof(a,b) +#ifndef CONFIG_ACPI
Quoted 50 lines
#ifndef
ACPI_OFFSET
#defineACPI_OFFSET(d, f)... #endifJung-uk Kim
Quoted 6 lines
include/acpi/actypes.h
Quoted 6 lines
include/acpi/actypes.h +1
-1+/* Pointer/Integer type conversions */ #define ACPI_TO_POINTER (i) ACPI_CAST_PTR (void, (acpi_size) (i))#define ACPI_TO_INTEGER (p) ACPI_PTR_DIFF (p, (void *) 0) -#define ACPI_OFFSET (d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void*) 0)
Quoted 11 lines
Quoted 11 lines
+#define ACPI_OFFSET(d, f) offsetof (d,f) #define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i) #define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i)Thanks,
ErikQuoted 4 lines
The non-kernel runtime of UBSAN would print:
runtime error: member access within null pointer of type for this macro.truck/
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Reported-by Will Deacon <[email protected]>Suggested-by Ard Biesheuvel <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>--- include/acpi/actypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 7 lines
Quoted 7 lines
include/acpi/actypes.h typedef u64 acpi_integer; · line 509
Quoted 7 lines
include/acpi/actypes.h index renamed from include/acpi/actypes.h +0
-0
4defed58ea33..04359c70b198100644include/acpi/actypes.h +0
-0@@ -508,7 +508,7 @@ typedef u64 acpi_integer;#define ACPI_TO_POINTER (i) ACPI_CAST_PTR (void, (acpi_size)(i))
Quoted 2 lines
Quoted 2 lines
include/acpi/actypes.h typedef u64 acpi_integer; · line 511
Quoted 2 lines
include/acpi/actypes.h +0
-1#define ACPI_TO_INTEGER (p) ACPI_PTR_DIFF (p, (void *) 0) -#define ACPI_OFFSET (d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void*)
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
include/acpi/actypes.h +1
-00) +#define ACPI_OFFSET (d, f) __builtin_offsetof(d, f)#define ACPI_PHYSADDR_TO_PTR (i) ACPI_TO_POINTER(i)#define ACPI_PTR_TO_PHYSADDR (i) ACPI_TO_INTEGER(i)
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
--
2.27.0.rc2.251.g90737beb825-goog_______________________________________________
Devel mailing list -- [email protected]
To unsubscribe send an email to [email protected] %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [Devel] Re: [PATCH] ACPICA: fix UBSAN warning using __builtin_offsetof
Quoted 32 lines · Erik
Quoted 5 lines
From: Jung-uk Kim <[email protected]>
Actually, I think we should let platform-specific
acfoo.hdecide what to do here, i.e.,That's a better solution. For Linux, it would look something like this:
include/acpi/actypes.h +6
-1@@ -508,10 +508,15 @@ typedef u64 acpi_integer;#define ACPI_TO_POINTER (i) ACPI_CAST_PTR (void, (acpi_size) (i))#define ACPI_TO_INTEGER (p) ACPI_PTR_DIFF (p, (void *) 0) -#define ACPI_OFFSET (d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0)#define ACPI_PHYSADDR_TO_PTR (i) ACPI_TO_POINTER(i)#define ACPI_PTR_TO_PHYSADDR (i) ACPI_TO_INTEGER(i) +/* Platforms may want to define their own ACPI_OFFSET */ + +#ifndef ACPI_OFFSET +#define ACPI_OFFSET (d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0) +#endif +/* Optimizations for 4-character (32-bit) acpi_name manipulation */ #ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED include/acpi/platform/aclinux.h +0
-0
include/acpi/platform/aclinux.h line 80
Quoted 10 lines
include/acpi/platform/aclinux.h +5
-0@@ -71,6 +71,11 @@#undef ACPI_DEBUG_DEFAULT#define ACPI_DEBUG_DEFAULT (ACPI_LV_INFO | ACPI_LV_REPAIR) +/* Use gcc's builtin offset instead of the default */ + +#undef ACPI_OFFSET +#define ACPI_OFFSET (a,b) __builtin_offsetof(a,b) +#ifndef CONFIG_ACPI
Looks good at first glance. Wouldn't actypes.h need to include platform/acenv.h first though? Otherwise you put some header inclusion order dependency on folks who include actypes.h to first include acenv.h otherwise we're not getting the definition in terms of __builtin_offsetof.
Signature · 2 lines
Thanks, ~Nick Desaulniers
RE: [Devel] Re: [PATCH] ACPICA: fix UBSAN warning using __builtin_offsetof
Quoted 56 lines
-----Original Message-----
From: Nick Desaulniers <[email protected]>
Sent: Thursday, June 11, 2020 10:06 AM
To: Kaneda, Erik <[email protected]>
Cc: Jung-uk Kim <[email protected]>; Wysocki, Rafael J <[email protected]>; Ard Biesheuvel <[email protected]>; [email protected]; [email protected]; linux-arm- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [Devel] Re: [PATCH] ACPICA: fix UBSAN warning using__builtin_offsetofQuoted 11 lines · Erik
Quoted 5 lines
From: Jung-uk Kim <[email protected]>
Actually, I think we should let platform-specific
acfoo.hdecide what to do here, i.e.,That's a better solution. For Linux, it would look something like this:
include/acpi/actypes.h typedef u64 acpi_integer; · line 511
Quoted 4 lines
include/acpi/actypes.h +0
-1@@ -508,10 +508,15 @@ typedef u64 acpi_integer;#define ACPI_TO_POINTER (i) ACPI_CAST_PTR (void, (acpi_size) (i))#define ACPI_TO_INTEGER (p) ACPI_PTR_DIFF (p, (void *) 0) -#define ACPI_OFFSET (d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *)0)
include/acpi/actypes.h typedef u64 acpi_integer;
Quoted 7 lines
include/acpi/actypes.h +4
-0#define ACPI_PHYSADDR_TO_PTR (i) ACPI_TO_POINTER(i)#define ACPI_PTR_TO_PHYSADDR (i) ACPI_TO_INTEGER(i) +/* Platforms may want to define their own ACPI_OFFSET */ + +#ifndef ACPI_OFFSET +#define ACPI_OFFSET (d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void*) 0)
Review
Quoted 6 lines
include/acpi/actypes.h +2
-0+#endif +/* Optimizations for 4-character (32-bit) acpi_name manipulation */ #ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED (quoted diff) +0
-0
b/include/acpi/platform/aclinux.hQuoted 7 lines
index
987e2af7c335..5d1ca6015fce100644include/acpi/platform/aclinux.h +0
-0@@ -71,6 +71,11 @@#undef ACPI_DEBUG_DEFAULT#define ACPI_DEBUG_DEFAULT (ACPI_LV_INFO | ACPI_LV_REPAIR)
Quoted 8 lines
include/acpi/platform/aclinux.h line 80
Quoted 7 lines
include/acpi/platform/aclinux.h +5
-0+/* Use gcc's builtin offset instead of the default */ + +#undef ACPI_OFFSET +#define ACPI_OFFSET (a,b) __builtin_offsetof(a,b) +#ifndef CONFIG_ACPI
Hi,
Sorry about the delayed response.
Quoted 5 lines
Looks good at first glance. Wouldn't
actypes.hneed to includeplatform/acenv.hfirst though? Otherwise you put some header inclusion order dependency on folks who includeactypes.hto first includeacenv.hotherwise we're not getting the definition in terms of__builtin_offsetof.
Actypes.h is intended for ACPICA use. For files using ACPI_OFFSET, they include headers like acpi.h that ends up including aclinux.h before including actypes.h. For those using ACPI_OFFSET, precedence will be given to the definition in aclinux.h before falling back to the definition in actypes.
Erik
Quoted 4 lines
--
Thanks,
~Nick Desaulniers
Re: [PATCH] ACPICA: fix UBSAN warning using __builtin_offsetof
In reply to Kaneda, ErikQuoted 49 lines · Erik
+JKim (for FreeBSD's perspective)
Quoted 15 lines
-----Original Message-----
From: Nick Desaulniers <ndesaulniers(a)google.com>
Sent: Monday, June 1, 2020 4:18 PM
To: Moore, Robert <robert.moore(a)intel.com>; Kaneda, Erik <erik.kaneda(a)intel.com>; Wysocki, Rafael J <rafael.j.wysocki(a)intel.com>; Len Brown <lenb(a)kernel.org>
Cc: Ard Biesheuvel <ardb(a)kernel.org>; dvyukov(a)google.com; glider(a)google.com; guohanjun(a)huawei.com; linux-arm- kernel(a)lists.infradead.org; linux-kernel(a)vger.kernel.org; lorenzo.pieralisi(a)arm.com; mark.rutland(a)arm.com; ndesaulniers(a)google.com; pcc(a)google.com; rjw(a)rjwysocki.net; will(a)kernel.org; stable(a)vger.kernel.org; linux-acpi(a)vger.kernel.org; devel(a)acpica.org
Subject: [PATCH] ACPICA: fix UBSAN warning using__builtin_offsetofQuoted 4 lines
Will reported UBSAN warnings:
UBSAN: null-ptr-deref in drivers/acpi/acpica/tbfadt.c:459:37 UBSAN: null-ptr-deref in arch/arm64/kernel/smp.c:596:6Hi,
Quoted 3 lines
Looks like the emulated offsetof macro
ACPI_OFFSETis causing these. We can avoid this by using the compiler builtin,__builtin_offsetof.This doesn't really fly because
__builtin_offsetofis a compiler extension.It looks like a lot of
stddef.hfiles do this:#define
offsetof(a,b)__builtin_offset(a,b)So does anyone have objections to
ACPI_OFFSETbeing defined tooffsetof()?This will allow a host OS project project to use their own definitions of offsetof in place of ACPICA's. If they don't have a definition for offsetof, we can supply the old one as a fallback.
Here's a patch:
include/acpi/actypes.h +4
-0@@ -504,11 +504,17 @@ typedef u64 acpi_integer;#define ACPI_SUB_PTR (t, a, b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (u8, (a)) - (acpi_size)(b)))#define ACPI_PTR_DIFF (a, b) ((acpi_size) (ACPI_CAST_PTR (u8, (a)) - ACPI_CAST_PTR (u8, (b)))) +/* Use an existing definiton for offsetof */ + +#ifndef offsetof +#define offsetof (d,f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0)
include/acpi/actypes.h typedef u64 acpi_integer; · line 519
Quoted 10 lines
include/acpi/actypes.h +3
-1+#endif +/* Pointer/Integer type conversions */ #define ACPI_TO_POINTER (i) ACPI_CAST_PTR (void, (acpi_size) (i))#define ACPI_TO_INTEGER (p) ACPI_PTR_DIFF (p, (void *) 0) -#define ACPI_OFFSET (d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0) +#define ACPI_OFFSET (d, f) offsetof (d,f)#define ACPI_PHYSADDR_TO_PTR (i) ACPI_TO_POINTER(i)#define ACPI_PTR_TO_PHYSADDR (i) ACPI_TO_INTEGER(i)
LGTM.
Jung-uk Kim
Quoted 29 lines
Quoted 28 lines
The non-kernel runtime of UBSAN would print:
runtime error: member access within null pointer of type for this macro.Cc stable(a)vger.kernel.orgReported-by Will Deacon <will(a)kernel.org>Suggested-by Ard Biesheuvel <ardb(a)kernel.org>Signed-off-by Nick Desaulniers <ndesaulniers(a)google.com>--- include/acpi/actypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/acpi/actypes.h index renamed from include/acpi/actypes.h +0
-0
4defed58ea33..04359c70b198100644include/acpi/actypes.h +1
-2@@ -508,7 +508,7 @@ typedef u64 acpi_integer;#define ACPI_TO_POINTER (i) ACPI_CAST_PTR (void, (acpi_size) (i))#define ACPI_TO_INTEGER (p) ACPI_PTR_DIFF (p, (void *) 0) -#define ACPI_OFFSET (d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0) +#define ACPI_OFFSET (d, f) __builtin_offsetof(d, f)#define ACPI_PHYSADDR_TO_PTR (i) ACPI_TO_POINTER(i)#define ACPI_PTR_TO_PHYSADDR (i) ACPI_TO_INTEGER(i) --2.27.0.rc2.251.g90737beb825-goog
Hi Will,
Quoted 13 lines · Will Deacon
Hi folks,
I just tried booting the arm64 for-kernelci branch under QEMU (version 4.2.50 (v4.2.0-779-g4354edb6dcc7)) with UBSAN enabled, and I see a couple of NULL pointer dereferences reported at boot. I think they're both GIC related (log below). I don't see a panic with UBSAN disabled, so something's fishy here.
Please can you take a look when you get a chance? I haven't had time to see if this is a regression or not, but I don't think it's particularly serious as I have all sorts of horrible stuff enabled in my .config, since I'm trying to chase down another bug:
Quoted 5 lines
(on top of defconfig)
CONFIG_FAIL_PAGE_ALLOCmay be to blame.
I enabled UBSAN and CONFIG_FAIL_PAGE_ALLOC on top of defconfig, testing against the for-kernelci branch on the D06 board, I can see some UBSAN warnings from megaraid_sas driver [0], but not from any other subsystem including ACPI, I will try all your configs above to see if I can get more warnings.
Thanks
Hanjun
[0]:
[ 18.244272] ================================================================================ [ 18.252673] UBSAN: array-index-out-of-bounds in drivers/scsi/megaraid/megaraid_sas_fp.c:104:32 [ 18.261244] index 1 is out of range for type 'MR_LD_SPAN_MAP [1]' [ 18.267313] CPU: 0 PID: 656 Comm: kworker/0:1 Not tainted 5.7.0-rc6-1-14703-gf4582661223d-dirty #20 [ 18.276314] Hardware name: Huawei TaiShan 2280 V2/BC82AMDC, BIOS 2280-V2 CS V3.B210.01 03/12/2020 [ 18.285151] Workqueue: events work_for_cpu_fn [ 18.289488] Call trace: [ 18.291925] dump_backtrace+0x0/0x248 [ 18.295572] show_stack+0x18/0x28 [ 18.298873] dump_stack+0xc0/0x10c [ 18.302261] ubsan_epilogue+0x10/0x58 [ 18.305905] __ubsan_handle_out_of_bounds+0x8c/0xa8 [ 18.310763] mr_update_load_balance_params+0x118/0x120 [ 18.315877] MR_ValidateMapInfo+0x300/0xb00 [ 18.320040] megasas_get_map_info+0x134/0x1f8 [ 18.324377] megasas_init_adapter_fusion+0xba8/0x10a0 [ 18.329403] megasas_probe_one+0x6e0/0x1b70 [ 18.333569] local_pci_probe+0x40/0xb0 [ 18.337299] work_for_cpu_fn+0x1c/0x30 [ 18.341031] process_one_work+0x1f8/0x378 [ 18.345022] worker_thread+0x21c/0x4c0 [ 18.348753] kthread+0x150/0x158 [ 18.351967] ret_from_fork+0x10/0x18 [ 18.355529] ================================================================================
[ 18.592274] ================================================================================ [ 18.600672] UBSAN: array-index-out-of-bounds in drivers/scsi/megaraid/megaraid_sas_fp.c:141:9 [ 18.609155] index 1 is out of range for type 'MR_LD_SPAN_MAP [1]' [ 18.615221] CPU: 0 PID: 656 Comm: kworker/0:1 Not tainted 5.7.0-rc6-1-14703-gf4582661223d-dirty #20 [ 18.624222] Hardware name: Huawei TaiShan 2280 V2/BC82AMDC, BIOS 2280-V2 CS V3.B210.01 03/12/2020 [ 18.633050] Workqueue: events work_for_cpu_fn [ 18.637387] Call trace: [ 18.639822] dump_backtrace+0x0/0x248 [ 18.643467] show_stack+0x18/0x28 [ 18.646767] dump_stack+0xc0/0x10c [ 18.650152] ubsan_epilogue+0x10/0x58 [ 18.653796] __ubsan_handle_out_of_bounds+0x8c/0xa8 [ 18.658652] MR_GetLDTgtId+0x58/0x60 [ 18.662211] megasas_sync_map_info+0xd0/0x1c0 [ 18.666547] megasas_init_adapter_fusion+0xd60/0x10a0 [ 18.671574] megasas_probe_one+0x6e0/0x1b70 [ 18.675736] local_pci_probe+0x40/0xb0 [ 18.679466] work_for_cpu_fn+0x1c/0x30 [ 18.683197] process_one_work+0x1f8/0x378 [ 18.687188] worker_thread+0x21c/0x4c0 [ 18.690920] kthread+0x150/0x158 [ 18.694123] ret_from_fork+0x10/0x18 [ 18.697683] ================================================================================
Quoted 21 lines · Hanjun Guo
Hi Will,
Quoted 18 lines · Will Deacon
Hi folks,
I just tried booting the arm64 for-kernelci branch under QEMU (version 4.2.50 (v4.2.0-779-g4354edb6dcc7)) with UBSAN enabled, and I see a couple of NULL pointer dereferences reported at boot. I think they're both GIC related (log below). I don't see a panic with UBSAN disabled, so something's fishy here.
Please can you take a look when you get a chance? I haven't had time to see if this is a regression or not, but I don't think it's particularly serious as I have all sorts of horrible stuff enabled in my .config, since I'm trying to chase down another bug:
(on top of defconfig)
Quoted 7 lines
Quoted 1 line
CONFIG_FAIL_PAGE_ALLOCmay be to blame.I enabled UBSAN and
CONFIG_FAIL_PAGE_ALLOCon top of defconfig, testing against the for-kernelci branch on the D06 board, I can see some UBSAN warnings frommegaraid_sasdriver [0], but not from any other subsystem including ACPI, I will try all your configs above to see if I can get more warnings.
Enabled all the configs except "CONFIG_MODULES=n" and "CONFIG_SHADOW_CALL_STACK=y" (can't do that via make menuconfig, do it manually?) in the link, but still got the same warnings and no other warnings as before, the system is in good function, please let me know I can do anything more to help the debug.
Thanks
Hanjun