From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 43323 invoked by alias); 23 Nov 2015 07:48:43 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 43295 invoked by uid 89); 23 Nov 2015 07:48:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.7 required=5.0 tests=AWL,BAYES_50,KAM_ASCII_DIVIDERS,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mailout1.w1.samsung.com Received: from mailout1.w1.samsung.com (HELO mailout1.w1.samsung.com) (210.118.77.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 23 Nov 2015 07:48:38 +0000 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NY900FVECCZMR30@mailout1.w1.samsung.com> for gcc-patches@gcc.gnu.org; Mon, 23 Nov 2015 07:48:35 +0000 (GMT) Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 77.C4.16778.3D4C2565; Mon, 23 Nov 2015 07:48:35 +0000 (GMT) Received: from [106.109.128.194] by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NY9001ODCCYKL60@eusync4.samsung.com>; Mon, 23 Nov 2015 07:48:35 +0000 (GMT) Subject: [PATCH 2/2] Libsanitizer merge from upstream r253555. To: Jakub Jelinek , Kostya Serebryany , GCC Patches References: <5652C3E0.4030000@partner.samsung.com> Cc: Yury Gribov , Vyacheslav Barinov , Slava Garbuzov From: Maxim Ostapenko Message-id: <5652C4CE.7020409@partner.samsung.com> Date: Mon, 23 Nov 2015 08:06:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-version: 1.0 In-reply-to: <5652C3E0.4030000@partner.samsung.com> Content-type: multipart/mixed; boundary=------------050002090106060305090802 X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg02645.txt.bz2 This is a multi-part message in MIME format. --------------050002090106060305090802 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 264 This patch reflects to corresponding compiler changes. In particular, it just enables -fsanitize-recover=address switch and migrates two small testcases from upstream. I don't backport other stress tests because they are heavy and have unstable output. -Maxim --------------050002090106060305090802 Content-Type: text/x-patch; name="compiler.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="compiler.diff" Content-length: 5100 gcc/testsuite/ChangeLog: 2015-11-23 Maxim Ostapenko * c-c++-common/asan/halt_on_error-1.c: New test. * c-c++-common/asan/halt_on_error-2.c: Likewise. gcc/ChangeLog: 2015-11-23 Maxim Ostapenko * opts.c (finish_options): Allow -fsanitize-recover=address for userspace sanitization. * asan.c (asan_expand_check_ifn): Redefine recover_p. * doc/invoke.texi (fsanitize-recover): Update documentation. Index: gcc/asan.c =================================================================== --- gcc/asan.c (revision 230597) +++ gcc/asan.c (working copy) @@ -2533,10 +2533,12 @@ { gimple *g = gsi_stmt (*iter); location_t loc = gimple_location (g); + bool recover_p; + if (flag_sanitize & SANITIZE_USER_ADDRESS) + recover_p = (flag_sanitize_recover & SANITIZE_USER_ADDRESS) != 0; + else + recover_p = (flag_sanitize_recover & SANITIZE_KERNEL_ADDRESS) != 0; - bool recover_p - = (flag_sanitize & flag_sanitize_recover & SANITIZE_KERNEL_ADDRESS) != 0; - HOST_WIDE_INT flags = tree_to_shwi (gimple_call_arg (g, 0)); gcc_assert (flags < ASAN_CHECK_LAST); bool is_scalar_access = (flags & ASAN_CHECK_SCALAR_ACCESS) != 0; Index: gcc/doc/invoke.texi =================================================================== --- gcc/doc/invoke.texi (revision 230597) +++ gcc/doc/invoke.texi (working copy) @@ -6111,8 +6111,10 @@ Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}), -@option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero} and -@option{-fsanitize=kernel-address}. For these sanitizers error recovery is turned on by default. +@option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero}, +@option{-fsanitize=kernel-address} and @option{-fsanitize=address}. +For these sanitizers error recovery is turned on by default, except @option{-fsanitize=address}, +for which this feature is experimental. @option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also accepted, the former enables recovery for all sanitizers that support it, the latter disables recovery for all sanitizers that support it. Index: gcc/opts.c =================================================================== --- gcc/opts.c (revision 230597) +++ gcc/opts.c (working copy) @@ -941,11 +941,8 @@ "-fsanitize=address and -fsanitize=kernel-address " "are incompatible with -fsanitize=thread"); - /* Error recovery is not allowed for ASan and TSan. */ + /* Error recovery is not allowed for LSan and TSan. */ - if (opts->x_flag_sanitize_recover & SANITIZE_USER_ADDRESS) - error_at (loc, "-fsanitize-recover=address is not supported"); - if (opts->x_flag_sanitize_recover & SANITIZE_THREAD) error_at (loc, "-fsanitize-recover=thread is not supported"); Index: gcc/testsuite/c-c++-common/asan/halt_on_error-1.c =================================================================== --- gcc/testsuite/c-c++-common/asan/halt_on_error-1.c (revision 0) +++ gcc/testsuite/c-c++-common/asan/halt_on_error-1.c (working copy) @@ -0,0 +1,23 @@ +/* Test recovery mode. */ +/* { dg-do run } */ +/* { dg-options "-fsanitize-recover=address" } */ +/* { dg-set-target-env-var ASAN_OPTIONS "halt_on_error=false" } */ + +#include + +volatile int ten = 10; + +int main() { + char x[10]; + memset(x, 0, 11); + asm volatile ("" : : : "memory"); + volatile int res = x[ten]; + x[ten] = res + 3; + res = x[ten]; + return 0; +} + +/* { dg-output "WRITE of size 11 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r).*" } */ +/* { dg-output "\[^\n\r]*READ of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r).*" } */ +/* { dg-output "\[^\n\r]*WRITE of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r).*" } */ +/* { dg-output "\[^\n\r]*READ of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r).*" } */ Index: gcc/testsuite/c-c++-common/asan/halt_on_error-2.c =================================================================== --- gcc/testsuite/c-c++-common/asan/halt_on_error-2.c (revision 0) +++ gcc/testsuite/c-c++-common/asan/halt_on_error-2.c (working copy) @@ -0,0 +1,24 @@ +/* Test recovery mode. */ +/* { dg-do run } */ +/* { dg-options "-fsanitize-recover=address" } */ +/* { dg-set-target-env-var ASAN_OPTIONS "halt_on_error=true" } */ +/* { dg-shouldfail "asan" } */ + +#include + +volatile int ten = 10; + +int main() { + char x[10]; + memset(x, 0, 11); + asm volatile ("" : : : "memory"); + volatile int res = x[ten]; + x[ten] = res + 3; + res = x[ten]; + return 0; +} + +/* { dg-output "WRITE of size 11 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r).*" } */ +/* { dg-prune-output "\[^\n\r]*READ of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r).*" } */ +/* { dg-prune-output "\[^\n\r]*WRITE of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r).*" } */ +/* { dg-prune-output "\[^\n\r]*READ of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r).*" } */ --------------050002090106060305090802--