aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-04-17 22:22:50 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2018-04-17 22:22:50 +0200
commit7504c3bf61443f9255b0a0caf310b5300b59b92d (patch)
tree939b6b49b4bfab6a1d9f681469b8ac2b360bfc9f /gcc/builtins.c
parentaa4ec2cdff98cdeec085fa14af4267a51e4e1052 (diff)
downloadgcc-7504c3bf61443f9255b0a0caf310b5300b59b92d.zip
gcc-7504c3bf61443f9255b0a0caf310b5300b59b92d.tar.gz
gcc-7504c3bf61443f9255b0a0caf310b5300b59b92d.tar.bz2
re PR sanitizer/85230 (asan: false positives in kernel on allocas)
PR sanitizer/85230 * asan.c (handle_builtin_stack_restore): Adjust comment. Emit __asan_allocas_unpoison call and last_alloca_addr = new_sp before __builtin_stack_restore rather than after it. * builtins.c (expand_asan_emit_allocas_unpoison): Pass arg1 + (virtual_dynamic_stack_rtx - stack_pointer_rtx) as second argument instead of virtual_dynamic_stack_rtx. From-SVN: r259446
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 93c617e..a71555e 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -5072,18 +5072,24 @@ expand_builtin_alloca (tree exp)
return result;
}
-/* Emit a call to __asan_allocas_unpoison call in EXP. Replace second argument
- of the call with virtual_stack_dynamic_rtx because in asan pass we emit a
- dummy value into second parameter relying on this function to perform the
- change. See motivation for this in comment to handle_builtin_stack_restore
- function. */
+/* Emit a call to __asan_allocas_unpoison call in EXP. Add to second argument
+ of the call virtual_stack_dynamic_rtx - stack_pointer_rtx, which is the
+ STACK_DYNAMIC_OFFSET value. See motivation for this in comment to
+ handle_builtin_stack_restore function. */
static rtx
expand_asan_emit_allocas_unpoison (tree exp)
{
tree arg0 = CALL_EXPR_ARG (exp, 0);
+ tree arg1 = CALL_EXPR_ARG (exp, 1);
rtx top = expand_expr (arg0, NULL_RTX, ptr_mode, EXPAND_NORMAL);
- rtx bot = convert_memory_address (ptr_mode, virtual_stack_dynamic_rtx);
+ rtx bot = expand_expr (arg1, NULL_RTX, ptr_mode, EXPAND_NORMAL);
+ rtx off = expand_simple_binop (Pmode, MINUS, virtual_stack_dynamic_rtx,
+ stack_pointer_rtx, NULL_RTX, 0,
+ OPTAB_LIB_WIDEN);
+ off = convert_modes (ptr_mode, Pmode, off, 0);
+ bot = expand_simple_binop (ptr_mode, PLUS, bot, off, NULL_RTX, 0,
+ OPTAB_LIB_WIDEN);
rtx ret = init_one_libfunc ("__asan_allocas_unpoison");
ret = emit_library_call_value (ret, NULL_RTX, LCT_NORMAL, ptr_mode,
top, ptr_mode, bot, ptr_mode);