mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] kasan: Support for r/w instrumentation control
@ 2016-12-13  5:57 Maninder Singh
  2016-12-13  8:58 ` Dmitry Vyukov
  0 siblings, 1 reply; 8+ messages in thread
From: Maninder Singh @ 2016-12-13  5:57 UTC (permalink / raw)
  To: aryabinin, glider, dvyukov, corbet, mmarek, akpm
  Cc: kasan-dev, linux-doc, linux-kernel, linux-kbuild, pankaj.m,
	ajeet.y, Maninder Singh, Vaneet narang

This provide option to control sanity of read and write operations
Both read and write instrumentation increase size of uImage, So using
this option read or write instrumentation can be avoided if not required.
Useful in case of module sanity, using this uImage sanity can be avoided.

Also user space ASAN provides this support for read/write instrumentation
control.

Signed-off-by: Vaneet narang <v.narang@samsung.com>
Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Reviewed-by: Ajeet Yadav <ajeet.y@samsung.com>
---
v1 -> v2: Added Documentation for the same.

 Documentation/dev-tools/kasan.rst | 16 ++++++++++++++++
 lib/Kconfig.kasan                 | 16 ++++++++++++++++
 scripts/Makefile.kasan            |  4 ++++
 3 files changed, 36 insertions(+)

diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst
index f7a18f2..b8147df 100644
--- a/Documentation/dev-tools/kasan.rst
+++ b/Documentation/dev-tools/kasan.rst
@@ -40,6 +40,22 @@ similar to the following to the respective kernel Makefile:
 
     KASAN_SANITIZE := n
 
+Control Over Read/Write Instrumentation of kernel::
+
+- To Disable Read Instrumentation of kernel with:
+
+    CONFIG_KASAN_READS = n
+
+Because in some cases we need to check only memory write sanitization
+for better performance, read instrumentation can be disabled.
+
+- To Disable Write Instrumentation of kernel with:
+
+    CONFIG_KASAN_WRITES = n
+
+In case when to instrument only external modules, not the entire kernel
+for read or write intrumentation or both.
+
 Error reports
 ~~~~~~~~~~~~~
 
diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan
index bd38aab..37d1de9 100644
--- a/lib/Kconfig.kasan
+++ b/lib/Kconfig.kasan
@@ -45,6 +45,22 @@ config KASAN_INLINE
 
 endchoice
 
+config KASAN_READS
+	prompt "Read instrumentation"
+	bool
+	default y
+	depends on KASAN
+	help
+	  This configuration controls the sanity of memory read.
+
+config KASAN_WRITES
+	prompt "Write instrumentation"
+	bool
+	default y
+	depends on KASAN
+	help
+	  This configuration controls the sanity of memory write.
+
 config TEST_KASAN
 	tristate "Module for testing kasan for bug detection"
 	depends on m && KASAN
diff --git a/scripts/Makefile.kasan b/scripts/Makefile.kasan
index 37323b0..a61b18e 100644
--- a/scripts/Makefile.kasan
+++ b/scripts/Makefile.kasan
@@ -29,3 +29,7 @@ else
     endif
 endif
 endif
+
+CFLAGS_KASAN += $(call cc-option, \
+		$(if $(CONFIG_KASAN_READS),, --param asan-instrument-reads=0) \
+		$(if $(CONFIG_KASAN_WRITES),, --param asan-instrument-writes=0))
-- 
1.9.1

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

end of thread, other threads:[~2016-12-16 10:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-13  5:57 [PATCH v2] kasan: Support for r/w instrumentation control Maninder Singh
2016-12-13  8:58 ` Dmitry Vyukov
2016-12-13  9:20   ` Andrey Ryabinin
2016-12-13  9:38     ` Dmitry Vyukov
2016-12-13 13:59       ` Andrey Ryabinin
2016-12-13 14:13         ` Dmitry Vyukov
2016-12-13 15:29           ` Andrey Ryabinin
     [not found]           ` <CGME20161213152904epcas3p15f600392fd9f54fe1f68ed9f87d9f03b@epcas3p1.samsung.com>
     [not found]             ` <20161216102902epcms5p1acc3482dea59a0eb85523ed082a31841@epcms5p1>
2016-12-16 10:46               ` Dmitry Vyukov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®