-
Notifications
You must be signed in to change notification settings - Fork 12.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
Sanitizer pointer-overflow
does not appear to function
#66451
Comments
@llvm/issue-subscribers-clang-codegen
Using `-fsanitize=pointer-overflow` doesn't appear to provide any checking on pointer math. GCC's implementation correctly triggers if `NULL` is operated on or if a value would wrap around.
https://godbolt.org/z/1c6ec9TTP
Clang just shows the value wrapping:
But GCC will catch it:
|
It seems like this sanitizer currently only works on pointer arithmetic in the form of |
@nikic Seems to only be the case for What is going on here? This is the case from clang5 (when it was introduced) to trunk. |
Good point, that makes the cause pretty obvious: llvm-project/clang/lib/CodeGen/CGExprScalar.cpp Lines 3723 to 3735 in 3f8d4a8
The void pointer case is handled separately and fails to call EmitCheckedInBoundsGEP. |
Pointer arithmetic on void pointers (a GNU extension) was going through a different code path and bypassed the pointer-overflow sanitizer. Fixes llvm#66451.
Pointer arithmetic on void pointers (a GNU extension) was going through a different code path and bypassed the pointer-overflow sanitizer. Fixes #66451.
Thanks for looking at and fixing this! |
Using
-fsanitize=pointer-overflow
doesn't appear to provide any checking on pointer math. GCC's implementation correctly triggers ifNULL
is operated on or if a value would wrap around.https://godbolt.org/z/1c6ec9TTP
Clang just shows the value wrapping:
But GCC will catch it:
The text was updated successfully, but these errors were encountered: