Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2603801rdh; Mon, 30 Oct 2023 02:10:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtogCPGg8kXH3HjbOY3TMpwaCBmjGhQ/1F4doIvoObp43N77ZnaLvKzs06YEjgZE9dJFQD X-Received: by 2002:a05:6358:94a6:b0:169:7eaa:cbe7 with SMTP id i38-20020a05635894a600b001697eaacbe7mr87893rwb.32.1698657051302; Mon, 30 Oct 2023 02:10:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698657051; cv=none; d=google.com; s=arc-20160816; b=n/L9zPtLWnad+yKhnAXg4YllXKra4tkCH+ao336Oei0dcB3aOOpQZdFw3jQ5qr+wcc 5DvBd3peL5TDZAlQ09UQPDRToQsCP+rDQL3jvmWOiYyTt0hfB8GMoQ0JGxhJY5Cu77ky Y9oP4REacjEnHWQ0amXKjg8AIJGa9QhTXo8IuE3JGOWC4yGEpCuzMQViLjI4IpNubr93 IJ4TKTvKe0tR0FpAgdDu/gn9XJHVSh2ImCQ3dARH1Xr3tZwpSv5HUiJgZwpbAHdSR0NU W/7b4s8B0EjEF48n6uJ2vYGyANdGCe6vSdpOJDK3gYbnaI+QUQplisk7Ndq+QY7iT0il f1Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=viTB2MCu7D6d4/He6yWasnXAPMRVI+rvDuoEeVOmWYM=; fh=vK62hcw06DNmTw7qPH6MSSwNUe33/YXRjAUKn6+3ETQ=; b=yzWM4mjnYhO/Y29S5f4DYQNszE6L4lSuF5MV1YVSojsf633RTUdCVeUPTP3Y2KaWgV 3SWPBfz9m5xQ9BN9n9XECM4+rcHQ0a80ow8mgpxWj5zixkAtuoW07uEsu86zViaIwqEa VdkK9e8M/oOIxW5XmjN4hG9CxFYyAoEBH/pskcV6Au6elgeFkmVS21XnjnfGREv9ceS0 5iHV00TcBejHajK6Escki8aUV3sbX9Df/vo7RbfzcvVe3qxRKCWLdDxWPrSG2kG3xkVm Pf0JOEtYko97zMCG3XlsezIAdZyXz6ycWWYV+uLOwz8AsjcDxLFmQJhA2NNHFFqUMQDb zjIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MahlD0m+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id m127-20020a632685000000b0057047d68837si4874730pgm.869.2023.10.30.02.10.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 02:10:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MahlD0m+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 27E4E80A07E0; Mon, 30 Oct 2023 02:10:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232374AbjJ3JKV (ORCPT + 99 others); Mon, 30 Oct 2023 05:10:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231467AbjJ3JKU (ORCPT ); Mon, 30 Oct 2023 05:10:20 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C96E9D for ; Mon, 30 Oct 2023 02:10:18 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-53b32dca0bfso8708333a12.0 for ; Mon, 30 Oct 2023 02:10:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698657016; x=1699261816; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=viTB2MCu7D6d4/He6yWasnXAPMRVI+rvDuoEeVOmWYM=; b=MahlD0m+jOtGjW3nj6u/J3VT63qnruWkkBqfXtxKjp+WpGqIldCtCQIZ2BD1v1rEbA cGgb+G+WCIo4FjWl4d5C25kSgRZboVpgVY4jEoU2MmwizF1DLnT46jOlVRCbsGGBm087 OJsz3hULcaVQ8O3gjJf54Al7g5XGLUmAhVkw2BsH4oM/35kbZiCo4kLEhT43oDTfaCYU D5RdNXMeVDhRn4wZWtNPMru75XMFU2/hJUd11qmwrFpUHjsgsWha8DJqX5MygG8ETPWf GynEOhS5cZayEOk2x7juQnu7LIgvyyX2WE024x8MyJcbqQKXbELEs2S/Lwpt3PvT1a7+ 9bTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698657016; x=1699261816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=viTB2MCu7D6d4/He6yWasnXAPMRVI+rvDuoEeVOmWYM=; b=BMETD9tOQaownNj/H3bUhzaxofZdgthlT6BLGAHfpj9DXpUSHnOWqP6VxFYxktDn3F +lLl6WOuxxI1HwK4eyQ1i/ULA5g7VDf2KDHvrdr0viC2hqpEGpkQz/7dTVmGvvuVfvme CXqImziGp3Sxf6zEKXnQUKh7V3naf7NtrhJlLorZ6LoWOi0u2U1tPjH/1Jwlv87nZG5S fhS/LuFyPFTm4Bpx8KBCEFTf7yZ/uyazF1N/L36rR04rycXjw6PKePIqD48eTnNPCETO z47HBiBDxVDtbHCSHSUxcKZh0R6To0XQ4t/vUs46DQ/dieGKn+X32ufcRKqkYjZ8H2TX NTJA== X-Gm-Message-State: AOJu0Yy5ObcLYPz9i9UA2AlKt2OOaBb+GppNZfc7MqMAIxqc1XdGdqkz e5RxOu9dv5cv7BoBt+AJEbbjW9JYedh6JTwVAqg= X-Received: by 2002:aa7:c68c:0:b0:542:f0af:21e6 with SMTP id n12-20020aa7c68c000000b00542f0af21e6mr3950932edq.14.1698657016395; Mon, 30 Oct 2023 02:10:16 -0700 (PDT) MIME-Version: 1.0 References: <20231026160100.195099-1-brgerst@gmail.com> <1eb4f2c46e1642519a40924ed3fe3ccc@AcuMS.aculab.com> In-Reply-To: <1eb4f2c46e1642519a40924ed3fe3ccc@AcuMS.aculab.com> From: Uros Bizjak Date: Mon, 30 Oct 2023 10:10:05 +0100 Message-ID: Subject: Re: [PATCH v2 00/11] x86-64: Stack protector and percpu improvements To: David Laight Cc: Brian Gerst , "linux-kernel@vger.kernel.org" , "x86@kernel.org" , Ingo Molnar , Thomas Gleixner , Borislav Petkov , "H . Peter Anvin" , Peter Zijlstra Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 30 Oct 2023 02:10:41 -0700 (PDT) On Mon, Oct 30, 2023 at 10:05=E2=80=AFAM David Laight wrote: > > From: Uros Bizjak > > Sent: 30 October 2023 08:07 > > > > On Sun, Oct 29, 2023 at 10:42=E2=80=AFPM David Laight wrote: > > > > > > From: Brian Gerst > > > > Sent: 26 October 2023 17:01 > > > > > > > > Currently, x86-64 uses an unusual percpu layout, where the percpu s= ection > > > > is linked at absolute address 0. The reason behind this is that ol= der GCC > > > > versions placed the stack protector (if enabled) at a fixed offset = from the > > > > GS segment base. Since the GS segement is also used for percpu var= iables, > > > > this forced the current layout. > > > > > > > > GCC since version 8.1 supports a configurable location for the stac= k > > > > protector value, which allows removal of the restriction on how the= percpu > > > > section is linked. This allows the percpu section to be linked > > > > normally, like most other architectures. In turn, this allows remo= val > > > > of code that was needed to support the zero-based percpu section. > > > > > > I didn't think the minimum gcc version was anything like 8.1. > > > I'm using 7.5.0 and I don't think that is the oldest version. > > > > Please see previous discussion regarding modernizing stack protector > > on x86_64 [1] > > > > [1] https://lore.kernel.org/lkml/20211113124035.9180-1-brgerst@gmail.co= m/ > > > > and x86_32 [2] > > > > [2] https://lore.kernel.org/lkml/cover.1601925251.git.luto@kernel.org/ > > > > The conclusion in [2] is: > > > > "I'm all in favour of simply requiring GCC-8.1 to build a more secure > > x86_64 kernel. Gives people an incentive to not use ancient compilers. > > > > And if you do want to use your ancient compiler, we'll still build, you > > just don't get to have stackprotector." > > I didn't see a patch that limited 'stackprotector' to gcc >=3D 8.1 > Without that anyone who already has it enabled and is using an > older compiler will get very broken kernels. It's this part: --cut here-- diff --git a/scripts/gcc-x86_32-has-stack-protector.sh b/scripts/gcc-x86_32-has-stack-protector.sh index f5c119495254..51f864d76bd6 100755 --- a/scripts/gcc-x86_32-has-stack-protector.sh +++ b/scripts/gcc-x86_32-has-stack-protector.sh @@ -1,4 +1,8 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 -echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -m32 -O0 -fstack-protector - -o - 2> /dev/null | grep -q "%gs" +# This requires GCC 8.1 or better. Specifically, we require +# -mstack-protector-guard-reg, added by +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D81708 + +echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -m32 -O0 -fstack-protector -mstack-protector-guard-reg=3Dfs -mstack-protector-guard-symbol=3Dstack_canary - -o - 2> /dev/null | grep -q "%fs" --cut here-- Uros.