Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp99961ybh; Mon, 9 Mar 2020 17:09:57 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuVe0Tmcywt0qimL6hyIeRPEDXkECuUAtxxMnKLaelwscOuStXn3C1Mz8vh4xcouKFVBNEw X-Received: by 2002:aca:4a86:: with SMTP id x128mr1293460oia.29.1583798997178; Mon, 09 Mar 2020 17:09:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583798997; cv=none; d=google.com; s=arc-20160816; b=AEnIqEt6tqSLYT70WgnjwHXjAtvBDpbE1pucVg8zf2oT+qZmjmVD49uuPJOBShd9K7 iONL9GDSNFxfsMaK2VSIJ8dglmREy4CI3mY/NYmfgM8eqfjlH6ct4Ie4lqfn9OLug2Bp ZJVoSXu4zkmAtYYNvWpP6cHL8VeJjHAOTwx/qgarFNfl+/FqWnb2RfGvpTLgJXtNe9Hj 2oaEFj003ap+EapjR1VX70+JC/fUkAxbofagrbYrFH5n/nQQ8kx4E4/bIs7FwQz1wDQb GG5xIkMdokRfFzUoOSLR+4YSwI2rW8gb6Kg3dfuDp5bn3o3KhGdYgcCctGRWGk0vmUvs 0eOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=nOkimidvyE/85zDjV2EvZo2MwwHSxFziV1SbX9R/ibI=; b=PRUh1tN8aJmrUx9P0Hmuna8yeW2+dxWnWXaoZwXz6KjGI7Q7wxOTwMUlJYMpWVm/b1 kCGL1St4S9oRLRP0rCj/QzN8o//fQUW8IcpbaUUCFlinUxF3ySxNDW+Wda2IZE2jel77 9W8ZkJiFsBFlu0kcWYiSn0kBHrjHGx7utKyfzv2WuEOzCqG2SqP0myKo1Y/vHL5Q9dN2 QGyVzdgTN07ZycuJCYBj1Aj3EHHfeFr94p8iyv/+Yj+oHG8UysqJ9tO6evU50XaNPrXP wlwrR2wf8BHByjwE39XVIA59cLRSyhO+riOExDNPKnnD+8rvOx4N7BD7KrqV0MFgmJE5 wd7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GmWZ2zNy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d83si3048311oig.5.2020.03.09.17.09.45; Mon, 09 Mar 2020 17:09:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GmWZ2zNy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727488AbgCJAJM (ORCPT + 99 others); Mon, 9 Mar 2020 20:09:12 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:39728 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727242AbgCJAJL (ORCPT ); Mon, 9 Mar 2020 20:09:11 -0400 Received: by mail-lj1-f196.google.com with SMTP id f10so12092324ljn.6; Mon, 09 Mar 2020 17:09:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nOkimidvyE/85zDjV2EvZo2MwwHSxFziV1SbX9R/ibI=; b=GmWZ2zNy3pBOaZKriqQ+ELzUA3ZkISmORCjefwTdN4b6GxnT8oDZNXtKGfqGeLb0xN IiiTUGNMcYuPt78bzuCu2JseD2cKOcG2BKIbBv1nrDraA4IiFTuiOIGeLR9XtJWTSHSU o5Y/SCO0xHIPL/s3Pnm9NltrhNpdm7orHHx5Ul5VHu3SlrFWDRkRvpCRJoKDfkv8aok4 7gSVUyGypCeG5yDuly7tpN0rQT+gi/PCLpHd+t/JsrbziukkSxb5v8o0NeMAsDbF2NF7 CYyb5DSfuCPlfnZdjg8XkFrrco44Kf7YR9qedQo6F6nt1XP0LKndiRnpRysETF81WdNy m3cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nOkimidvyE/85zDjV2EvZo2MwwHSxFziV1SbX9R/ibI=; b=EtgbDLQ7rNknyA+IkoYfcGZlC8R+faRu7iOL8ZH+I5Qqv1Q+7x5huVL1C1ww3ZQXXw 1Dca9XjpXBMZBSEfp5xpuabMacoDwDjhNVWxc2vKANY1N7+sh089LDR0PMONd1jiEbvv s8W6VqmHZb7X1CZXX3ttH2LVbkVTHm5N+Qx8oAJuC/t3BJS7qFtYtVHxZgLOnlLx86yi 58RohfCdgXRKMEMtDU4AMRk4RLqNXxiiyKde7DIOR7YonFjH4w6dpyOc6bcpRS27WFmC pqysuDFBbTsN3UbEXWtY1Syf3xCNa6ziDkD2Ox7jiW7QkI3aDHpp53rttlBBHKWUquBE HMwA== X-Gm-Message-State: ANhLgQ1m1HLFXEX8tlwsWha2lbXqHYTuVmrrKr/65MVGEBB6ulBOo5Hr 72cmSVlWMKEl3N0wzNYBMc6gv2VmzANzrFmcIJY= X-Received: by 2002:a2e:9b90:: with SMTP id z16mr11153242lji.254.1583798948111; Mon, 09 Mar 2020 17:09:08 -0700 (PDT) MIME-Version: 1.0 References: <0088001c-0b12-a7dc-ff2a-9d5c282fa36b@intel.com> <56ab33ac-865b-b37e-75f2-a489424566c3@intel.com> In-Reply-To: From: "H.J. Lu" Date: Mon, 9 Mar 2020 17:08:29 -0700 Message-ID: Subject: Re: [RFC PATCH v9 01/27] Documentation/x86: Add CET description To: Andy Lutomirski Cc: Dave Hansen , Yu-cheng Yu , "the arch/x86 maintainers" , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , LKML , "open list:DOCUMENTATION" , Linux-MM , linux-arch , Linux API , Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , x86-patch-review@intel.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 9, 2020 at 4:59 PM Andy Lutomirski wrote: > > On Mon, Mar 9, 2020 at 4:52 PM H.J. Lu wrote: > > > > On Mon, Mar 9, 2020 at 4:21 PM Dave Hansen wrote: > > > > > > On 3/9/20 4:11 PM, H.J. Lu wrote: > > > > A threaded application is loaded from disk. The object file on disk is > > > > either CET enabled or not CET enabled. > > > > > > Huh. Are you saying that all instructions executed on userspace on > > > Linux come off of object files on the disk? That's an interesting > > > assertion. You might want to go take a look at the processes on your > > > systems. Here's my browser for example: > > > > > > # for p in $(ps aux | grep chromium | awk '{print $2}' ); do cat > > > /proc/$p/maps; done | grep ' r-xp 00000000 00:00 0' > > > ... > > > 202f00082000-202f000bf000 r-xp 00000000 00:00 0 > > > 202f000c2000-202f000c3000 r-xp 00000000 00:00 0 > > > 202f00102000-202f00103000 r-xp 00000000 00:00 0 > > > 202f00142000-202f00143000 r-xp 00000000 00:00 0 > > > 202f00182000-202f001bf000 r-xp 00000000 00:00 0 > > > > > > Lots of funny looking memory areas which are anonymous and executable! > > > Those didn't come off the disk. Same thing in firefox. Weird. Any > > > idea what those are? > > > > > > One guess: https://en.wikipedia.org/wiki/Just-in-time_compilation > > > > jitted code belongs to a process loaded from disk. Enable CET in > > an application which uses JIT engine means to also enable CET in > > JIT engine. Take git as an example, "git grep" crashed for me on Tiger > > Lake. It turned out that git itself was compiled with -fcf-protection and > > git was linked against libpcre2-8.so.0 also compiled with -fcf-protection, > > which has a JIT, sljit, which was not CET enabled. git crashed in the > > jitted codes due to missing ENDBR. I had to enable CET in sljit to make > > git working on CET enabled Tiger Lake. So we need to enable CET in > > JIT engine before enabling CET in applications which use JIT engine. > > This could presumably have been fixed by having libpcre or sljit > disable IBT before calling into JIT code or by running the JIT code in > another thread. In the other direction, a non-CET libpcre build could > build IBT-capable JITted code and enable JIT (by syscall if we allow > that or by creating a thread?) when calling it. And IBT has this This is not how thread in user space works. > fancy legacy bitmap to allow non-instrumented code to run with IBT on, > although SHSTK doesn't have hardware support for a similar feature. All these changes are called CET enabing. > So, sure, the glibc-linked ELF ecosystem needs some degree of CET > coordination, but it is absolutely not the case that a process MUST > have all CET or no CET. Let's please support the complicated cases in > the kernel and the ABI too. If glibc wants to make it annoying to do > complicated things, so be it. People work behind glibc's back all the > time. CET is no different from NX in this regard. -- H.J.