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

From
Alexander Potapenko <glider@google.com>
Date
2021-05-07 07:16:06
Also in
linux-mm
Reply to
Peter Collingbourne, 2021-05-07
On Fri, May 7, 2021 at 4:59 AM Peter Collingbourne [off-list ref] 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.
Thanks for tracking this down! These crashes have been puzzling me for a while.
These accesses use volatile pointers to char (char *volatile) rather
than the more conventional pointers to volatile char (volatile char *)
because we want to prevent the compiler from making inferences about
the pointer itself (i.e. its array bounds), not the data that it
refers to.
Signed-off-by: Peter Collingbourne <redacted>
Tested-by: Alexander Potapenko <glider@google.com>

(also note you are missing the Acked-by: here that Andrey gave)
Thread (3 messages) 3 messages, 3 authors, last reply 2021-05-07
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help