VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
ec8f24b7faaf3 (Thomas Gleixner 2019-05-19 13:07:45 +0100   1) # SPDX-License-Identifier: GPL-2.0-only
c6d308534aef6 (Andrey Ryabinin 2016-01-20 15:00:55 -0800   2) config ARCH_HAS_UBSAN_SANITIZE_ALL
c6d308534aef6 (Andrey Ryabinin 2016-01-20 15:00:55 -0800   3) 	bool
c6d308534aef6 (Andrey Ryabinin 2016-01-20 15:00:55 -0800   4) 
277a10850f9f4 (Kees Cook       2020-04-06 20:12:31 -0700   5) menuconfig UBSAN
c6d308534aef6 (Andrey Ryabinin 2016-01-20 15:00:55 -0800   6) 	bool "Undefined behaviour sanity checker"
c6d308534aef6 (Andrey Ryabinin 2016-01-20 15:00:55 -0800   7) 	help
0887a7ebc9777 (Kees Cook       2020-04-06 20:12:27 -0700   8) 	  This option enables the Undefined Behaviour sanity checker.
c6d308534aef6 (Andrey Ryabinin 2016-01-20 15:00:55 -0800   9) 	  Compile-time instrumentation is used to detect various undefined
0887a7ebc9777 (Kees Cook       2020-04-06 20:12:27 -0700  10) 	  behaviours at runtime. For more details, see:
0887a7ebc9777 (Kees Cook       2020-04-06 20:12:27 -0700  11) 	  Documentation/dev-tools/ubsan.rst
0887a7ebc9777 (Kees Cook       2020-04-06 20:12:27 -0700  12) 
277a10850f9f4 (Kees Cook       2020-04-06 20:12:31 -0700  13) if UBSAN
277a10850f9f4 (Kees Cook       2020-04-06 20:12:31 -0700  14) 
0887a7ebc9777 (Kees Cook       2020-04-06 20:12:27 -0700  15) config UBSAN_TRAP
0887a7ebc9777 (Kees Cook       2020-04-06 20:12:27 -0700  16) 	bool "On Sanitizer warnings, abort the running kernel code"
79791378a1bc9 (Kees Cook       2020-12-15 20:46:31 -0800  17) 	depends on !COMPILE_TEST
0887a7ebc9777 (Kees Cook       2020-04-06 20:12:27 -0700  18) 	depends on $(cc-option, -fsanitize-undefined-trap-on-error)
0887a7ebc9777 (Kees Cook       2020-04-06 20:12:27 -0700  19) 	help
0887a7ebc9777 (Kees Cook       2020-04-06 20:12:27 -0700  20) 	  Building kernels with Sanitizer features enabled tends to grow
0887a7ebc9777 (Kees Cook       2020-04-06 20:12:27 -0700  21) 	  the kernel size by around 5%, due to adding all the debugging
0887a7ebc9777 (Kees Cook       2020-04-06 20:12:27 -0700  22) 	  text on failure paths. To avoid this, Sanitizer instrumentation
0887a7ebc9777 (Kees Cook       2020-04-06 20:12:27 -0700  23) 	  can just issue a trap. This reduces the kernel size overhead but
0887a7ebc9777 (Kees Cook       2020-04-06 20:12:27 -0700  24) 	  turns all warnings (including potentially harmless conditions)
0887a7ebc9777 (Kees Cook       2020-04-06 20:12:27 -0700  25) 	  into full exceptions that abort the running kernel code
0887a7ebc9777 (Kees Cook       2020-04-06 20:12:27 -0700  26) 	  (regardless of context, locks held, etc), which may destabilize
0887a7ebc9777 (Kees Cook       2020-04-06 20:12:27 -0700  27) 	  the system. For some system builders this is an acceptable
0887a7ebc9777 (Kees Cook       2020-04-06 20:12:27 -0700  28) 	  trade-off.
c6d308534aef6 (Andrey Ryabinin 2016-01-20 15:00:55 -0800  29) 
ea91a1d45d194 (Arnd Bergmann   2020-05-21 16:20:37 +0200  30) config UBSAN_KCOV_BROKEN
ea91a1d45d194 (Arnd Bergmann   2020-05-21 16:20:37 +0200  31) 	def_bool KCOV && CC_HAS_SANCOV_TRACE_PC
ea91a1d45d194 (Arnd Bergmann   2020-05-21 16:20:37 +0200  32) 	depends on CC_IS_CLANG
ea91a1d45d194 (Arnd Bergmann   2020-05-21 16:20:37 +0200  33) 	depends on !$(cc-option,-Werror=unused-command-line-argument -fsanitize=bounds -fsanitize-coverage=trace-pc)
ea91a1d45d194 (Arnd Bergmann   2020-05-21 16:20:37 +0200  34) 	help
ea91a1d45d194 (Arnd Bergmann   2020-05-21 16:20:37 +0200  35) 	  Some versions of clang support either UBSAN or KCOV but not the
ea91a1d45d194 (Arnd Bergmann   2020-05-21 16:20:37 +0200  36) 	  combination of the two.
ea91a1d45d194 (Arnd Bergmann   2020-05-21 16:20:37 +0200  37) 	  See https://bugs.llvm.org/show_bug.cgi?id=45831 for the status
ea91a1d45d194 (Arnd Bergmann   2020-05-21 16:20:37 +0200  38) 	  in newer releases.
ea91a1d45d194 (Arnd Bergmann   2020-05-21 16:20:37 +0200  39) 
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  40) config CC_HAS_UBSAN_BOUNDS
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  41) 	def_bool $(cc-option,-fsanitize=bounds)
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  42) 
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  43) config CC_HAS_UBSAN_ARRAY_BOUNDS
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  44) 	def_bool $(cc-option,-fsanitize=array-bounds)
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  45) 
277a10850f9f4 (Kees Cook       2020-04-06 20:12:31 -0700  46) config UBSAN_BOUNDS
277a10850f9f4 (Kees Cook       2020-04-06 20:12:31 -0700  47) 	bool "Perform array index bounds checking"
277a10850f9f4 (Kees Cook       2020-04-06 20:12:31 -0700  48) 	default UBSAN
ea91a1d45d194 (Arnd Bergmann   2020-05-21 16:20:37 +0200  49) 	depends on !UBSAN_KCOV_BROKEN
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  50) 	depends on CC_HAS_UBSAN_ARRAY_BOUNDS || CC_HAS_UBSAN_BOUNDS
277a10850f9f4 (Kees Cook       2020-04-06 20:12:31 -0700  51) 	help
277a10850f9f4 (Kees Cook       2020-04-06 20:12:31 -0700  52) 	  This option enables detection of directly indexed out of bounds
277a10850f9f4 (Kees Cook       2020-04-06 20:12:31 -0700  53) 	  array accesses, where the array size is known at compile time.
277a10850f9f4 (Kees Cook       2020-04-06 20:12:31 -0700  54) 	  Note that this does not protect array overflows via bad calls
277a10850f9f4 (Kees Cook       2020-04-06 20:12:31 -0700  55) 	  to the {str,mem}*cpy() family of functions (that is addressed
277a10850f9f4 (Kees Cook       2020-04-06 20:12:31 -0700  56) 	  by CONFIG_FORTIFY_SOURCE).
277a10850f9f4 (Kees Cook       2020-04-06 20:12:31 -0700  57) 
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  58) config UBSAN_ONLY_BOUNDS
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  59) 	def_bool CC_HAS_UBSAN_BOUNDS && !CC_HAS_UBSAN_ARRAY_BOUNDS
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  60) 	depends on UBSAN_BOUNDS
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  61) 	help
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  62) 	  This is a weird case: Clang's -fsanitize=bounds includes
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  63) 	  -fsanitize=local-bounds, but it's trapping-only, so for
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  64) 	  Clang, we must use -fsanitize=array-bounds when we want
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  65) 	  traditional array bounds checking enabled. For GCC, we
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  66) 	  want -fsanitize=bounds.
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  67) 
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  68) config UBSAN_ARRAY_BOUNDS
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  69) 	def_bool CC_HAS_UBSAN_ARRAY_BOUNDS
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  70) 	depends on UBSAN_BOUNDS
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  71) 
6a6155f664e31 (George Popescu  2020-10-15 20:13:38 -0700  72) config UBSAN_LOCAL_BOUNDS
6a6155f664e31 (George Popescu  2020-10-15 20:13:38 -0700  73) 	bool "Perform array local bounds checking"
6a6155f664e31 (George Popescu  2020-10-15 20:13:38 -0700  74) 	depends on UBSAN_TRAP
6a6155f664e31 (George Popescu  2020-10-15 20:13:38 -0700  75) 	depends on !UBSAN_KCOV_BROKEN
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  76) 	depends on $(cc-option,-fsanitize=local-bounds)
6a6155f664e31 (George Popescu  2020-10-15 20:13:38 -0700  77) 	help
6a6155f664e31 (George Popescu  2020-10-15 20:13:38 -0700  78) 	  This option enables -fsanitize=local-bounds which traps when an
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  79) 	  exception/error is detected. Therefore, it may only be enabled
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  80) 	  with CONFIG_UBSAN_TRAP.
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  81) 
6a6155f664e31 (George Popescu  2020-10-15 20:13:38 -0700  82) 	  Enabling this option detects errors due to accesses through a
6a6155f664e31 (George Popescu  2020-10-15 20:13:38 -0700  83) 	  pointer that is derived from an object of a statically-known size,
6a6155f664e31 (George Popescu  2020-10-15 20:13:38 -0700  84) 	  where an added offset (which may not be known statically) is
6a6155f664e31 (George Popescu  2020-10-15 20:13:38 -0700  85) 	  out-of-bounds.
6a6155f664e31 (George Popescu  2020-10-15 20:13:38 -0700  86) 
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  87) config UBSAN_SHIFT
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800  88) 	bool "Perform checking for bit-shift overflows"
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800  89) 	default UBSAN
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  90) 	depends on $(cc-option,-fsanitize=shift)
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800  91) 	help
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800  92) 	  This option enables -fsanitize=shift which checks for bit-shift
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800  93) 	  operations that overflow to the left or go switch to negative
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800  94) 	  for signed types.
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  95) 
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  96) config UBSAN_DIV_ZERO
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800  97) 	bool "Perform checking for integer divide-by-zero"
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800  98) 	depends on $(cc-option,-fsanitize=integer-divide-by-zero)
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800  99) 	help
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 100) 	  This option enables -fsanitize=integer-divide-by-zero which checks
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 101) 	  for integer division by zero. This is effectively redundant with the
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 102) 	  kernel's existing exception handling, though it can provide greater
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 103) 	  debugging information under CONFIG_UBSAN_REPORT_FULL.
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800 104) 
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800 105) config UBSAN_UNREACHABLE
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 106) 	bool "Perform checking for unreachable code"
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 107) 	# objtool already handles unreachable checking and gets angry about
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 108) 	# seeing UBSan instrumentation located in unreachable places.
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 109) 	depends on !STACK_VALIDATION
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800 110) 	depends on $(cc-option,-fsanitize=unreachable)
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 111) 	help
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 112) 	  This option enables -fsanitize=unreachable which checks for control
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 113) 	  flow reaching an expected-to-be-unreachable position.
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800 114) 
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800 115) config UBSAN_OBJECT_SIZE
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 116) 	bool "Perform checking for accesses beyond the end of objects"
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 117) 	default UBSAN
61e0349f703d1 (Kees Cook       2020-12-15 20:46:28 -0800 118) 	# gcc hugely expands stack usage with -fsanitize=object-size
61e0349f703d1 (Kees Cook       2020-12-15 20:46:28 -0800 119) 	# https://lore.kernel.org/lkml/CAHk-=wjPasyJrDuwDnpHJS2TuQfExwe=px-SzLeN8GFMAQJPmQ@mail.gmail.com/
61e0349f703d1 (Kees Cook       2020-12-15 20:46:28 -0800 120) 	depends on !CC_IS_GCC
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800 121) 	depends on $(cc-option,-fsanitize=object-size)
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 122) 	help
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 123) 	  This option enables -fsanitize=object-size which checks for accesses
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 124) 	  beyond the end of objects where the optimizer can determine both the
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 125) 	  object being operated on and its size, usually seen with bad downcasts,
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 126) 	  or access to struct members from NULL pointers.
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800 127) 
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800 128) config UBSAN_BOOL
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 129) 	bool "Perform checking for non-boolean values used as boolean"
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 130) 	default UBSAN
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800 131) 	depends on $(cc-option,-fsanitize=bool)
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 132) 	help
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 133) 	  This option enables -fsanitize=bool which checks for boolean values being
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 134) 	  loaded that are neither 0 nor 1.
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800 135) 
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800 136) config UBSAN_ENUM
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 137) 	bool "Perform checking for out of bounds enum values"
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 138) 	default UBSAN
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800 139) 	depends on $(cc-option,-fsanitize=enum)
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 140) 	help
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 141) 	  This option enables -fsanitize=enum which checks for values being loaded
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 142) 	  into an enum that are outside the range of given values for the given enum.
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 143) 
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 144) config UBSAN_ALIGNMENT
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 145) 	bool "Perform checking for misaligned pointer usage"
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 146) 	default !HAVE_EFFICIENT_UNALIGNED_ACCESS
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 147) 	depends on !UBSAN_TRAP && !COMPILE_TEST
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 148) 	depends on $(cc-option,-fsanitize=alignment)
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 149) 	help
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 150) 	  This option enables the check of unaligned memory accesses.
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 151) 	  Enabling this option on architectures that support unaligned
c637693b20da8 (Kees Cook       2020-12-15 20:46:39 -0800 152) 	  accesses may produce a lot of false positives.
cdf8a76fda4ae (Kees Cook       2020-12-15 20:46:24 -0800 153) 
c6d308534aef6 (Andrey Ryabinin 2016-01-20 15:00:55 -0800 154) config UBSAN_SANITIZE_ALL
c6d308534aef6 (Andrey Ryabinin 2016-01-20 15:00:55 -0800 155) 	bool "Enable instrumentation for the entire kernel"
c6d308534aef6 (Andrey Ryabinin 2016-01-20 15:00:55 -0800 156) 	depends on ARCH_HAS_UBSAN_SANITIZE_ALL
c6d308534aef6 (Andrey Ryabinin 2016-01-20 15:00:55 -0800 157) 	default y
c6d308534aef6 (Andrey Ryabinin 2016-01-20 15:00:55 -0800 158) 	help
c6d308534aef6 (Andrey Ryabinin 2016-01-20 15:00:55 -0800 159) 	  This option activates instrumentation for the entire kernel.
c6d308534aef6 (Andrey Ryabinin 2016-01-20 15:00:55 -0800 160) 	  If you don't enable this option, you have to explicitly specify
c6d308534aef6 (Andrey Ryabinin 2016-01-20 15:00:55 -0800 161) 	  UBSAN_SANITIZE := y for the files/directories you want to check for UB.
7707535ab95e2 (Yang Shi        2016-02-11 16:12:55 -0800 162) 	  Enabling this option will get kernel image size increased
7707535ab95e2 (Yang Shi        2016-02-11 16:12:55 -0800 163) 	  significantly.
c6d308534aef6 (Andrey Ryabinin 2016-01-20 15:00:55 -0800 164) 
854686f4edf48 (Jinbum Park     2018-04-10 16:32:58 -0700 165) config TEST_UBSAN
854686f4edf48 (Jinbum Park     2018-04-10 16:32:58 -0700 166) 	tristate "Module for testing for undefined behavior detection"
277a10850f9f4 (Kees Cook       2020-04-06 20:12:31 -0700 167) 	depends on m
854686f4edf48 (Jinbum Park     2018-04-10 16:32:58 -0700 168) 	help
854686f4edf48 (Jinbum Park     2018-04-10 16:32:58 -0700 169) 	  This is a test module for UBSAN.
854686f4edf48 (Jinbum Park     2018-04-10 16:32:58 -0700 170) 	  It triggers various undefined behavior, and detect it.
277a10850f9f4 (Kees Cook       2020-04-06 20:12:31 -0700 171) 
277a10850f9f4 (Kees Cook       2020-04-06 20:12:31 -0700 172) endif	# if UBSAN