-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add additional undefined behaviors #232
Comments
What do you think about |
Should we enable function, vla-bound. How about others ? |
@Dor1s - when you get time, can you add parsing signature+test for vla-bound (don't see in current clusterfuzz code) and then we can enable it here. |
I have a feeling that we treat |
Yes probably, but what about if we skip past the left redzone for a large negative value. We can probably wait on @kcc to respond here if vla-bound is even needed since ASAN should probably catch this. |
I mixed up that with
$ cat vla.cc
int main(int argc, char* argv[]) {
int n = 5;
n -= 10;
int a[n];
return 0;
}
$ clang vla.cc -fsanitize=vla-bound -o vla && ./vla
vla.cc:4:9: runtime error: variable length array bound evaluates to non-positive value -5 ASan doesn't report an attempt to declare an array with a negative size: $ clang vla.cc -fsanitize=address -o vla && ./vla
$ echo $?
0 But reports an attempt to use it, e.g.: $ cat vla.cc
#include <stdio.h>
int main(int argc, char* argv[]) {
int n = 5;
n -= 10;
int a[n];
printf("%i\n", a[0]);
return 0;
}
$ clang vla.cc -fsanitize=address -o vla && ./vla
ASAN:DEADLYSIGNAL
=================================================================
==11176==ERROR: AddressSanitizer: stack-overflow on address 0x7ff9f171d358 (pc 0x0000004ec705 bp 0x7ffdf171d440 sp 0x7ff9f171d360 T0)
#0 0x4ec704 in main (/usr/local/google/home/mmoroz/Projects/clusterfuzz/vla+0x4ec704)
#1 0x7f5b52872f44 in __libc_start_main /build/eglibc-oGUzwX/eglibc-2.19/csu/libc-start.c:287
#2 0x41977b in _start (/usr/local/google/home/mmoroz/Projects/clusterfuzz/vla+0x41977b)
SUMMARY: AddressSanitizer: stack-overflow (/usr/local/google/home/mmoroz/Projects/clusterfuzz/vla+0x4ec704) in main
==11176==ABORTING
$ echo $?
1 |
Hm, strange. The following code: #include <stdio.h>
int main(int argc, char* argv[]) {
int n = 5;
n -= 10;
int a[n];
printf("%lu\n", sizeof(a));
return 0;
} doesn't break with ASan: $ clang vla.cc -g -fsanitize=address -o vla && ASAN_OPTIONS=symbolzie=1 ./vla
17179869164
$ echo $?
0 So probably it makes sense to be added, but +1 to wait for @kcc |
Hm... I've no opinion and no experience with Perhaps it's still worth trying. |
I also thought that it might haave been optimized away, but why it is not omitted when building with UBSan... Ok, let's add it and see if we catch anything unique! |
It seems that declaration of a variable-length array with a negative length ends up as an arbitrary pointer in memory:
mov [rbp+n], 5
mov edi, [rbp+n]
mov esi, edi
mov rcx, rsp
mov [rbp+var_20], rcx
mov [rbp+n], 5
mov edi, [rbp+n]
add edi, 0FFFFFFF6h
mov [rbp+n], edi
mov edi, [rbp+n]
mov esi, edi
mov rcx, rsp
mov [rbp+var_20], rcx Due to that, we should mark |
Thanks Max for adding the parsing signatures, enabled vla-bound in 921f143. |
Enabled object-size in 45d8efa. |
Removing object size due to all targets crashing on WARNING: Failed to find function "__sanitizer_print_stack_trace". SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/local/bin/../include/c++/v1/algorithm:714:10 in |
fyi - 48f8d5e, Enable enabled UBSan builtin, null, returns-nonnull-attribute, and unreachable |
Remaining ones - alignment, full-bounds, pointer-overflow (after that noisy null one is fixed), etc. |
In the benchmark page: 1. Use green if the value in the `Builds` column is `True`. 2. Use red if the value in the `Crashes` or `Bug` columns is `False`.
Current config:
bool,signed-integer-overflow,shift,vptr
The text was updated successfully, but these errors were encountered: