Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1429064rwd; Tue, 16 May 2023 17:37:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7NwJXMSnyNeI5qjBezs2StLvu9cPTwU/Fz/Z4G0koHu4ft7pBTqaS2/A9dAJb+6DTT15Js X-Received: by 2002:a17:902:74c6:b0:1ad:b5f4:dfd5 with SMTP id f6-20020a17090274c600b001adb5f4dfd5mr23617321plt.32.1684283821028; Tue, 16 May 2023 17:37:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684283821; cv=none; d=google.com; s=arc-20160816; b=Gi/b7g63A4zzsv9X57n7ryV101v9qAkZEE6aKXURew6laYKVRZmyPD3gJSwSiweonx P7KSIcYfhTmxnVpncAV+tRtiV8RmPsCHYC5uPgAIpEnrq3LVrpVreQ8Lq4D3jg4/2sWK CttneNy4/leiBRJFql2R86se87h9j8RAW0Rr+nTj2puU5+DVVsax/8zCIfcEHYM3lDBu Yzf86msRLv76xvaFCuz6waCLaEGRK/YNl1OSmJ62WfRFlf6+rL4pDlxPYj74rZyKtwqj hDAp/G33o5L+URDDS+Ca97lWNYOeNEguwxsPF8EBqZOM/Q0OGs5wzuYG/qBaZ02YSbV/ gP3A== 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=pTpjK4cMLE86CEBQAy0o7c1MtYlIewmfVg/CfBkzS8g=; b=iYk5BhRzM8RK28j5aMaToBAL52tEdiHw/hLQFLGTBqYOcxw69+EkOSYM+o2qVr5GJz REBsR4VNtOsd06RhKjApYs151A7b02uwF6dOvGjHUDQ6o1rpMluoFNVazArh5LBdoG2D bpS5x/TGc4c76YK0jeYGcHHJ7jWJvWRFjzxq4VrNa5qh8IN4DBsOMiNvrdcntKOHVf8m Vpe3aeUWaGYpt3/5NJUiJumC4oKr3mzh7npjFOQmDvHBWlwx25y2kkYxgYInV31YGodi UKLl5EMLvuvCMUSm72zXsAoDBtYQYZdnv7T50SBAEi7+9jCEtcw2Nvzku8zd6tP+/j8/ KqtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="S6BjV/ln"; 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 y13-20020a170902b48d00b001aacffacf0bsi18936183plr.570.2023.05.16.17.36.49; Tue, 16 May 2023 17:37:01 -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="S6BjV/ln"; 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 S229458AbjEPX4L (ORCPT + 99 others); Tue, 16 May 2023 19:56:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231286AbjEPX4J (ORCPT ); Tue, 16 May 2023 19:56:09 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C7FF59C4 for ; Tue, 16 May 2023 16:56:08 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-50bf7bb76d0so1974a12.0 for ; Tue, 16 May 2023 16:56:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684281366; x=1686873366; 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=pTpjK4cMLE86CEBQAy0o7c1MtYlIewmfVg/CfBkzS8g=; b=S6BjV/lnZHhJsIdjUWkam5dY6C+mo1ieKbzG4UHHJfBP49QZq6QLvGuaPjGHLXxg/T 2QagfQVirGsBg/WEz5YrT6PSrDAffE5c/5zcneGPlcQfp6acvCmYADqIKiJ/FMKfkli7 W/TOL5WsLXPtrVzsCEwS76u2cllo0vfS7FRghu1qjn2qa86TDxkloHLOdW8YtVducYW+ 4LzQP8VLdDH9r59mpqDKgyoE8+N98u8OiBpf6tBCB/dnc2pOeAJcRTGxMHTWlrs6OFTM AVQcqOxRBEfW+4lavr1y5FtR31v5l2iTxXulaHqdpy3WEh02cuRJFKF1KpDuUZnmMcEk eoFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684281366; x=1686873366; 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=pTpjK4cMLE86CEBQAy0o7c1MtYlIewmfVg/CfBkzS8g=; b=VB99/jD2vvCCcmNlFgMxU7NYn2h8gIDV29D4T9PVgovD4X2Us4PRbNJA7ReyOV5rV5 xsFeee+XFTFx+3DjTwtnXztEOyKBVbrY1xCWEt6xRdyABHjvTv5bZZNKvbDCWvz97zlS Byac4Q2uQLmgWwSC8cE9yRWOQKCKLQ06g79ui2e+hp+vofast7MT+Mg4a9vTQEPZhPiE UvC2hjCZeNWOkcz2yC5/wYxEN8zWDxJAn0QrhHfOZ2TGyTzz2DJC1ofonDL/BILfcMPx UUZBsPvaSAVR5auaKlmTZ1Ym7Vz7c915o4R5MJPwLsKPmcE/rkcjeArlQKuGhcSn79gF DmfQ== X-Gm-Message-State: AC+VfDxERDGFQahH/gwbNegSoXqvlkrHoYj+bXZgic1kefypddAnati0 LGs0yraFCBAjg1t9zvs1U1ocjwnorSDPe6L4XRpPEg== X-Received: by 2002:a50:8752:0:b0:50d:bb88:a80c with SMTP id 18-20020a508752000000b0050dbb88a80cmr19046edv.3.1684281365993; Tue, 16 May 2023 16:56:05 -0700 (PDT) MIME-Version: 1.0 References: <20230515130553.2311248-1-jeffxu@chromium.org> <20230515130553.2311248-2-jeffxu@chromium.org> <6cb7df56-0479-30be-5389-b4b819572deb@intel.com> In-Reply-To: <6cb7df56-0479-30be-5389-b4b819572deb@intel.com> From: Jeff Xu Date: Tue, 16 May 2023 16:55:28 -0700 Message-ID: Subject: Re: [PATCH 1/6] PKEY: Introduce PKEY_ENFORCE_API flag To: Dave Hansen Cc: jeffxu@chromium.org, luto@kernel.org, jorgelo@chromium.org, keescook@chromium.org, groeck@chromium.org, jannh@google.com, sroettger@google.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=unavailable 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 Tue, May 16, 2023 at 4:14=E2=80=AFPM Dave Hansen = wrote: > > On 5/15/23 06:05, jeffxu@chromium.org wrote: > > --- a/arch/x86/mm/pkeys.c > > +++ b/arch/x86/mm/pkeys.c > > @@ -20,7 +20,7 @@ int __execute_only_pkey(struct mm_struct *mm) > > /* Do we need to assign a pkey for mm's execute-only maps? */ > > if (execute_only_pkey =3D=3D -1) { > > /* Go allocate one to use, which might fail */ > > - execute_only_pkey =3D mm_pkey_alloc(mm); > > + execute_only_pkey =3D mm_pkey_alloc(mm, 0); > > if (execute_only_pkey < 0) > > return -1; > > need_to_set_mm_pkey =3D true; > > In your threat model, what mechanism prevents the attacker from > modifying executable mappings? > > I was trying to figure out if the implicit execute-only pkey should have > the PKEY_ENFORCE_API bit set. I think that in particular would probably > cause some kind of ABI breakage, but it still reminded me that I have an > incomplete picture of the threat model. Yes. The main reason for not adding it now is the ABI breakage. As a next step, we could potentially develop mseal(), which fits more to the code segment. The PKEY_ENFORCE_API allows munmap(), so the user case is slightly differen= t. I will leave the threat model / V8 specific question to Stephan.