Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp364962pxx; Thu, 29 Oct 2020 04:41:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVdKbCs95bGzEyZYNOJkxwXJyyxQCGziaiPfpcMQ3LIiZTCvLMaq1hwWmN5mgFgMpzXXiX X-Received: by 2002:a17:906:b043:: with SMTP id bj3mr3496607ejb.543.1603971683144; Thu, 29 Oct 2020 04:41:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603971683; cv=none; d=google.com; s=arc-20160816; b=fSVt/lK88p/CdwS+TzkEYuzOIgWhfKY2Dvd+Jv5IIHkPGrmzpduhHu83ORPOiutu3q QMAsKxsVcByE9zfdaafy481AxoELxAovR/bKjInsM+lLWWSbhRrI7zuwQn0bGRtz2o0w 53scFwVYuM7z85H3GdUKEn6mxZskxTQW9do+77T+k88jnqWF6ULD+S9EWehQ2p0yCs59 TKbSsNo9/+ynWHpRqjiUPi8dXRRs1dY84e1wPgnjGncbhF+BMd23B0oT5UuoNGrLfRtp VAVy1di1j9xOxQumQ/qnloJDWO4YsN1eVmdg91zz9s210ZhkpTh21XnWhFyVlNUNORGy IZig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=Zod12g2Tu48/Be5tUz7QzruMHC3mYdb7yZ+Nbxw0l4w=; b=wiBz0rPf3j+RR3Dza2lLBqbW1y4wZonjoscULblOQitdILgafbufeYt838BolxzaPL 4w/TQUolJ6VDZzt8BHGMk5+YOjP9nA2wVy6uyOcC0VxntIH/iXtlCMGogVb72Wej5dpt RPpclOJgg7CV0vIShy4a/0o2GXg+5RDryst+wneaS20pLsGKSBRchvAqRjJLk9/fl8eO f2ZIPB8OFxHOOpJjPD4ezCQUXFtOH5hfnwFVeah0C0/W9tiqtgWUGRv3Z9p5KeCfq3+x XbqTwFiY7Fd2fL6+mDTphxY/cVg1HWs+879p7LxTNxinaHzj+ex5ExL2wvkA4jUdBelA ECrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=qEmzQJry; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d12si1728657edj.601.2020.10.29.04.40.59; Thu, 29 Oct 2020 04:41:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=qEmzQJry; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725536AbgJ2Lh0 (ORCPT + 99 others); Thu, 29 Oct 2020 07:37:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725791AbgJ2LgW (ORCPT ); Thu, 29 Oct 2020 07:36:22 -0400 Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9234FC0613CF for ; Thu, 29 Oct 2020 04:36:22 -0700 (PDT) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4CMNg06TwCz9sSC; Thu, 29 Oct 2020 22:35:56 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ellerman.id.au; s=201909; t=1603971378; bh=/bWxFtkcnR3hrEd2XbJrRVATAUV/nns9oZ79oXlWWZI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=qEmzQJryIrXXvMFilHzdRLfCxqjaLw14CC76shLzlafg3MPoa7WBOwi3fxtkEoSTQ 0xEp0E5qrjHLRnwWfF78HGCQdBSw6w0Vgegj8pgdzP9Yx3Wt1XapfMHsBWTTHcEaGq xTxkqA0xXrYuLSZSBWp/9YW/uD0WdEJlo5xD8eZo3BQZaHjuy7TrTLJMrqDHA4jQlN kJVN+jBD4yIhS6H4t0I7S8m1EWVxFGgWiiSTOmymGeCki5QJsbsnvYsIVa60c8yVuF vGOsVGY+8gtWfUIhsAk5Wo7V6PDNfbKW+uMMqDIrTMK+882wWiIPddMoAfYB8Jwnr5 f6mq9Qu2c91hQ== From: Michael Ellerman To: Ard Biesheuvel , Linux Kernel Mailing List Cc: "open list\:LINUX FOR POWERPC \(32-BIT AND 64-BIT\)" , Benjamin Herrenschmidt , Paul Mackerras , Nick Desaulniers , Arvind Sankar , Randy Dunlap , Josh Poimboeuf , Thomas Gleixner , Alexei Starovoitov , Daniel Borkmann , Peter Zijlstra , Geert Uytterhoeven , Kees Cook Subject: Re: [PATCH] powerpc: avoid broken GCC __attribute__((optimize)) In-Reply-To: References: <20201028080433.26799-1-ardb@kernel.org> Date: Thu, 29 Oct 2020 22:35:48 +1100 Message-ID: <875z6tw9gr.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ard Biesheuvel writes: > On Wed, 28 Oct 2020 at 09:04, Ard Biesheuvel wrote: >> >> Commit 7053f80d9696 ("powerpc/64: Prevent stack protection in early boot") >> introduced a couple of uses of __attribute__((optimize)) with function >> scope, to disable the stack protector in some early boot code. >> >> Unfortunately, and this is documented in the GCC man pages [0], overriding >> function attributes for optimization is broken, and is only supported for >> debug scenarios, not for production: the problem appears to be that >> setting GCC -f flags using this method will cause it to forget about some >> or all other optimization settings that have been applied. >> >> So the only safe way to disable the stack protector is to disable it for >> the entire source file. >> >> [0] https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html >> >> Cc: Michael Ellerman >> Cc: Benjamin Herrenschmidt >> Cc: Paul Mackerras >> Cc: Nick Desaulniers >> Cc: Arvind Sankar >> Cc: Randy Dunlap >> Cc: Josh Poimboeuf >> Cc: Thomas Gleixner >> Cc: Alexei Starovoitov >> Cc: Daniel Borkmann >> Cc: Peter Zijlstra (Intel) >> Cc: Geert Uytterhoeven >> Cc: Kees Cook >> Fixes: 7053f80d9696 ("powerpc/64: Prevent stack protection in early boot") >> Signed-off-by: Ard Biesheuvel >> --- >> Related discussion here: >> https://lore.kernel.org/lkml/CAMuHMdUg0WJHEcq6to0-eODpXPOywLot6UD2=GFHpzoj_hCoBQ@mail.gmail.com/ >> >> TL;DR using __attribute__((optimize("-fno-gcse"))) in the BPF interpreter >> causes the compiler to forget about -fno-asynchronous-unwind-tables passed >> on the command line, resulting in unexpected .eh_frame sections in vmlinux. >> >> arch/powerpc/kernel/Makefile | 3 +++ >> arch/powerpc/kernel/paca.c | 2 +- >> arch/powerpc/kernel/setup.h | 6 ------ >> arch/powerpc/kernel/setup_64.c | 2 +- >> 4 files changed, 5 insertions(+), 8 deletions(-) Thanks for the patch. > FYI i was notified by one of the robots that I missed one occurrence > of __nostackprotector in arch/powerpc/kernel/paca.c > > Let me know if I need to resend. That's fine I'll fix it up when applying. With the existing code, with STACKPROTECTOR_STRONG=y, I see two functions in setup_64.c that are triggering stack protection. One is __init, and the other takes no parameters and is not easily reachable from userspace, so I don't think losing the stack canary on either of those is a concern. I don't see anything in paca.c triggering stack protection. I don't think there's any evidence this is causing a bug for us, so I'll plan to put this in next for v5.11. cheers