public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: "Martin Liška" <mliska@suse.cz>
Cc: gcc-patches@gcc.gnu.org, arnd@linaro.org
Subject: [PATCH] Partial fix for asan on big endian targets (PR sanitizer/88289)
Date: Sat, 01 Dec 2018 07:36:00 -0000	[thread overview]
Message-ID: <20181201073641.GL12380@tucnak> (raw)
In-Reply-To: <76d386fe-68a5-068c-111c-d3d5dc7a8b32@suse.cz>

On Fri, Nov 30, 2018 at 12:44:04PM +0100, Martin Liška wrote:
> Ok, I'm sending updated version of the patch. I factored out the shadow memory
> byte emission into a class, it's responsible for underlying flushing and guarantees
> that stores are 4B aligned (when beginning of stack vars is properly aligned
> to ASAN_RED_ZONE_SIZE).
> 
> So far I tested the patch on x86_64-linux-gnu and ppc64le-linux-gnu machine.

The patch broke most of the asan tests on powerpc64-linux unfortunately,
sorry for not catching it during patch review.

The following patch fixes most of them, bootstrapped/regtested on
powerpc64-linux, committed to trunk as obvious.

I'm still seeing some regressions, ICEs like:
FAIL: c-c++-common/asan/clone-test-1.c   -O1  (internal compiler error)
FAIL: c-c++-common/asan/clone-test-1.c   -O1  (test for excess errors)
Excess errors:
during RTL pass: expand
/home/jakub/gcc2/gcc/testsuite/c-c++-common/asan/clone-test-1.c:25:5: internal compiler error: in asan_clear_shadow, at asan.c:1181
0x10c52833 asan_clear_shadow
        ../../gcc/asan.c:1181
0x10c618b7 asan_emit_stack_protection(rtx_def*, rtx_def*, unsigned int, long*, tree_node**, int)
        ../../gcc/asan.c:1676
0x10621fe7 expand_used_vars
        ../../gcc/cfgexpand.c:2277
0x1062708f execute
        ../../gcc/cfgexpand.c:6338
That is
  gcc_assert ((len & 3) == 0);
To be debugged later.

2018-12-01  Jakub Jelinek  <jakub@redhat.com>

	PR sanitizer/88289
	* asan.c (asan_redzone_buffer::flush_redzone_payload): Fix up
	an off-by-one for BYTES_BIG_ENDIAN.

--- gcc/asan.c.jj	2018-11-30 19:59:59.675789930 +0100
+++ gcc/asan.c	2018-11-30 23:19:55.336780260 +0100
@@ -1326,7 +1326,7 @@ asan_redzone_buffer::flush_redzone_paylo
   for (unsigned i = 0; i < RZ_BUFFER_SIZE; i++)
     {
       unsigned char v
-	= m_shadow_bytes[BYTES_BIG_ENDIAN ? RZ_BUFFER_SIZE - i : i];
+	= m_shadow_bytes[BYTES_BIG_ENDIAN ? RZ_BUFFER_SIZE - i - 1 : i];
       val |= (unsigned HOST_WIDE_INT)v << (BITS_PER_UNIT * i);
       if (dump_file && (dump_flags & TDF_DETAILS))
 	fprintf (dump_file, "%02x ", v);


	Jakub

  parent reply	other threads:[~2018-12-01  7:36 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-25  9:05 [PATCH] Come up with --param asan-stack-small-redzone (PR sanitizer/81715) Martin Liška
2018-09-25  9:49 ` Jakub Jelinek
2018-09-25 10:17   ` Martin Liška
2018-09-25 10:25     ` Martin Liška
2018-09-25 12:19     ` Jakub Jelinek
2018-09-25 15:40       ` Martin Liška
2018-09-25 15:55         ` Jakub Jelinek
2018-09-26  9:34           ` Martin Liška
2018-10-09  8:53             ` Martin Liška
2018-10-23  9:17               ` Martin Liška
2018-11-13  7:50                 ` Martin Liška
2018-11-28 12:01             ` Jakub Jelinek
2018-11-29 15:03               ` Martin Liška
2018-11-29 15:17                 ` Jakub Jelinek
2018-11-29 16:37                   ` Martin Liška
2018-11-29 16:50                     ` Jakub Jelinek
2018-11-30 11:44                       ` Martin Liška
2018-11-30 12:01                         ` Jakub Jelinek
2018-12-01  7:36                         ` Jakub Jelinek [this message]
2018-12-02 12:46                           ` [committed] Fix ICE in asan_clear_shadow (PR sanitizer/88291) Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181201073641.GL12380@tucnak \
    --to=jakub@redhat.com \
    --cc=arnd@linaro.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mliska@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).