Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp835900rwd; Sat, 20 May 2023 07:32:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7QT+MBod2eAF3weNNm7YTTQVW12Hwm6a0HVFjFg5aQeROMgZFYC619kGeP7ZlARSbNEArv X-Received: by 2002:a05:6a21:3703:b0:102:dd98:509b with SMTP id yl3-20020a056a21370300b00102dd98509bmr4716423pzb.21.1684593172490; Sat, 20 May 2023 07:32:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684593172; cv=none; d=google.com; s=arc-20160816; b=uELBApu2ursnyH/XpdYJof5sZ+mod4KWJ7mdY24gQ1J8dGeHT1rhoRY+tWQdJLl++Z U9sWCAM5kVHeIeXm+as5UttQe13hn/fEdXwGGG5j151UnG+iuggwXjH3y2DmXKRA+Pm/ zd0JT8pd4aPLom+Mf2Xn8Jgv/nYBPlQd9t7eDdMJTmA+82TVtN0QHVRXaYBOs9F3qK9V s3L5MEvyTKQma/+RXFoDwOut6XxKhjH25QLirvYm4FnTES06z3CScrD27yf168KYA4ea WIQVThPResOOY5qgq88rE0IK6R1d6Yg74u/+1pZpWWh87w89OjjKIojN4/Fiqry+qhCl 3NSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=XgiAUYb8vQqCYRnsw2vaRQgZ2/fNH9x/pE6DJM/vD/k=; b=nB8w5TpmA6ASLGIANwbpseJYdYkczX1g4+N7gbaSWYu1tW3ro0Zq4OfGaPN/D0K/K7 4HOTZpA/l17lIQsGAo0OViViypSyKwGGU3/uxYni335cKd0dMUvSTg4tfKBO58ZzQ+09 D4nQ+hK5uZTy0braInyxMBNQ7IdC90U+/584mZ/dxl/IPjoNOkudA5Haen1Xzo622/CC mhpG2yCEdaMZwOn7BRUONe3+mU3P7cXVA1wuWmLbug/9mXEcl0OTQGZk6p2kc9uafpsx F4LD857HGRhC47zkRreWTDL4m5zA0zYRNwMWal2PpJL1JMuQTNr8zCwUt2IlndoZ8ajk +EYw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 19-20020a631553000000b0053071bc497dsi1654238pgv.90.2023.05.20.07.32.37; Sat, 20 May 2023 07:32:52 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231578AbjETONs (ORCPT + 99 others); Sat, 20 May 2023 10:13:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229464AbjETONr (ORCPT ); Sat, 20 May 2023 10:13:47 -0400 Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6D2CEFD; Sat, 20 May 2023 07:13:46 -0700 (PDT) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 34KEDW6v027662; Sat, 20 May 2023 16:13:32 +0200 Date: Sat, 20 May 2023 16:13:32 +0200 From: Willy Tarreau To: Thomas =?iso-8859-1?Q?Wei=DFschuh?= Cc: Zhangjin Wu , aou@eecs.berkeley.edu, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, palmer@dabbelt.com, paul.walmsley@sifive.com, shuah@kernel.org Subject: Re: [PATCH] selftests/nolibc: Fix up compile error for rv32 Message-ID: <20230520141332.GB27611@1wt.eu> References: <20230520-nolibc-stackprotector-riscv-v1-1-d8912012a034@weissschuh.net> <20230520120254.66315-1-falcon@tinylab.org> <20230520133237.GA27501@1wt.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Sat, May 20, 2023 at 04:07:34PM +0200, Thomas Wei?schuh wrote: > Hi Willy! > > On 2023-05-20 15:32:37+0200, Willy Tarreau wrote: > > Thomas, Zhangjin, > > > > I've merged your latest patches in my branch 20230520-nolibc-rv32+stkp2, > > which was rebased to integrate the updated commit messages and a few > > missing s-o-b from mine. Please have a look: > > > > https://git.kernel.org/pub/scm/linux/kernel/git/wtarreau/nolibc.git > > > > However, Thomas, I noticed something puzzling me. While I tested with > > gcc-9.5 (that I have here along my toolchains) I found that it would > > systematically fail: > > > > sysroot/x86/include/stackprotector.h:46:1: warning: 'no_stack_protector' attribute directive ignored [-Wattributes] > > 46 | { > > | ^ > > !!Stack smashing detected!! > > qemu: uncaught target signal 6 (Aborted) - core dumped > > 0 test(s) passed. > > > > The reason is that it doesn't support the attribute "no_stack_protector". > > Upon closer investigation, I noticed that _start() on x86_64 doens't have > > it, yet it works on more recent compilers! So I don't understand why it > > works with more recent compilers. > > _start() not having the attribute is indeed an oversight. > No idea how it worked before. No problem, I preferred to mention it anyway. > > I managed to avoid the crash by enclosing the __stack_chk_init() function > > in a #pragma GCC optimize("-fno-stack-protector") while removing the > > attribute (though Clang and more recent gcc use this attribute so we > > shouldn't completely drop it either). > > I would like to first align x86 to __attribute__((no_stack_protector)) > for uniformity and then figure out on how to make it nicer. I agree. > > I consider this non-critical as we can expect that regtests are run with > > a reasonably recent compiler version, but if in the long term we can find > > a more reliable detection for this, it would be nice. > > > > For example I found that gcc defines __SSP_ALL__ to 1 when > > -fstack-protector is used, and 2 when -fstack-protector-all is used. > > With clang, it's 1 and 3 respectively. Maybe we should use that and > > drop NOLIBC_STACKPROTECTOR, that would be one less variable to deal > > with: the code would automatically adapt to whatever cflags the user > > sets on the compiler, which is generally better. > > That sounds great! > > I explicitly looked for something like this before, dumping preprocessor > directives and comparing. > It seems the fact that my compilers enable this feature by default made > me miss it. Hmmm that's indeed possible. With -fno-stack-protector it should disappear: $ gcc -fno-stack-protector -dM -E -xc - < /dev/null |grep SSP $ gcc -fstack-protector -dM -E -xc - < /dev/null |grep SSP #define __SSP__ 1 $ gcc -fstack-protector-all -dM -E -xc - < /dev/null |grep SSP #define __SSP_ALL__ 2 $ clang -fstack-protector-all -dM -E -xc - < /dev/null |grep SSP #define __SSP_ALL__ 3 > I'll send patches. OK thanks. Just be aware that I'll be less responsive this week-end from now on. Willy