Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp664790rwl; Sat, 25 Mar 2023 08:47:33 -0700 (PDT) X-Google-Smtp-Source: AK7set8I/OQ/+s+SKPWbf+3FuvQx/3qhg/Zy5DmyLDNEJotLiVh03A+lGI8F79zKb3DHg7VU7zvW X-Received: by 2002:a05:6a20:89a9:b0:de:4f40:e226 with SMTP id h41-20020a056a2089a900b000de4f40e226mr5101631pzg.52.1679759253260; Sat, 25 Mar 2023 08:47:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679759253; cv=none; d=google.com; s=arc-20160816; b=S8YZ8C+JyRwler3Mj0tIwzJVzm4+AGK6YhGVbrZtM1mr5Sx+udUpv8Stch+rvcnj+y bpG4TcXjaqW3NYJwUL8pb6x/nlE1tFRECFThBZitQoSOImMqkjXDSjjg9BxM+6JQvSqB TyEVPjxfU3B52/bCTOH/xNhJTIcpVcT5ip6p63I/WnrAsNRf83aCXvbJHOqizODrFRQD AI1WIq5heml1CDarG9fCayb6xsCkbWvwsFrXsJdYU/Yx52FtBBrpH4vP6o/9IfdBPLbY VCSmeABi5Es3ViUKaceD1mwKbueS9vYCAj6NR+lR0ii12tObNHjN1tz1kXSsMgMX2meB 25Yg== 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=xreXGVt3PK/IEX/YFbEP1OT2sEENYNlNcc5hGJKd6OE=; b=NV5/4AdOzLxa2xzsHQle530biaBaGhutDe1vp39Bh40Moo3BZ3a9iEIf++WcLrRBKN tNRveC4k3DeXNwpHweyMp7Cud9qvBHRDrbUEmGovuerYlPqw0UmXQku/vEaFzYoiEZAr GBvzBHwWNhgEmzhVVPWmA5VLISfLf/TCZaldk0SRmKCGI+Zaln80LlOLLUyq9WC5L7Re fFhlvCITlUj/dS4ROlP1LRfYwh4ihVpBjM3Ya7Oi2Z7hi2rkEDkNw4EG4XKNVtG7pM1a 4o+2mBMgdEnpIeLHEtWNBJorY0XCin9/uWNmFggNorq8eDvjqT+UT7lo+wdywtsSFC5M xWbA== 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 bn22-20020a056a00325600b005d1442319d3si22452919pfb.308.2023.03.25.08.47.22; Sat, 25 Mar 2023 08:47:33 -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 S231820AbjCYPqK (ORCPT + 99 others); Sat, 25 Mar 2023 11:46:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231735AbjCYPqE (ORCPT ); Sat, 25 Mar 2023 11:46:04 -0400 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BBEAD1258E for ; Sat, 25 Mar 2023 08:45:55 -0700 (PDT) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 32PFjRTo008053; 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 8/8] tools/nolibc: x86_64: add stackprotector support Date: Sat, 25 Mar 2023 16:45:16 +0100 Message-Id: <20230325154516.7995-9-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 x86_64. Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau --- tools/include/nolibc/arch-x86_64.h | 5 +++++ tools/testing/selftests/nolibc/Makefile | 2 ++ 2 files changed, 7 insertions(+) diff --git a/tools/include/nolibc/arch-x86_64.h b/tools/include/nolibc/arch-x86_64.h index 17f6751208e7..f7f2a11d4c3b 100644 --- a/tools/include/nolibc/arch-x86_64.h +++ b/tools/include/nolibc/arch-x86_64.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 */ /* * x86-64 System V ABI mandates: @@ -191,6 +193,9 @@ const unsigned long *_auxv __attribute__((weak)); void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void) { __asm__ volatile ( +#ifdef NOLIBC_STACKPROTECTOR + "call __stack_chk_init\n" // initialize stack protector +#endif "pop %rdi\n" // argc (first arg, %rdi) "mov %rsp, %rsi\n" // argv[] (second arg, %rsi) "lea 8(%rsi,%rdi,8),%rdx\n" // then a NULL then envp (third arg, %rdx) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index ab99786c1e94..bbce57420465 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_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) \ -- 2.17.5