Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp664711rwl; Sat, 25 Mar 2023 08:47:29 -0700 (PDT) X-Google-Smtp-Source: AK7set8zhBvOaLMvLWQ8rSrKith4mI5FmNzVki3HqXhWBradB9VoPmDccrbaEDPIQmIpCJzrTw29 X-Received: by 2002:a05:6a20:2a0a:b0:db:5ff5:8f21 with SMTP id e10-20020a056a202a0a00b000db5ff58f21mr5242490pzh.15.1679759249195; Sat, 25 Mar 2023 08:47:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679759249; cv=none; d=google.com; s=arc-20160816; b=VJGelb7X6HnqqspWTEnDSMhh1Vp29BKEiKo/OXnXIEVx/kZwzU4SG3ZrzMaGOWetwS 1EcNz+gC6987GATxG4zSNw4/uB2AEtUBLX+qTan4CjRgACR9zZDF2HYkUaLItA0M9Al6 ECRSd9eMqbKlVVRBuzVo/9hpl03ACTYTUQgAF+Ayphw0UdDT2oLTf1W7aT6180xV4y/5 dVL5wAx30zraQF+ajFvGRsT2CzkzgESKizKt7ucsHrLEqE1e1TYOM0XoR1SBh1iV0qR0 29Saby2tazQ4hFju5tVy2lVU2dpYZQ458BjED/eXCqRjE/V0vwhCpCBgL+yWCDv7rfp4 EogA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=QaCqf5aYN1wS4/dZCpghp1fjLz9/EZ02VlhtLdR6M/k=; b=sMwNwZ8HnOAakdGKayZK+9eS9B384AaxOSEtjItEhRQSngfzVIZfPFsu5VnumVECZq aMO2cH+2PXRa7jcDcNmRvT6J7NhIfuMVKJ/LCvOe/bxR8cN4c1JLwOWEVwg+Ci0YX0FG 0FQDBI0P35UKtONllpt8Glr63KlbfnU07PdX4gKoVAe4f4NxDXVVycAHUfWxn/FJ/wvY 3Il6ePIIbbdNx/zPq+uFpChLmZBfjSd8JIx8uodS0XDTdGoSyliW1FGVN2fMwth7m8vM sYGw07lv5qQiHWWMkSIVoGhV/SESgIFZ5SNmBaji3HsrtQVvvjagB/ZtLeLQLZs6tomk 4aQQ== 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 f62-20020a62db41000000b00591f06fa9d9si23188385pfg.277.2023.03.25.08.47.18; Sat, 25 Mar 2023 08:47:29 -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 S231391AbjCYPqH (ORCPT + 99 others); Sat, 25 Mar 2023 11:46:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231667AbjCYPp7 (ORCPT ); Sat, 25 Mar 2023 11:45:59 -0400 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ACAA7126D9 for ; Sat, 25 Mar 2023 08:45:54 -0700 (PDT) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 32PFjR6D008052; Sat, 25 Mar 2023 16:45:27 +0100 From: Willy Tarreau To: "Paul E. McKenney" Cc: linux@weissschuh.net, linux-kernel@vger.kernel.org, Willy Tarreau Subject: [PATCH 7/8] tools/nolibc: i386: add stackprotector support Date: Sat, 25 Mar 2023 16:45:15 +0100 Message-Id: <20230325154516.7995-8-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20230325154516.7995-1-w@1wt.eu> References: <20230325154516.7995-1-w@1wt.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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 From: Thomas Weißschuh Enable the new stackprotector support for i386. Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau --- tools/include/nolibc/arch-i386.h | 7 ++++++- tools/testing/selftests/nolibc/Makefile | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/include/nolibc/arch-i386.h b/tools/include/nolibc/arch-i386.h index e8d0cf545bf1..2d98d78fd3f3 100644 --- a/tools/include/nolibc/arch-i386.h +++ b/tools/include/nolibc/arch-i386.h @@ -181,6 +181,8 @@ struct sys_stat_struct { char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); +#define __ARCH_SUPPORTS_STACK_PROTECTOR + /* startup code */ /* * i386 System V ABI mandates: @@ -188,9 +190,12 @@ const unsigned long *_auxv __attribute__((weak)); * 2) The deepest stack frame should be set to zero * */ -void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void) +void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void) { __asm__ volatile ( +#ifdef NOLIBC_STACKPROTECTOR + "call __stack_chk_init\n" // initialize stack protector +#endif "pop %eax\n" // argc (first arg, %eax) "mov %esp, %ebx\n" // argv[] (second arg, %ebx) "lea 4(%ebx,%eax,4),%ecx\n" // then a NULL then envp (third arg, %ecx) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index e516e53775d4..ab99786c1e94 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -79,6 +79,7 @@ endif CFLAGS_STACKPROTECTOR = -DNOLIBC_STACKPROTECTOR \ $(call cc-option,-mstack-protector-guard=global) \ $(call cc-option,-fstack-protector-all) +CFLAGS_STKP_i386 = $(CFLAGS_STACKPROTECTOR) CFLAGS_s390 = -m64 CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables \ $(call cc-option,-fno-stack-protector) \ -- 2.17.5