Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp266637rwd; Tue, 16 May 2023 00:19:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4s3/LYahVVh0924nbuIsPyM8TLmiG+TJF6alYt4ilo4sy1hXfDQ7Bb6r/t1E5TJTlcPHKj X-Received: by 2002:a05:6a20:4658:b0:ec:7e0c:5546 with SMTP id eb24-20020a056a20465800b000ec7e0c5546mr38224149pzb.7.1684221588601; Tue, 16 May 2023 00:19:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684221588; cv=none; d=google.com; s=arc-20160816; b=TLFbVizm70nl0xZgAgvWdveLu1BVtYsrsSh8aadRvkSUiYh2U58PNQRVcywNqTYRmT VkQo7d0fI+V5TiycVEalzRwc5SIEOKE6PkYOQ8CfM3U2t0Z+s5ThPOfSWkNsYL0opYBD EpAl4mK+/T6cqLFL8kECIfSmiAU8YnVCayJF7/FgiXIuwCcffKP/u6KsC330KPT+uY8G 25PNOa7+MyYGme1RHLTmF9P6KUF4tSzI1NSLrRnME6n/fTTAGIKw2jCboyCRr26YAUbh kEPF2bJT5bVel01mDi9QJCJkQdDRLfgvXenUVad5AGZXFp7/rxw29WyR/bTht1oU4ZmR PPtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=EcsUMgaVLa7Lx3vJSziGf4X4psvz0m2gfilxI+//RuM=; b=XYhZjYc36LrttAWoIO11OohWq+5IzYTawSdLXtz0Fe9EkFgafgBFa25QYSJOMse1iM /7uEo7JKvKsK2wctGqkWbZUrV6zKprvNmcyUaUVdCPvV1VuaBl8MlWd3vHJARZ+2OGMA ETkz5ChViS2MsNLcqORvlVaryNR1LPCOvKAcms6iq58cks8SJ1aSCy7CNqJQHHRtKWsY 5PB8p/7xWImUXJ2jaY2WwdYPK4rnqBbxXIJis6TW4b/mqBf4K9xkV2mwAoR/G/CpGRpM caQAYSrpbtzBo4pV3j4q/KFkXgWryRSmpQvlaBy3i+Dm0iouflQjDQO4cO+8NWrAjWkr G8dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="GpWjCi/S"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ca2-20020a17090af30200b0024df0aab0e2si1185526pjb.8.2023.05.16.00.19.34; Tue, 16 May 2023 00:19:48 -0700 (PDT) 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=@google.com header.s=20221208 header.b="GpWjCi/S"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230455AbjEPHGu (ORCPT + 99 others); Tue, 16 May 2023 03:06:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230447AbjEPHGs (ORCPT ); Tue, 16 May 2023 03:06:48 -0400 Received: from mail-vs1-xe34.google.com (mail-vs1-xe34.google.com [IPv6:2607:f8b0:4864:20::e34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDD6112D for ; Tue, 16 May 2023 00:06:46 -0700 (PDT) Received: by mail-vs1-xe34.google.com with SMTP id ada2fe7eead31-4361225a745so2856391137.2 for ; Tue, 16 May 2023 00:06:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684220806; x=1686812806; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=EcsUMgaVLa7Lx3vJSziGf4X4psvz0m2gfilxI+//RuM=; b=GpWjCi/SCbtfJnh2yt3dYIE17gAUEdSa1jytjCWfuXn2PLnA3fJnXXVxSsLznz/b/X 4y/oK1Qhum4zQKl8TRwy7PKQN4SWuWy834g0mLRDw84zkK89c3Nc4CTowDotjiMO4ACK K+cYRBxZK/tiLNWMdEg2lnnSorcqOKx8fiR5gkxhA9mTHeDH/7U3bYTv6cwpeLgN5a5H hbcJ+ihb1M82Yvk16FQxJy82T1RTjfvEX6erTw02qzRMaA2CJ3McxiafjQt0FJGnsc92 d6hfsZ4tqN8DuwcwfsFa0L3jts5bb2a3y3b460oodONxnkzQM0nl/27hS0rpk11lb7Mr gjvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684220806; x=1686812806; h=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=EcsUMgaVLa7Lx3vJSziGf4X4psvz0m2gfilxI+//RuM=; b=dJ8Kfo53uvHvvanA0i5S5urfvHtlBKEgzOMV3LqdDy78RPh3TGx0IVBds7VX4VKCyP CWV8GmLOKYlZc3mKhcvtjBsYPKh4pcChnZCMFxZgDeBV06yMV1vk4y1L6pbTYEKFqwig 0NKtr1DZbuEn7yZiclN/AOV9tmozoQlT8NEwCl4pvUJh6VRpYvHV99zbMnS/G+dXPHIt x2bqrJe3ojbG6PxRUNl2UgWEyT7k9RQwAvw04r0qv0FqX5XvSxP1YMvj1XtPICDZU8gW TyHi6tdXQ5/ju7abjlikpc9JichottN65hOOPqOQ/VCmuAT+X5CkitQs+fXmbS3nj3+f grbA== X-Gm-Message-State: AC+VfDyR8Um4/v/A764cAGxsBM3HMIlu1nyOpyBYX5kTBUOVzK5V8f13 Knt9qY8oYfO7AsTE1d+A2NPpMI+zA89a14xaIqK6yg== X-Received: by 2002:a05:6102:303a:b0:42f:efd4:f170 with SMTP id v26-20020a056102303a00b0042fefd4f170mr12760499vsa.29.1684220805698; Tue, 16 May 2023 00:06:45 -0700 (PDT) MIME-Version: 1.0 References: <20230515130553.2311248-1-jeffxu@chromium.org> <2bcffc9f-9244-0362-2da9-ece230055320@intel.com> In-Reply-To: <2bcffc9f-9244-0362-2da9-ece230055320@intel.com> From: =?UTF-8?Q?Stephen_R=C3=B6ttger?= Date: Tue, 16 May 2023 09:06:32 +0200 Message-ID: Subject: Re: [PATCH 0/6] Memory Mapping (VMA) protection using PKU - set 1 To: Dave Hansen Cc: jeffxu@chromium.org, luto@kernel.org, jorgelo@chromium.org, keescook@chromium.org, groeck@chromium.org, jannh@google.com, akpm@linux-foundation.org, jeffxu@google.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-hardening@vger.kernel.org Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="000000000000df156d05fbca367a" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 --000000000000df156d05fbca367a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, May 15, 2023 at 4:28=E2=80=AFPM Dave Hansen = wrote: > > On 5/15/23 06:05, jeffxu@chromium.org wrote: > > We're using PKU for in-process isolation to enforce control-flow integr= ity > > for a JIT compiler. In our threat model, an attacker exploits a > > vulnerability and has arbitrary read/write access to the whole process > > space concurrently to other threads being executed. This attacker can > > manipulate some arguments to syscalls from some threads. > > This all sounds like it hinges on the contents of PKRU in the attacker > thread. > > Could you talk a bit about how the attacker is prevented from running > WRPKRU, XRSTOR or compelling the kernel to write to PKRU like at sigretur= n? (resending without html) Since we're using the feature for control-flow integrity, we assume the control-flow is still intact at this point. I.e. the attacker thread can't run arbitrary instructions. * For JIT code, we're going to scan it for wrpkru instructions before writing it to executable memory * For regular code, we only use wrpkru around short critical sections to temporarily enable write access Sigreturn is a separate problem that we hope to solve by adding pkey support to sigaltstack --000000000000df156d05fbca367a Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIIPoQYJKoZIhvcNAQcCoIIPkjCCD44CAQExDzANBglghkgBZQMEAgEFADALBgkqhkiG9w0BBwGg ggz7MIIEtjCCA56gAwIBAgIQeAMYYHb81ngUVR0WyMTzqzANBgkqhkiG9w0BAQsFADBMMSAwHgYD VQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UE AxMKR2xvYmFsU2lnbjAeFw0yMDA3MjgwMDAwMDBaFw0yOTAzMTgwMDAwMDBaMFQxCzAJBgNVBAYT AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMSowKAYDVQQDEyFHbG9iYWxTaWduIEF0bGFz IFIzIFNNSU1FIENBIDIwMjAwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvLe9xPU9W dpiHLAvX7kFnaFZPuJLey7LYaMO8P/xSngB9IN73mVc7YiLov12Fekdtn5kL8PjmDBEvTYmWsuQS 6VBo3vdlqqXZ0M9eMkjcKqijrmDRleudEoPDzTumwQ18VB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