Re: [PATCH] kasan: fix unit tests with CONFIG_UBSAN_LOCAL_BOUNDS enabled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, May 8, 2021 at 5:30 PM Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Thu,  6 May 2021 14:20:25 -0700 Peter Collingbourne <pcc@xxxxxxxxxx> wrote:
>
> > These tests deliberately access these arrays out of bounds,
> > which will cause the dynamic local bounds checks inserted by
> > CONFIG_UBSAN_LOCAL_BOUNDS to fail and panic the kernel. To avoid this
> > problem, access the arrays via volatile pointers, which will prevent
> > the compiler from being able to determine the array bounds.
>
> Huh.  Is this use of volatile the official way of suppressing the
> generation of the checking code or is it just something which happened
> to work?  I'm wondering if this workaround should be formalized in some
> fashion (presumably a wrapper) rather than mysteriously and
> unexplainedly open-coding it like this.

I would consider it the official way in the sense that the compiler
must assume that the pointer that it loads from the address of "array"
has an arbitrary value due to the volatile qualifier, and the array
bounds stuff follows from that. Actually I don't think the compiler is
powerful enough yet to look through the store and load of "array", but
if it were, I think that would be the right way to suppress the
analysis.

Is the comment that I added in v2 not enough here?

Peter




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux