From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE018C433EF for ; Mon, 28 Feb 2022 07:37:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233654AbiB1HiZ (ORCPT ); Mon, 28 Feb 2022 02:38:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229882AbiB1HiX (ORCPT ); Mon, 28 Feb 2022 02:38:23 -0500 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E25612B25B; Sun, 27 Feb 2022 23:37:44 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=ashimida@linux.alibaba.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---0V5h6dX7_1646033858; Received: from 192.168.193.153(mailfrom:ashimida@linux.alibaba.com fp:SMTPD_---0V5h6dX7_1646033858) by smtp.aliyun-inc.com(127.0.0.1); Mon, 28 Feb 2022 15:37:40 +0800 Message-ID: <26a0a816-bc3e-2ac0-d773-0819d9f225af@linux.alibaba.com> Date: Sun, 27 Feb 2022 23:37:38 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH] [PATCH v2] AARCH64: Add gcc Shadow Call Stack support Content-Language: en-US To: Miguel Ojeda Cc: Catalin Marinas , Will Deacon , Nathan Chancellor , Nick Desaulniers , Kees Cook , Masahiro Yamada , Thomas Gleixner , Andrew Morton , Mark Rutland , Sami Tolvanen , Nicholas Piggin , Guenter Roeck , Masami Hiramatsu , Miguel Ojeda , Luc Van Oostenryck , Marco Elver , linux-kernel , Linux ARM , llvm@lists.linux.dev, linux-hardening@vger.kernel.org References: <20220225032410.25622-1-ashimida@linux.alibaba.com> From: Dan Li In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/25/22 12:47, Miguel Ojeda wrote: > On Fri, Feb 25, 2022 at 4:24 AM Dan Li wrote: >> >> + - Clang (https://clang.llvm.org/docs/ShadowCallStack.html) >> + - GCC (https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html#Instrumentation-Options) > > Maybe Clang: and GCC: instead of the parenthesis? > Got it. >> +#ifdef CONFIG_SHADOW_CALL_STACK >> +#define __noscs __attribute__((__no_sanitize__("shadow-call-stack"))) >> +#endif > > Since both compilers have it, and I guess the `#ifdef` condition would > work for both, could this be moved into `compiler_types.h` where the > empty `__noscs` definition is, and remove the one from > `compiler-clang.h`? > In the clang documentation I see __has_feature(shadow_call_stack) is used to check if -fsanitize=shadow-call-stack is enabled, so I think maybe it's fine to use "#ifdef CONFIG_SHADOW_CALL_STACK" instead of "#if __has_attribute(__no_sanitize_address__)" here, then move it to `compiler_types.h`. And from the results of my local clang 12 compilation, this doesn't seem to be a problem. Link: https://clang.llvm.org/docs/ShadowCallStack.html#has-feature-shadow-call-stack