* [PATCH] Fix -fsanitize=address -fstack-protector* (PR sanitizer/88333)
@ 2018-12-04 23:32 Jakub Jelinek
2018-12-05 3:19 ` Jeff Law
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2018-12-04 23:32 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
Hi!
The current asan.c code requires that the whole block of vars starts and
ends on ASAN_RED_ZONE_SIZE (i.e. 32 byte) boundary, so that it is on 4 byte
boundary in the shadow memory. Normally it is, when frame_offset starts at
0, but with -fstack-protector there is the guard above it and in that case
following patch is needed to realign the end of the block.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2018-12-04 Jakub Jelinek <jakub@redhat.com>
PR sanitizer/88333
* cfgexpand.c (expand_stack_vars): If asan_vec is empty, start with
aligning frame offset to ASAN_RED_ZONE_SIZE bytes.
* c-c++-common/asan/pr88333.c: New test.
--- gcc/cfgexpand.c.jj 2018-11-30 19:59:59.676789914 +0100
+++ gcc/cfgexpand.c 2018-12-04 11:25:55.549672029 +0100
@@ -1124,6 +1124,11 @@ expand_stack_vars (bool (*pred) (size_t)
&& frame_offset.is_constant (&prev_offset)
&& stack_vars[i].size.is_constant ())
{
+ if (data->asan_vec.is_empty ())
+ {
+ alloc_stack_frame_space (0, ASAN_RED_ZONE_SIZE);
+ prev_offset = frame_offset.to_constant ();
+ }
prev_offset = align_base (prev_offset,
MAX (alignb, ASAN_MIN_RED_ZONE_SIZE),
!FRAME_GROWS_DOWNWARD);
--- gcc/testsuite/c-c++-common/asan/pr88333.c.jj 2018-12-04 12:14:44.329877625 +0100
+++ gcc/testsuite/c-c++-common/asan/pr88333.c 2018-12-04 12:14:34.804033303 +0100
@@ -0,0 +1,12 @@
+/* PR sanitizer/88333 */
+/* { dg-do compile { target fstack_protector } } */
+/* { dg-options "-fstack-protector-strong -fsanitize=address" } */
+
+void bar (int *);
+
+void
+foo (void)
+{
+ int c;
+ bar (&c);
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix -fsanitize=address -fstack-protector* (PR sanitizer/88333)
2018-12-04 23:32 [PATCH] Fix -fsanitize=address -fstack-protector* (PR sanitizer/88333) Jakub Jelinek
@ 2018-12-05 3:19 ` Jeff Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2018-12-05 3:19 UTC (permalink / raw)
To: Jakub Jelinek, Richard Biener; +Cc: gcc-patches
On 12/4/18 4:32 PM, Jakub Jelinek wrote:
> Hi!
>
> The current asan.c code requires that the whole block of vars starts and
> ends on ASAN_RED_ZONE_SIZE (i.e. 32 byte) boundary, so that it is on 4 byte
> boundary in the shadow memory. Normally it is, when frame_offset starts at
> 0, but with -fstack-protector there is the guard above it and in that case
> following patch is needed to realign the end of the block.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2018-12-04 Jakub Jelinek <jakub@redhat.com>
>
> PR sanitizer/88333
> * cfgexpand.c (expand_stack_vars): If asan_vec is empty, start with
> aligning frame offset to ASAN_RED_ZONE_SIZE bytes.
>
> * c-c++-common/asan/pr88333.c: New test.
OK
jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-12-05 3:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-04 23:32 [PATCH] Fix -fsanitize=address -fstack-protector* (PR sanitizer/88333) Jakub Jelinek
2018-12-05 3:19 ` Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).