Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp481030pxm; Wed, 23 Feb 2022 04:52:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8XujzD51YoAELX1HsdJPqwF1oo+IKjc1LjEDvKNowiEONQP7390lzATTCY/IrfmhH7OHE X-Received: by 2002:a17:90b:ecf:b0:1bc:232d:a87d with SMTP id gz15-20020a17090b0ecf00b001bc232da87dmr9013375pjb.27.1645620758132; Wed, 23 Feb 2022 04:52:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645620758; cv=none; d=google.com; s=arc-20160816; b=b/8Sz9Q+a5iGvylZj3tWX2qQBqHnUgI4KAU2t9WjqzEoSiyExcR0+N7XXWOK1qs6yf fGJDLkfrS5jNGZLw0xwJYvEaxC4N+6WSKM0Lw3XO0T9X6d6ikcq5G2slhENzQCv7Do2m 28dO7h1rdIcoszwEtBlQHTcTWyLnDcIEtL2wC8FAV4aRyHvSyrrGBeehO6c+UVV9YJ7x g2udpWD4iBic4+K4Ptuimea4oHMyLwzhDZSxRmTBrsO9C6EdYclWL++vs0igvuobLqk2 SIjXLCo6dytNgI0sCpf022xIpct8MpwD0iRiXCKtP0lSzdTLSLMQ7Z6tRK+5GGVKEEFa Jl3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=7zsIyFyhALDLHykGAWfcwi5EsLTKSKMVlG0TpIRsYn0=; b=R0GN/+dnMP+pt9ULtMsxb1fFAkAJwjNFLZGgq+2xEexIA8kXv+oMS5RgFRh0uuIQKf WTj1jxKH0dQrGmLp9AoTQo/RtnpnOYtD7Eqi8axA66gMUZqsn6+IDnQfKaqcXRkiqubb /ZvU7hTFFqWG2fFO7BypflkGD1loyN47SHA9/mf/GHb79OewQEarKA/IZHoKe9rA7e22 KD4nhzneiOVUahF1gAfoqfvXjZ4LseZHox+bp+mMc1fmOm3llutWRtiJ+iNpsW18Ohjv dULPG7URVsVrhQT8Fvh+JiYevufrS8Pw4a0qJ2+rXnCJYAhXYzigiTYdVS1AgcjadpnZ +u6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l126si15143391pgl.70.2022.02.23.04.52.22; Wed, 23 Feb 2022 04:52:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235466AbiBWJGg (ORCPT + 99 others); Wed, 23 Feb 2022 04:06:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230301AbiBWJGf (ORCPT ); Wed, 23 Feb 2022 04:06:35 -0500 Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E39557B35; Wed, 23 Feb 2022 01:06:06 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R931e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04407;MF=ashimida@linux.alibaba.com;NM=1;PH=DS;RN=20;SR=0;TI=SMTPD_---0V5I3avg_1645607161; Received: from 192.168.193.152(mailfrom:ashimida@linux.alibaba.com fp:SMTPD_---0V5I3avg_1645607161) by smtp.aliyun-inc.com(127.0.0.1); Wed, 23 Feb 2022 17:06:02 +0800 Message-ID: Date: Wed, 23 Feb 2022 01:06:01 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 Subject: Re: [PATCH] [PATCH] AARCH64: Add gcc Shadow Call Stack support Content-Language: en-US To: Mark Rutland Cc: catalin.marinas@arm.com, will@kernel.org, nathan@kernel.org, ndesaulniers@google.com, keescook@chromium.org, masahiroy@kernel.org, tglx@linutronix.de, akpm@linux-foundation.org, samitolvanen@google.com, npiggin@gmail.com, linux@roeck-us.net, mhiramat@kernel.org, ojeda@kernel.org, luc.vanoostenryck@gmail.com, elver@google.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org References: <20220222095736.24898-1-ashimida@linux.alibaba.com> From: Dan Li In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/22/22 10:47, Mark Rutland wrote: > Hi, > > On Tue, Feb 22, 2022 at 01:57:36AM -0800, Dan Li wrote: >> Shadow call stack is available in GCC > 11.2.0, this patch makes >> the corresponding kernel configuration available when compiling >> the kernel with gcc. > > Neat! > > My local GCC devs told me that means GCC 12.x.x rather than 11.2.x or > 11.3.x, so as others have said it'd be clearer to say `GCC >= 12.0.0`. > Ah, yes, I just saw this flag in gcc/BASE-VER. > I'd like to try this with a GCC binary before I provide an Ack or R-b; > but in the mean time I have a few comments below. > Thanks for your test, Mark. Please let me know if there is any issues :) >> --- >> FYI: >> This function can be used to test if the shadow call stack works: >> //noinline void __noscs scs_test(void) >> noinline void scs_test(void) >> { >> register unsigned long *sp asm("sp"); >> unsigned long * lr = sp + 1; >> >> asm volatile("":::"x30"); >> *lr = 0; >> } > > It's probably be better to use __builtin_frame_address(0) to get the > address of the frame record rather than assuming that fp==sp in the > middle of the function. > Got it. >> config SHADOW_CALL_STACK >> - bool "Clang Shadow Call Stack" >> - depends on CC_IS_CLANG && ARCH_SUPPORTS_SHADOW_CALL_STACK >> + bool "Shadow Call Stack" >> + depends on ARCH_SUPPORTS_SHADOW_CALL_STACK >> depends on DYNAMIC_FTRACE_WITH_REGS || !FUNCTION_GRAPH_TRACER >> help >> - This option enables Clang's Shadow Call Stack, which uses a >> + This option enables Clang/GCC's Shadow Call Stack, which uses a >> shadow stack to protect function return addresses from being >> overwritten by an attacker. More information can be found in >> Clang's documentation: > > Is there any additional GCC documentation that we can refer to? > Currently there is only a brief description of -fsanitize=shadow-call-stack in the user manual. Since the description of the clang documentation is more detailed, should I add this gcc link to the configuration description? Link: https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html#Instrumentation-Options >> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig >> index 09b885cc4db5..a48a604301aa 100644 >> --- a/arch/arm64/Kconfig >> +++ b/arch/arm64/Kconfig >> @@ -1255,7 +1255,7 @@ config HW_PERF_EVENTS >> config ARCH_HAS_FILTER_PGPROT >> def_bool y >> >> -# Supported by clang >= 7.0 >> +# Supported by clang >= 7.0 or GCC > 11.2.0 > > As above, I beleive that should be `GCC >= 12.0.0`. > Yeah. Thanks, Dan.