mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-09 23:39:18 +00:00
7d8ad890da
Patch series "mm/kasan: Add object validation in ksize()", v3. This patch (of 5): This introduces __kasan_check_{read,write}. __kasan_check functions may be used from anywhere, even compilation units that disable instrumentation selectively. This change eliminates the need for the __KASAN_INTERNAL definition. [elver@google.com: v5] Link: http://lkml.kernel.org/r/20190708170706.174189-2-elver@google.com Link: http://lkml.kernel.org/r/20190626142014.141844-2-elver@google.com Signed-off-by: Marco Elver <elver@google.com> Acked-by: Mark Rutland <mark.rutland@arm.com> Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Alexander Potapenko <glider@google.com> Cc: Andrey Konovalov <andreyknvl@google.com> Cc: Christoph Lameter <cl@linux.com> Cc: Pekka Enberg <penberg@kernel.org> Cc: David Rientjes <rientjes@google.com> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: Kees Cook <keescook@chromium.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
35 lines
1.1 KiB
C
35 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _LINUX_KASAN_CHECKS_H
|
|
#define _LINUX_KASAN_CHECKS_H
|
|
|
|
/*
|
|
* __kasan_check_*: Always available when KASAN is enabled. This may be used
|
|
* even in compilation units that selectively disable KASAN, but must use KASAN
|
|
* to validate access to an address. Never use these in header files!
|
|
*/
|
|
#ifdef CONFIG_KASAN
|
|
void __kasan_check_read(const volatile void *p, unsigned int size);
|
|
void __kasan_check_write(const volatile void *p, unsigned int size);
|
|
#else
|
|
static inline void __kasan_check_read(const volatile void *p, unsigned int size)
|
|
{ }
|
|
static inline void __kasan_check_write(const volatile void *p, unsigned int size)
|
|
{ }
|
|
#endif
|
|
|
|
/*
|
|
* kasan_check_*: Only available when the particular compilation unit has KASAN
|
|
* instrumentation enabled. May be used in header files.
|
|
*/
|
|
#ifdef __SANITIZE_ADDRESS__
|
|
#define kasan_check_read __kasan_check_read
|
|
#define kasan_check_write __kasan_check_write
|
|
#else
|
|
static inline void kasan_check_read(const volatile void *p, unsigned int size)
|
|
{ }
|
|
static inline void kasan_check_write(const volatile void *p, unsigned int size)
|
|
{ }
|
|
#endif
|
|
|
|
#endif
|