Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2490009rwb; Mon, 7 Nov 2022 14:03:07 -0800 (PST) X-Google-Smtp-Source: AMsMyM6CGYvm5d/4kl7SW5CyYoZCfgM0HyZvGDcSGjKzOOFe1gLydkrlr41XTAenXajD+WNTayoK X-Received: by 2002:a17:907:1ddd:b0:7ad:8371:b59c with SMTP id og29-20020a1709071ddd00b007ad8371b59cmr49255723ejc.429.1667858587387; Mon, 07 Nov 2022 14:03:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667858587; cv=none; d=google.com; s=arc-20160816; b=SqjtaDhccoNLATfCHju9fqZrgQI/wLiLS8R31BRrRdesmxnxgCagBofWu7H/rUE2Di d/QdzZKSTpb30xwHHLm1ge+6fLwNUqfJRIj/3vOz+H0rKpn4vw2xWZFYIrKEuiRMDXdl PxdhnUvcC4NTr9wYvwvzhWNyLYFWUs0lJmRQHIoCG+W4Anm6kEJgL6q3XWAfNyDJ4+O5 5tOqj6K7PHu2W2a8g8MsO4A/y0uWgV7IhVM2MibO+CAl+QrJnfFJSF/MQdbGTqSToIYw bQj6bDM8XcWhBM/BveGuTJsq/4EAF5ia79zZpbgm9f5znOJqpgOx0paxIaIei7LYO4Be lLdQ== 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=2p+o/wwFzaQT3YrtLLy11P/EQH0km3heDCq7YaIDuHE=; b=zOhmaqyxhdJkM6ezb6irk73zP6PoiXgyUPwmz5gf1EDcAHT9Zl7u6qT+PSOyjmPlqO w0FrRWm5XUGkgfdXkK+56LpYalyc2LsrFyRK57NYcUZLI0X95TD1VjLXGjSkR5EIkapB GOq6mjwqxJPetSfCcbg6OtCU/yMr3Tvswo1ecUknbTy+b1hK151vE8+I8MkPHQWuElC0 LNMpvizVRFZ6sS5YsHyIRUD7/HdsiZZDDjI04+As7KEIjo+k38G4a2lWLJyLx8Ln91jv pe1XB66BLilLdjDnxmQrf01BTR1PK5KlcqJXn4t36yhwxNmGa1GHVKkaeD52yiyFbC4E SReQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Kjm0WJEa; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go35-20020a1709070da300b0078d44c5da0esi11010004ejc.667.2022.11.07.14.02.45; Mon, 07 Nov 2022 14:03:07 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Kjm0WJEa; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233073AbiKGVXA (ORCPT + 91 others); Mon, 7 Nov 2022 16:23:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233037AbiKGVWm (ORCPT ); Mon, 7 Nov 2022 16:22:42 -0500 Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF726102F; Mon, 7 Nov 2022 13:22:26 -0800 (PST) Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-13b103a3e5dso14187609fac.2; Mon, 07 Nov 2022 13:22:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=2p+o/wwFzaQT3YrtLLy11P/EQH0km3heDCq7YaIDuHE=; b=Kjm0WJEazxNniutHxpP/iWzp30/ucmFoXjNcrqKBpDby8wMAHcWjC5s4iDf2e1EXPU 9xz7D01nAcLCLqWCrR1zC2fFZzsjL+V0hbcDxyZ2MGgrOk0zHpKczXOloTnlEEv1deLg kB2xq9pVDzuFnsL69XzNC291l8iCoDoWbczQBS06d5MwKJP/7YjEoJEO/T4+gMdf6CU7 xOvRZApZvcxriK3UXAqxM81rho6C1vJkQy2v8jpIkMH8ly0JVq0kwdaaCwCucT9zVfEZ 2kDlegWL+kb1CarsoXje0G8gr736QSdt52a9sQSckDoMLfEAOO7/z3AB7Sc35g+EAExm Y6ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=2p+o/wwFzaQT3YrtLLy11P/EQH0km3heDCq7YaIDuHE=; b=JiZDxAcWe0Q2eeQsgTX1ZwTMI5T7E1gXfRQ6bUCdXywOkZqEpByyCEwKoSwWp4b7Ry OstV9f6BhKiNKNyNfsClkULXBPGwWQA3EeygJ6hMrB8Ixdh7eZ7CbgJF7rkli/3VeGo/ eQC8Hn0I/t50fFerYDngTDCecZyrD63DEClm/eMUMSTul0k8T3zMg0q83k6oeWf5knly yWilHFf/vQRiF7keb2W1UiefxgLFo1zGt/aTMAtZ27Gzk34Rfg0RUVLs/eppYMlvEJty mID6WBBoJliUauKPXjyT5DKA6nuhEETn/Q7ZtTdHkE7n78JN/LGaoLxmmtPej0r3iUIN TcwQ== X-Gm-Message-State: ACrzQf30As744iKtds4e89jP6IGZQ03xOMdMh8EE/hHy04w93t4T/2NK 3bP579MyRqn7fErZbJVe1sWlUH6rFwlULrX/I04= X-Received: by 2002:a05:6870:f5a4:b0:136:3e0d:acdd with SMTP id eh36-20020a056870f5a400b001363e0dacddmr32962986oab.298.1667856145978; Mon, 07 Nov 2022 13:22:25 -0800 (PST) MIME-Version: 1.0 References: <20221104223604.29615-1-rick.p.edgecombe@intel.com> <20221104223604.29615-38-rick.p.edgecombe@intel.com> <87iljs4ecp.fsf@oldenburg.str.redhat.com> <87h6zaiu05.fsf@oldenburg.str.redhat.com> <73b8f726c424db1af1c10a48e101bf74703a186a.camel@intel.com> In-Reply-To: <73b8f726c424db1af1c10a48e101bf74703a186a.camel@intel.com> From: "H.J. Lu" Date: Mon, 7 Nov 2022 13:21:49 -0800 Message-ID: Subject: Re: [RFC 37/37] fs/binfmt_elf: Block old shstk elf bit To: "Edgecombe, Rick P" Cc: "bsingharora@gmail.com" , "hpa@zytor.com" , "Syromiatnikov, Eugene" , "peterz@infradead.org" , "rdunlap@infradead.org" , "keescook@chromium.org" , "Yu, Yu-cheng" , "Eranian, Stephane" , "kirill.shutemov@linux.intel.com" , "dave.hansen@linux.intel.com" , "linux-mm@kvack.org" , "fweimer@redhat.com" , "nadav.amit@gmail.com" , "jannh@google.com" , "dethoma@microsoft.com" , "kcc@google.com" , "linux-arch@vger.kernel.org" , "bp@alien8.de" , "oleg@redhat.com" , "Yang, Weijiang" , "Lutomirski, Andy" , "jamorris@linux.microsoft.com" , "arnd@arndb.de" , "akpm@linux-foundation.org" , "pavel@ucw.cz" , "mike.kravetz@oracle.com" , "x86@kernel.org" , "linux-doc@vger.kernel.org" , "tglx@linutronix.de" , "john.allen@amd.com" , "rppt@kernel.org" , "mingo@redhat.com" , "Shankar, Ravi V" , "corbet@lwn.net" , "linux-kernel@vger.kernel.org" , "linux-api@vger.kernel.org" , "gorcunov@gmail.com" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 On Mon, Nov 7, 2022 at 1:11 PM Edgecombe, Rick P wrote: > > On Mon, 2022-11-07 at 11:10 -0800, H.J. Lu wrote: > > On Mon, Nov 7, 2022 at 9:47 AM Edgecombe, Rick P > > wrote: > > > > > > On Mon, 2022-11-07 at 17:55 +0100, Florian Weimer wrote: > > > > * Rick P. Edgecombe: > > > > > > > > > On Sun, 2022-11-06 at 10:33 +0100, Florian Weimer wrote: > > > > > > * H. J. Lu: > > > > > > > > > > > > > This change doesn't make a binary CET compatible. It just > > > > > > > requires > > > > > > > that the toolchain must be updated and all binaries have to > > > > > > > be > > > > > > > recompiled with the new toolchain to enable CET. It > > > > > > > doesn't > > > > > > > solve > > > > > > > any > > > > > > > issue which can't be solved by not updating glibc. > > > > > > > > > > > > Right, and it doesn't even address the library case (the > > > > > > kernel > > > > > > would > > > > > > have to hook into mmap for that). The kernel shouldn't do > > > > > > this. > > > > > > > > > > Shadow stack shouldn't enable as a result of loading a library, > > > > > if > > > > > that's what you mean. > > > > > > > > It's the opposite=E2=80=94loading incompatible libraries needs to d= isable > > > > shadow > > > > stack (or ideally, not enable it in the first place). > > > > > > The glibc changes I have been using would not have enabled shadow > > > stack > > > in the first place unless the execing binary has the elf bit. So > > > the > > > binary would run as if shadow stack was not enabled in the kernel > > > and > > > there should be nothing to disable when an incompatible binary is > > > loaded. Glibc will have to detect this and act accordingly because > > > not > > > all kernels will have shadow stack configured. > > > > > > > Technically, I > > > > think most incompatible code resides in libraries, so this kernel > > > > change > > > > achieves nothing besides punishing early implementations of the > > > > published-as-finalized x86-64 ABI. > > > > > > It's under the assumption that not breaking things is more > > > important > > > than having shadow stack enabled. So it is not intended as a > > > punishment > > > for users at all, rather the opposite. > > > > > > I'm not sure how much the spec mandates things by the letter of it, > > > but > > > in any case things have gone wrong in the real world. I am very > > > open to > > > discussion here. I only went this way as a last resort because I > > > didn't > > > hear back on the last thread. > > > > Some applications and libraries are compiled with -fcf-protection, > > but > > they manipulate the stack in such a way that they aren't compatible > > with the shadow stack. However, if the build/test setup doesn't > > support > > shadow stack, it is impossible to validate. > > > > When we have everything in place, the problems would be much more > obvious when distros started turning it on. But we can't turn it on as Not necessarily. The problem will show up only in a CET enabled environment since build/test setup may not be on a CET capable hardware. > planned without breaking things for existing binaries. We can have both > by: > 1. Choosing a new bit, adding it to the tools, and never supporting the > old bit in glibc. > 2. Providing the option to have the kernel block the old bit, so > upgraded users can decide what experience they would like. Then distros > can find the problems and adjust their packages. I'm starting to think > a default off sysctl toggle might be better than a Kconfig. > 3. Any other ideas? Don't enable CET in glibc until we can validate CET functionality. --=20 H.J.