forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kasan: add CONFIG_KASAN_GENERIC and CONFIG_KASAN_SW_TAGS
This commit splits the current CONFIG_KASAN config option into two: 1. CONFIG_KASAN_GENERIC, that enables the generic KASAN mode (the one that exists now); 2. CONFIG_KASAN_SW_TAGS, that enables the software tag-based KASAN mode. The name CONFIG_KASAN_SW_TAGS is chosen as in the future we will have another hardware tag-based KASAN mode, that will rely on hardware memory tagging support in arm64. With CONFIG_KASAN_SW_TAGS enabled, compiler options are changed to instrument kernel files with -fsantize=kernel-hwaddress (except the ones for which KASAN_SANITIZE := n is set). Both CONFIG_KASAN_GENERIC and CONFIG_KASAN_SW_TAGS support both CONFIG_KASAN_INLINE and CONFIG_KASAN_OUTLINE instrumentation modes. This commit also adds empty placeholder (for now) implementation of tag-based KASAN specific hooks inserted by the compiler and adjusts common hooks implementation. While this commit adds the CONFIG_KASAN_SW_TAGS config option, this option is not selectable, as it depends on HAVE_ARCH_KASAN_SW_TAGS, which we will enable once all the infrastracture code has been added. Link: http://lkml.kernel.org/r/b2550106eb8a68b10fefbabce820910b115aa853.1544099024.git.andreyknvl@google.com Signed-off-by: Andrey Konovalov <[email protected]> Reviewed-by: Andrey Ryabinin <[email protected]> Reviewed-by: Dmitry Vyukov <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Will Deacon <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
- Loading branch information
Showing
11 changed files
with
214 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* This file contains core KASAN code. | ||
* This file contains core generic KASAN code. | ||
* | ||
* Copyright (c) 2014 Samsung Electronics Co., Ltd. | ||
* Author: Andrey Ryabinin <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* This file contains core tag-based KASAN code. | ||
* | ||
* Copyright (c) 2018 Google, Inc. | ||
* Author: Andrey Konovalov <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
* | ||
*/ | ||
|
||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
#define DISABLE_BRANCH_PROFILING | ||
|
||
#include <linux/export.h> | ||
#include <linux/interrupt.h> | ||
#include <linux/init.h> | ||
#include <linux/kasan.h> | ||
#include <linux/kernel.h> | ||
#include <linux/kmemleak.h> | ||
#include <linux/linkage.h> | ||
#include <linux/memblock.h> | ||
#include <linux/memory.h> | ||
#include <linux/mm.h> | ||
#include <linux/module.h> | ||
#include <linux/printk.h> | ||
#include <linux/random.h> | ||
#include <linux/sched.h> | ||
#include <linux/sched/task_stack.h> | ||
#include <linux/slab.h> | ||
#include <linux/stacktrace.h> | ||
#include <linux/string.h> | ||
#include <linux/types.h> | ||
#include <linux/vmalloc.h> | ||
#include <linux/bug.h> | ||
|
||
#include "kasan.h" | ||
#include "../slab.h" | ||
|
||
void check_memory_region(unsigned long addr, size_t size, bool write, | ||
unsigned long ret_ip) | ||
{ | ||
} | ||
|
||
#define DEFINE_HWASAN_LOAD_STORE(size) \ | ||
void __hwasan_load##size##_noabort(unsigned long addr) \ | ||
{ \ | ||
} \ | ||
EXPORT_SYMBOL(__hwasan_load##size##_noabort); \ | ||
void __hwasan_store##size##_noabort(unsigned long addr) \ | ||
{ \ | ||
} \ | ||
EXPORT_SYMBOL(__hwasan_store##size##_noabort) | ||
|
||
DEFINE_HWASAN_LOAD_STORE(1); | ||
DEFINE_HWASAN_LOAD_STORE(2); | ||
DEFINE_HWASAN_LOAD_STORE(4); | ||
DEFINE_HWASAN_LOAD_STORE(8); | ||
DEFINE_HWASAN_LOAD_STORE(16); | ||
|
||
void __hwasan_loadN_noabort(unsigned long addr, unsigned long size) | ||
{ | ||
} | ||
EXPORT_SYMBOL(__hwasan_loadN_noabort); | ||
|
||
void __hwasan_storeN_noabort(unsigned long addr, unsigned long size) | ||
{ | ||
} | ||
EXPORT_SYMBOL(__hwasan_storeN_noabort); | ||
|
||
void __hwasan_tag_memory(unsigned long addr, u8 tag, unsigned long size) | ||
{ | ||
} | ||
EXPORT_SYMBOL(__hwasan_tag_memory); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.