# Re: \[PATCH\] ACPICA: fix UBSAN warning using \_\_builtin\_offsetof

- From: Nick Desaulniers \<ndesaulniers@google.com\>
- Date: 2020-06-01 23:48:44 
- List: linux-arm-kernel
- Page: https://ratatoskr.run/linux-arm-kernel/2020/06/5986540
- Thread: https://ratatoskr.run/linux-arm-kernel/2020/05/5973580/t.md

```text
On Mon, Jun 1, 2020 at 4:37 PM Peter Collingbourne [ref] wrote:
>
> On Mon, Jun 1, 2020 at 4:18 PM Nick Desaulniers [ref] wrote:
> >
> > 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.
>
> 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.
-- 
Thanks,
~Nick Desaulniers

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
```
