Skip to content

Commit

Permalink
x86: Suppress KMSAN reports in arch_within_stack_frames()
Browse files Browse the repository at this point in the history
arch_within_stack_frames() performs stack walking and may confuse
KMSAN by stepping on stale shadow values. To prevent false positive
reports, disable KMSAN checks in this function.

This fixes KMSAN's interoperability with CONFIG_HARDENED_USERCOPY.

Signed-off-by: Alexander Potapenko <[email protected]>
Signed-off-by: Dave Hansen <[email protected]>
Tested-by: Eric Biggers <[email protected]>
Link: google/kmsan#89
Link: https://lore.kernel.org/lkml/[email protected]/
Link: https://lore.kernel.org/all/20221118172305.3321253-1-glider%40google.com
  • Loading branch information
ramosian-glider authored and hansendc committed Jan 27, 2023
1 parent 6be9a8f commit ce3ba2a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions arch/x86/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@ struct thread_info {
* GOOD_FRAME if within a frame
* BAD_STACK if placed across a frame boundary (or outside stack)
* NOT_STACK unable to determine (no frame pointers, etc)
*
* This function reads pointers from the stack and dereferences them. The
* pointers may not have their KMSAN shadow set up properly, which may result
* in false positive reports. Disable instrumentation to avoid those.
*/
__no_kmsan_checks
static inline int arch_within_stack_frames(const void * const stack,
const void * const stackend,
const void *obj, unsigned long len)
Expand Down

0 comments on commit ce3ba2a

Please sign in to comment.