History

ubsan: remove CONFIG_UBSAN_OBJECT_SIZE

The object-size sanitizer is redundant to -Warray-bounds, and inappropriately performs its checks at run-time when all information needed for the evaluation is available at compile-time, making it quite difficult to use: https://bugzilla.kernel.org/show_bug.cgi?id=214861 With -Warray-bounds almost enabled globally, it doesn't make sense to keep this around.

Kees Cook committed 4 years ago

Commit 69d0db01 parent bece04b3 files · +0 −36Browse files

Unified · Split

3 files
  1. lib/Kconfig.ubsan +0 −13
  2. lib/test_ubsan.c +0 −22
  3. scripts/Makefile.ubsan +0 −1
lib/Kconfig.ubsan+0−13
@@ -112,19 +112,6 @@ config UBSAN_UNREACHABLE · 111 unmodified lines
112112 This option enables -fsanitize=unreachable which checks for control
113113 flow reaching an expected-to-be-unreachable position.
114114
115−config UBSAN_OBJECT_SIZE
116− bool "Perform checking for accesses beyond the end of objects"
117− default UBSAN
118− # gcc hugely expands stack usage with -fsanitize=object-size
119− # https://lore.kernel.org/lkml/CAHk-=wjPasyJrDuwDnpHJS2TuQfExwe=px-SzLeN8GFMAQJPmQ@mail.gmail.com/
120− depends on !CC_IS_GCC
121− depends on $(cc-option,-fsanitize=object-size)
122− help
123− This option enables -fsanitize=object-size which checks for accesses
124− beyond the end of objects where the optimizer can determine both the
125− object being operated on and its size, usually seen with bad downcasts,
126− or access to struct members from NULL pointers.
127−
128115 config UBSAN_BOOL
129116 bool "Perform checking for non-boolean values used as boolean"
130117 default UBSAN
lib/test_ubsan.c+0−22
@@ -79,15 +79,6 @@ static void test_ubsan_load_invalid_value(void) · 78 unmodified lines
7979 eval2 = eval;
8080 }
8181
82−static void test_ubsan_null_ptr_deref(void)
83−{
84− volatile int *ptr = NULL;
85− int val;
86−
87− UBSAN_TEST(CONFIG_UBSAN_OBJECT_SIZE);
88− val = *ptr;
89−}
90−
9182 static void test_ubsan_misaligned_access(void)
9283 {
9384 volatile char arr[5] __aligned(4) = {1, 2, 3, 4, 5};
@@ -98,29 +89,16 @@ static void test_ubsan_misaligned_access(void) · 4 unmodified lines
9889 *ptr = val;
9990 }
10091
101−static void test_ubsan_object_size_mismatch(void)
102−{
103− /* "((aligned(8)))" helps this not into be misaligned for ptr-access. */
104− volatile int val __aligned(8) = 4;
105− volatile long long *ptr, val2;
106−
107− UBSAN_TEST(CONFIG_UBSAN_OBJECT_SIZE);
108− ptr = (long long *)&val;
109− val2 = *ptr;
110−}
111−
11292 static const test_ubsan_fp test_ubsan_array[] = {
11393 test_ubsan_shift_out_of_bounds,
11494 test_ubsan_out_of_bounds,
11595 test_ubsan_load_invalid_value,
11696 test_ubsan_misaligned_access,
117− test_ubsan_object_size_mismatch,
11897 };
11998
12099 /* Excluded because they Oops the module. */
121100 static const test_ubsan_fp skip_ubsan_array[] = {
122101 test_ubsan_divrem_overflow,
123− test_ubsan_null_ptr_deref,
124102 };
125103
126104 static int __init test_ubsan_init(void)
scripts/Makefile.ubsan+0−1
@@ -8,7 +8,6 @@ ubsan-cflags-$(CONFIG_UBSAN_LOCAL_BOUNDS) += -fsanitize=local-bounds · 7 unmodified lines
88 ubsan-cflags-$(CONFIG_UBSAN_SHIFT) += -fsanitize=shift
99 ubsan-cflags-$(CONFIG_UBSAN_DIV_ZERO) += -fsanitize=integer-divide-by-zero
1010 ubsan-cflags-$(CONFIG_UBSAN_UNREACHABLE) += -fsanitize=unreachable
11−ubsan-cflags-$(CONFIG_UBSAN_OBJECT_SIZE) += -fsanitize=object-size
1211 ubsan-cflags-$(CONFIG_UBSAN_BOOL) += -fsanitize=bool
1312 ubsan-cflags-$(CONFIG_UBSAN_ENUM) += -fsanitize=enum
1413 ubsan-cflags-$(CONFIG_UBSAN_TRAP) += -fsanitize-undefined-trap-on-error

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t