Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp637914rwl; Thu, 23 Mar 2023 23:08:08 -0700 (PDT) X-Google-Smtp-Source: AKy350Yxkd6f7M8wXj3NfsbpoB8WcwSlkzzZJGfDbsZTbm2Lpanx88QtHeUf6thsS2q65140k13k X-Received: by 2002:a17:907:8c10:b0:928:c92e:d112 with SMTP id ta16-20020a1709078c1000b00928c92ed112mr1594742ejc.50.1679638088347; Thu, 23 Mar 2023 23:08:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679638088; cv=none; d=google.com; s=arc-20160816; b=1LbGT1bxq9LKHgxhisVn3hVxtMcOzLsNcDiJ4prfi8EJhkau3xN3TAKYgw8PxNTNa+ k5D9lPl4IgOTINGrU4WOxs6iJuE+JNb8IVDGP7D+LHXxg3v67HrnglBdMbSlA3SFJVo6 Fnj87qJGWaGyl2zl80getWH/TsPO09Uga+GKIMO8XVpVNdp8zzY2MrRU6a3ms5qPS85M PeWhiK4Je6/9ZQdqQ8HvuNRjspsbNNdJOT77rYBJ3EkLdB2EOJ9Vvw96iJ8ftVosECal ngMVr2gFgjyTxOamJ7upsqj0SfE6QqEyu2ZsE7UuF4Uqfp7JBqFpwLmWKU912UEDSXCZ zHRA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Hta4rzImztfr59ZgkK8vcjCD3Dvgu7b2g5vwsK8Fp/c=; b=nIfwBpJxBXCtOOpQPNGdy7V4cvlYDhLiwguKwSxbtJa2j8Rf7xgCxv8s6/jwydJs2C dFEDim+AupHQjj0SeEczFj+SyUx7cDuI5Rmw3krHhTed25/5hW6PHowLT5KfYukYKCmw BWl4QdP34ALFKTw2yCkNWnYaul2RCbMVk/PmbymGialvb/OBDiU7WL3MxHWldK3PXFWT 0ILFk9UP0rxMDLYxzf/9aQQ46H/SgKrr5gN+DTBIBouVg8QNYfE2/aCGx+mKsXehNatb pyWxP3tQ9CeFojkyQxGTiNCvhGU0cSY/XxTvTaC9FdSqIBxSpKcfdAWQnGZth6eCWsXv Vx/Q== 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 v15-20020a17090651cf00b008deaca3a01csi18765816ejk.221.2023.03.23.23.07.42; Thu, 23 Mar 2023 23:08:08 -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 S231344AbjCXFcV (ORCPT + 99 others); Fri, 24 Mar 2023 01:32:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230040AbjCXFcP (ORCPT ); Fri, 24 Mar 2023 01:32:15 -0400 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 368E11980; Thu, 23 Mar 2023 22:32:10 -0700 (PDT) Received: (from willy@localhost) by mail.home.local (8.17.1/8.17.1/Submit) id 32O5W5q8025977; Fri, 24 Mar 2023 06:32:05 +0100 Date: Fri, 24 Mar 2023 06:32:05 +0100 From: Willy Tarreau To: Thomas =?iso-8859-1?Q?Wei=DFschuh?= Cc: Shuah Khan , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH v2 8/8] tools/nolibc: x86_64: add stackprotector support Message-ID: References: <20230223-nolibc-stackprotector-v2-0-4c938e098d67@weissschuh.net> <20230223-nolibc-stackprotector-v2-8-4c938e098d67@weissschuh.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-0.0 required=5.0 tests=SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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 Thu, Mar 23, 2023 at 11:44:15PM +0000, Thomas Wei?schuh wrote: > Hi Willy, > > On Thu, Mar 23, 2023 at 09:19:48PM +0100, Willy Tarreau wrote: > > On Mon, Mar 20, 2023 at 03:41:08PM +0000, Thomas Wei?schuh wrote: > > > Enable the new stackprotector support for x86_64. > > (...) > > > diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile > > > index 8f069ebdd124..543555f4cbdc 100644 > > > --- a/tools/testing/selftests/nolibc/Makefile > > > +++ b/tools/testing/selftests/nolibc/Makefile > > > @@ -80,6 +80,8 @@ CFLAGS_STACKPROTECTOR = -DNOLIBC_STACKPROTECTOR \ > > > $(call cc-option,-mstack-protector-guard=global) \ > > > $(call cc-option,-fstack-protector-all) > > > CFLAGS_i386 = $(CFLAGS_STACKPROTECTOR) > > > +CFLAGS_x86_64 = $(CFLAGS_STACKPROTECTOR) > > > +CFLAGS_x86 = $(CFLAGS_STACKPROTECTOR) > > > CFLAGS_s390 = -m64 > > > CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables \ > > > $(call cc-option,-fno-stack-protector) \ > > > > This change is making it almost impossible for me to pass external CFLAGS > > without forcefully disabling the automatic detection of stackprot. I need > > to do it for some archs (e.g. "-march=armv5t -mthumb") or even to change > > optimization levels. > > > > I figured that the simplest way to recover that functionality for me > > consists in using a dedicated variable to assign stack protector per > > supported architecure and concatenating it to the per-arch CFLAGS like > > this: > > > > diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile > > index 543555f4cbdc..bbce57420465 100644 > > --- a/tools/testing/selftests/nolibc/Makefile > > +++ b/tools/testing/selftests/nolibc/Makefile > > @@ -79,13 +79,13 @@ endif > > CFLAGS_STACKPROTECTOR = -DNOLIBC_STACKPROTECTOR \ > > $(call cc-option,-mstack-protector-guard=global) \ > > $(call cc-option,-fstack-protector-all) > > -CFLAGS_i386 = $(CFLAGS_STACKPROTECTOR) > > -CFLAGS_x86_64 = $(CFLAGS_STACKPROTECTOR) > > -CFLAGS_x86 = $(CFLAGS_STACKPROTECTOR) > > +CFLAGS_STKP_i386 = $(CFLAGS_STACKPROTECTOR) > > +CFLAGS_STKP_x86_64 = $(CFLAGS_STACKPROTECTOR) > > +CFLAGS_STKP_x86 = $(CFLAGS_STACKPROTECTOR) > > CFLAGS_s390 = -m64 > > CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables \ > > $(call cc-option,-fno-stack-protector) \ > > - $(CFLAGS_$(ARCH)) > > + $(CFLAGS_STKP_$(ARCH)) $(CFLAGS_$(ARCH)) > > LDFLAGS := -s > > > > help: > > > > And now with this it works again for me on all archs, with all of them > > showing "SKIPPED" for the -fstackprotector line except i386/x86_64 which > > show "OK". > > > > Are you OK with this approach ? And if so, do you want to respin it or > > do you want me to retrofit it into your 3 patches that introduce this > > change (it's easy enough so I really don't care) ? > > Looks good to me. > > If nothing else needs to be changed feel free to fix it up on your side. Perfect, will do it then. Thanks! Willy