From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E6BAC433DF for ; Mon, 29 Jun 2020 14:45:03 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3E91423E1F for ; Mon, 29 Jun 2020 14:45:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="0vHC41kT"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="FcI9HcFN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E91423E1F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AuSdoqz7x4cFaf2SrGwg4iYbDtCIJj/Kfc2y5Fk51xQ=; b=0vHC41kTewgLQFmlXju+9gHH3 rcHOK/Qm3nQj/RX7Nm3z1fEgg14l6eO5RlCom/JqY0WzYbj8GpbAmdQ73mywT5nrguGXxAOSicbQP gr5i9pnCluuj1OAzlPH9CWVT8dyBy3b85aB45GdfnwOCTfLqJeT5uWpaCeEW9PB20V5t12JSay3no CpO52Vl+0Ip1guCvToHrUb+OwrJKnISh4bXyIoXFJCs2Qlw4qjkLI3gXeBo+JWogOCb14RCgv8bxN qQvKx2yDIuOu4/BZamjIoch+/s0UYfbVSQjGkOLq2BUnAV2f2pK7oZ0ZNIbLn6RDs4bHN5HzAdtQE oS/0ncv7A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jpv0Z-0006At-8G; Mon, 29 Jun 2020 14:43:43 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jpv0W-0006AH-Hn for linux-arm-kernel@lists.infradead.org; Mon, 29 Jun 2020 14:43:41 +0000 Received: by mail-pl1-x641.google.com with SMTP id x11so7177753plo.7 for ; Mon, 29 Jun 2020 07:43:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Yi6JXAo1ZyKdvYW2lysqRB4X8J5GEgjfQlw9nhW0Ebg=; b=FcI9HcFNnmkS7xOHrCLlNWmbbi80f8MLjkp0bTXWTdF+IBlRUCurEMLoVIR7Yt57B0 mhPSrFkFF78lCAtSinaJ6aJX97k5zhtcFaxInJWiI7oACyaPmRvWRoa5/N4zzTpu+TPl VXPrT6yEUnDqZ0d1u9easG3Ru3Qjw96EneDF4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Yi6JXAo1ZyKdvYW2lysqRB4X8J5GEgjfQlw9nhW0Ebg=; b=ROrO212PNkcIJfTXQ8jB1PXL76xBXRqTfoHweumX4jj7e7lAWAWF6kupz2Jl8ke+Yn NWv/bR6I9vV+xoWABhFkt2jXDKfi95eCp28Be60tSBY30JonALsBYbUGEHn9ZMOCVOYT xMI+fM1C2pg8nUEesR8Cs7peO7ts+c6fzP9L38Tjrm2Iqn8AuaKAOdAqH93T03dXcjbn 1wvMA5IhKQ3ac6HLdWpAXj5uO70JvGSGNJ7SgiervjJrMWf27t1omK+ijlSPOlT1DfbW Zcv2gxpSOOOAQjfycyZwKiR96ncj42XqZ8OXr+Zzi26B2Vu4eXU4XSJ/WVAPmjypt6kz MYXg== X-Gm-Message-State: AOAM532S33eJUh5dU9uVRyrRmIpsLOCudTDE/OaqhNw5xmXNzRUpF7rY t9FebrWXGnHeQzh876/INr2MNQ== X-Google-Smtp-Source: ABdhPJwybf+0t6W88LuU35gXB6jzrCSMoNi9aseWcKSgTK9Lcgit7BB1R8CrmUhMywtQcxnrnSW8RQ== X-Received: by 2002:a17:902:9346:: with SMTP id g6mr13542327plp.19.1593441818365; Mon, 29 Jun 2020 07:43:38 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id 25sm58832pfi.7.2020.06.29.07.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 07:43:37 -0700 (PDT) Date: Mon, 29 Jun 2020 07:43:36 -0700 From: Kees Cook To: Ard Biesheuvel Subject: Re: [PATCH v4 05/17] ctype: Work around Clang -mbranch-protection=none bug Message-ID: <202006290742.92EC7235@keescook> References: <20200629061840.4065483-1-keescook@chromium.org> <20200629061840.4065483-6-keescook@chromium.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , linux-arch , linux-efi , Arnd Bergmann , Peter Collingbourne , Masahiro Yamada , X86 ML , Nick Desaulniers , Russell King , Linux Kernel Mailing List , Nathan Chancellor , clang-built-linux , Arvind Sankar , Ingo Molnar , James Morse , Catalin Marinas , Thomas Gleixner , Borislav Petkov , Will Deacon , Dave Martin , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jun 29, 2020 at 10:15:47AM +0200, Ard Biesheuvel wrote: > On Mon, 29 Jun 2020 at 08:18, Kees Cook wrote: > > > > In preparation for building efi/libstub with -mbranch-protection=none > > (EFI does not support branch protection features[1]), add no-op code > > to work around a Clang bug that emits an unwanted .note.gnu.property > > section for object files without code[2]. > > > > [1] https://lore.kernel.org/lkml/CAMj1kXHck12juGi=E=P4hWP_8vQhQ+-x3vBMc3TGeRWdQ-XkxQ@mail.gmail.com > > [2] https://bugs.llvm.org/show_bug.cgi?id=46480 > > > > Cc: Ard Biesheuvel > > Cc: Will Deacon > > Cc: Dave Martin > > Cc: clang-built-linux@googlegroups.com > > Signed-off-by: Kees Cook > > --- > > lib/ctype.c | 10 ++++++++++ > > 1 file changed, 10 insertions(+) > > > > diff --git a/lib/ctype.c b/lib/ctype.c > > index c819fe269eb2..21245ed57d90 100644 > > --- a/lib/ctype.c > > +++ b/lib/ctype.c > > @@ -36,3 +36,13 @@ _L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L, /* 224-239 */ > > _L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L}; /* 240-255 */ > > > > EXPORT_SYMBOL(_ctype); > > + > > +/* > > + * Clang will generate .note.gnu.property sections for object files > > + * without code, even in the presence of -mbranch-protection=none. > > + * To work around this, define an unused static function. > > + * https://bugs.llvm.org/show_bug.cgi?id=46480 > > + */ > > +#ifdef CONFIG_CC_IS_CLANG > > +void __maybe_unused __clang_needs_code_here(void) { } > > +#endif > > -- > > 2.25.1 > > > > I take it we don't need this horrible hack if we build the EFI stub > with branch protections and filter out the .note.gnu.property section > explicitly? Correct. > Sorry to backpedal, but that is probably a better approach after all, > given that the instructions don't hurt, and we will hopefully be able > to arm them once UEFI (as well as PE/COFF) gets around to describing > this in a way that both the firmware and the OS can consume. Okay, will revert to the v3 solution. -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel