On Fri, May 7, 2021 at 4:59 AM Peter Collingbourne pcc@google.com 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 pcc@google.com
Tested-by: Alexander Potapenko glider@google.com
(also note you are missing the Acked-by: here that Andrey gave)