linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/2] Fix some incompatibilites between KASAN and FORTIFY_SOURCE
@ 2020-04-24 14:55 Daniel Axtens
  2020-04-24 14:55 ` [PATCH v4 1/2] kasan: stop tests being eliminated as dead code with FORTIFY_SOURCE Daniel Axtens
  2020-04-24 14:55 ` [PATCH v4 2/2] string.h: fix incompatibility between FORTIFY_SOURCE and KASAN Daniel Axtens
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Axtens @ 2020-04-24 14:55 UTC (permalink / raw)
  To: linux-kernel, linux-mm, akpm, kasan-dev
  Cc: dvyukov, christophe.leroy, Daniel Axtens

3 KASAN self-tests fail on a kernel with both KASAN and FORTIFY_SOURCE:
memchr, memcmp and strlen. I have observed this on x86 and powerpc.

When FORTIFY_SOURCE is on, a number of functions are replaced with
fortified versions, which attempt to check the sizes of the
operands. However, these functions often directly invoke __builtin_foo()
once they have performed the fortify check.

This breaks things in 2 ways:

 - the three function calls are technically dead code, and can be
   eliminated. When __builtin_ versions are used, the compiler can detect
   this.

 - Using __builtins may bypass KASAN checks if the compiler decides to
   inline it's own implementation as sequence of instructions, rather than
   emit a function call that goes out to a KASAN-instrumented
   implementation.

The patches address each reason in turn.

v4: Drop patch 3, it turns out I created that issue in patch 1!
    Include David's Tested-by.

v3: resend with Reviewed-bys, hopefully for inclusion in 5.8.

v2: - some cleanups, don't mess with arch code as I missed some wrinkles.
    - add stack array init (patch 3)

Daniel Axtens (2):
  kasan: stop tests being eliminated as dead code with FORTIFY_SOURCE
  string.h: fix incompatibility between FORTIFY_SOURCE and KASAN

 include/linux/string.h | 60 +++++++++++++++++++++++++++++++++---------
 lib/test_kasan.c       | 29 +++++++++++++-------
 2 files changed, 67 insertions(+), 22 deletions(-)

-- 
2.20.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-04-24 14:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-24 14:55 [PATCH v4 0/2] Fix some incompatibilites between KASAN and FORTIFY_SOURCE Daniel Axtens
2020-04-24 14:55 ` [PATCH v4 1/2] kasan: stop tests being eliminated as dead code with FORTIFY_SOURCE Daniel Axtens
2020-04-24 14:55 ` [PATCH v4 2/2] string.h: fix incompatibility between FORTIFY_SOURCE and KASAN Daniel Axtens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).