Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp835439rwd; Sat, 20 May 2023 07:32:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Paz9kUmJRsw5rMPh4leCI1L8lP2Ifq9mrNHE08ChEIvqNNQSzgNBiNN4ha3jcBShufFCN X-Received: by 2002:a05:6a20:3d28:b0:fc:8dfb:318b with SMTP id y40-20020a056a203d2800b000fc8dfb318bmr6164670pzi.0.1684593147977; Sat, 20 May 2023 07:32:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684593147; cv=none; d=google.com; s=arc-20160816; b=fr3bLirjBZNjtu+Uh3V0xFIbwe/9qCPcYb7dW0oUpgwBnK5bEYy1NfI6+Y1BKHPXEr 2u6X8afeFZ19Wd8zPgoU+ReQCWdZ4IcWuZXDA5lvizzmle////R1sDz+L2WuN6FFhgzt 4XgH6/D7cFfhZIyHZFG351ECc2TgiOBvueI8QlVHy8vZAFbCTDJlO4nD8ULu3HXsbhs4 Gn6+UtcsbEeFBW2vYzzwehFTrM7PWsit7GCn7OKrvIMElr4VLmlInO0f9RfmA8cVNZiY K0GtB3TgUaSqQ32fxkcae8S0fYsxh+qhFsluTw1SrjXVJDCoWkWN7JMJTeSH5VlVlxrU 8RBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=946czL6CM4PEF47FAwvqDo2UsNwY0EjRPA1A4GV52C0=; b=ZtEBQMJkt/CWzHGp8Ds8+V8dGouK8pvcbEKSHu+5x9CQ25UzUN0hfijYa0Z+MBGYrp DBCg1HnlbhUA3RAth15lxn+d9dCTvZVRXZRWPLikpJrURuAQm63vdRbH7tirEBtBpPxm 4scpODuQAiLC7iteVGMVhXXXYLkr4a1hKq2kQbr+qTu3Hex33HxA8T00YJnq01fyWmMm 6tbls21ZL2zkXc09c5TGjzbNhqMrllAbTEczUfbCTmoTseUbgEA+UsyaY3A+kjljHrpN KtMTzP7SlZLY3WiPG0MLL5gHlVYU4aTF5vidN6+e/Z0nUwTC7IyHvbyfVwPzeN2fO1YU U3Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@t-8ch.de header.s=mail header.b=M9NICF87; 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 z22-20020a637e16000000b0052dcd67347asi1654158pgc.382.2023.05.20.07.32.10; Sat, 20 May 2023 07:32:27 -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; dkim=pass header.i=@t-8ch.de header.s=mail header.b=M9NICF87; 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 S230527AbjETOHk (ORCPT + 99 others); Sat, 20 May 2023 10:07:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229548AbjETOHi (ORCPT ); Sat, 20 May 2023 10:07:38 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81166103; Sat, 20 May 2023 07:07:37 -0700 (PDT) Date: Sat, 20 May 2023 16:07:34 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=t-8ch.de; s=mail; t=1684591655; bh=ySREgzMBnxEK+0ESf3+KXe4YjYf8WKePWiFol6csxZo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=M9NICF87zsuSxMmlrl2aWcCqjjZp/fU9cSUqETjqgM4+cH6C2+Wwuc/NA5UW4i/xa qwURD69NS6FdK7PtSo8slY/2nv/cYTQYQCIHVe4z2Xfq3py00oqtRXlnr/4oPIejux E5bJ/ykbzSIS+Z/1dkpOLNCi/p39Yb28r252B+Qs= From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: Willy Tarreau 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: 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=us-ascii Content-Disposition: inline In-Reply-To: <20230520133237.GA27501@1wt.eu> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 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. > 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 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. I'll send patches. Thomas