From patchwork Fri Jan 13 09:01:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Ostapenko X-Patchwork-Id: 91290 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp93197qgi; Fri, 13 Jan 2017 01:02:32 -0800 (PST) X-Received: by 10.99.158.18 with SMTP id s18mr22908284pgd.88.1484298152214; Fri, 13 Jan 2017 01:02:32 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id s10si12082276pgn.194.2017.01.13.01.02.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jan 2017 01:02:32 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-446052-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-446052-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-446052-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:cc:from:message-id:date:mime-version:in-reply-to :content-type:references; q=dns; s=default; b=CgUZnGYzwSDW0LD4IU 2fjkm72wlHTZU6tBzBKDV3Q5zTEGt0Ec5pWUV8za8A8sWLi5EA2BFEmxtVJHCfIl LFWMiwu9xU1hlI8jbUGD78XK+wxUTm7tHGZwusRsb2piHVcvmdIBbYa1vS2X35KO 0rE+fwZHZfx1Y2ot/nqZFv6LE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:cc:from:message-id:date:mime-version:in-reply-to :content-type:references; s=default; bh=SCKnL6O96cjNNGZrkK41ZIc2 o6k=; b=TySZ6cJDAQkjHVClRU+oU8MMybNxnGa6u4xWLMfxNlI8AGsxZY2LqPUd D5/Bzr7ISsCApsWuxpjd7ED9QYoUH21NcOadmbSuV0a7B6d0noDnhu5Noe8e1ZWJ MhIdfbHmps4P7LKJCGkrdPTLUrglidcbpq1umIOd2btySbiqB0o= Received: (qmail 32927 invoked by alias); 13 Jan 2017 09:02:18 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 32898 invoked by uid 89); 13 Jan 2017 09:02:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Kernel, Hx-languages-length:2811, HContent-type:multipart, HContent-type:boundary X-HELO: mailout2.w1.samsung.com Received: from mailout2.w1.samsung.com (HELO mailout2.w1.samsung.com) (210.118.77.12) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 13 Jan 2017 09:02:06 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OJP004T1NRFI050@mailout2.w1.samsung.com> for gcc-patches@gcc.gnu.org; Fri, 13 Jan 2017 09:02:03 +0000 (GMT) Received: from eusmges3.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170113090202eucas1p2a86cf247c2790158e9408b5efdc65fdc~ZSUdIEKxQ1943219432eucas1p2J; Fri, 13 Jan 2017 09:02:02 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3.samsung.com (EUCPMTA) with SMTP id A5.3B.09557.88798785; Fri, 13 Jan 2017 09:02:00 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170113090200eucas1p1eaf95d5ba2ea8761cfb1bed97e7a9c20~ZSUbBxOne2401924019eucas1p1z; Fri, 13 Jan 2017 09:02:00 +0000 (GMT) Received: from eusync2.samsung.com ( [203.254.199.212]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id B3.EB.06687.DB798785; Fri, 13 Jan 2017 09:02:53 +0000 (GMT) Received: from [106.109.129.18] by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OJP00BSGNRBNA60@eusync2.samsung.com>; Fri, 13 Jan 2017 09:02:00 +0000 (GMT) Subject: Re: [PATCH][PR sanitizer/78887] Don't emit ODR indicators if -fsanitize=kernel-address is present. To: Jakub Jelinek Cc: GCC Patches From: Maxim Ostapenko Message-id: <58789782.1050809@samsung.com> Date: Fri, 13 Jan 2017 12:01:54 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-version: 1.0 In-reply-to: <20170113082439.GH21933@tucnak> Content-type: multipart/mixed; boundary=------------080801050203090105040806 X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170113090200eucas1p1eaf95d5ba2ea8761cfb1bed97e7a9c20 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?TWFrc2ltIE9zdGFwZW5rbxtTUlItU1cgVG9vbHMgTGFiGw==?= =?UTF-8?B?7IK87ISx7KCE7J6QG0VuZ2luZWVy?= X-Global-Sender: =?UTF-8?B?TWF4aW0gT3N0YXBlbmtvG1NSUi1TVyBUb29scyBMYWIbU2Ft?= =?UTF-8?B?c3VuZ8KgRWxlY3Ryb25pY3MbRW5naW5lZXI=?= X-Sender-Code: =?UTF-8?B?QzEwG0NJU0hRG0MxMEdEMDFHRDAxMDE1Nw==?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170113081926eucas1p2182a7b44313074dab4efc7d75d2362e2 X-RootMTR: 20170113081926eucas1p2182a7b44313074dab4efc7d75d2362e2 References: <58788D87.7040104@samsung.com> <20170113082439.GH21933@tucnak> X-IsSubscribed: yes On 13/01/17 11:24, Jakub Jelinek wrote: > On Fri, Jan 13, 2017 at 11:19:19AM +0300, Maxim Ostapenko wrote: >> as mentioned in PR, Linux kernel 4.9 fails to build with ASan due to wrong >> handling of emitted ODR indicator symbols. Although this might be a kernel >> bug (relying on specific pattern in symbol name sounds questionable), kernel >> doesn't need ODR indicators at all thus we can just disable them if >> -fsanitize=kernel-address is present. >> Tested on x86_64-unknown-linux-gnu, OK for trunk? >> gcc/ChangeLog: >> >> 2017-01-13 Maxim Ostapenko >> >> PR sanitizer/78887 >> * asan.c (asan_needs_odr_indicator_p): Don't emit ODR indicators >> if -fsanitize=kernel-address is present. >> >> diff --git a/gcc/asan.c b/gcc/asan.c >> index bc7ebc8..157d468 100644 >> --- a/gcc/asan.c >> +++ b/gcc/asan.c >> @@ -2360,7 +2360,8 @@ create_odr_indicator (tree decl, tree type) >> static bool >> asan_needs_odr_indicator_p (tree decl) >> { >> - return !DECL_ARTIFICIAL (decl) && !DECL_WEAK (decl) && TREE_PUBLIC (decl); >> + return !(flag_sanitize & SANITIZE_KERNEL_ADDRESS) && !DECL_ARTIFICIAL (decl) >> + && !DECL_WEAK (decl) && TREE_PUBLIC (decl); > As the condition is longer than a line, please use > return (!(flag_sanitize & SANITIZE_KERNEL_ADDRESS) > && !DECL_ARTIFICIAL (decl) > && !DECL_WEAK (decl) > && TREE_PUBLIC (decl)); > instead (i.e. one sub-condition per line, and ()s around the whole > condition. Perhaps a short comment why we don't emit those for > -fsanitize=kernel-address would be useful too. > > Ok for trunk with those changes. OK, thanks, I'm going to apply following patch. -Maxim > > Jakub > > gcc/ChangeLog: 2017-01-13 Maxim Ostapenko PR sanitizer/78887 * asan.c (asan_needs_odr_indicator_p): Don't emit ODR indicators if -fsanitize=kernel-address is present. diff --git a/gcc/asan.c b/gcc/asan.c index bc7ebc8..e3bf16d 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -2360,7 +2360,16 @@ create_odr_indicator (tree decl, tree type) static bool asan_needs_odr_indicator_p (tree decl) { - return !DECL_ARTIFICIAL (decl) && !DECL_WEAK (decl) && TREE_PUBLIC (decl); + /* Don't emit ODR indicators for kernel because: + a) Kernel is written in C thus doesn't need ODR indicators. + b) Some kernel code may have assumptions about symbols containing specific + patterns in their names. Since ODR indicators contain original names + of symbols they are emmitted for, these assumptions would be broken for + ODR indicator symbols. */ + return (!(flag_sanitize & SANITIZE_KERNEL_ADDRESS) + && !DECL_ARTIFICIAL (decl) + && !DECL_WEAK (decl) + && TREE_PUBLIC (decl)); } /* Append description of a single global DECL into vector V.