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=-6.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 DD2C4C43461 for ; Wed, 5 May 2021 18:38:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 816A3613BF for ; Wed, 5 May 2021 18:38:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 816A3613BF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F3C3C6B0071; Wed, 5 May 2021 14:38:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F138D6B0072; Wed, 5 May 2021 14:38:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D8F366B0073; Wed, 5 May 2021 14:38:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0154.hostedemail.com [216.40.44.154]) by kanga.kvack.org (Postfix) with ESMTP id B9B536B0071 for ; Wed, 5 May 2021 14:38:42 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 77674824999B for ; Wed, 5 May 2021 18:38:42 +0000 (UTC) X-FDA: 78108038484.12.049FF60 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by imf29.hostedemail.com (Postfix) with ESMTP id B164E135 for ; Wed, 5 May 2021 18:38:36 +0000 (UTC) Received: by mail-pj1-f43.google.com with SMTP id x7-20020a17090a5307b02901589d39576eso437862pjh.0 for ; Wed, 05 May 2021 11:38:41 -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=POQGQj7ALoCPENTaHpI2WeLM1iSFaDi818aVBMGOLqw=; b=Db7y3p0IEKbFRtxFUuYHcc68qZZR873peN9d0aGG9tlw2rZmwTOGIz/dx5FTZ5Lphi 6fuBUvVN2bTS1kqRzIhmnlmKpakG8unMK8hTv9EYWQRvwhYHW7AFphwdkFb7ZpM7neay rktKL9ozidaqOd0M8nj1aEFODm3v9hbv8k6+Y= 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=POQGQj7ALoCPENTaHpI2WeLM1iSFaDi818aVBMGOLqw=; b=uhL9PcNdlSa33DQRi/83Uo21tzE05YdDCVFQRaazxOWO9LLfP7wxABGYMqMRLK8OLp gkLtbpFqHW++fgCwp23Ix4otuKg5zloJohYqS02L64WM4lmp83VOvDIu4yh6amTOeEue fhYF8GDtreGBPMtPJaGj3dUKiiXbBxEb5eE0twCwt4v2q096Daj5Zzyar8ZKqWZH78Un CVqUq0TLmkGzO0qqfbByi7na6GIUyQK3kS8pkZMXRvMsyTU+wI8VRv34DFyI4KaIYEWg U1u0029M6IikkhZShWcYaRk0R2CblWJsyKNxkhP8bOkvO9uQFaMeatpFzVXpYD042ILg dQpw== X-Gm-Message-State: AOAM533MDUb2gCJMBJRtd7XqdCP38jc/9a1xHLIRbchw4Z+Lf8BxNxSP OJJR54sOMn4oUQXm1IS8YZYvRQ== X-Google-Smtp-Source: ABdhPJxiN86yOamEdzSsvtrqNATfjczZniozKJJExXyIhzlZO4VwUnelTWDRAcgOFOWnS4+Z9USU8g== X-Received: by 2002:a17:90a:302:: with SMTP id 2mr13376430pje.34.1620239921095; Wed, 05 May 2021 11:38:41 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id x26sm15882079pfm.134.2021.05.05.11.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 11:38:40 -0700 (PDT) Date: Wed, 5 May 2021 11:38:39 -0700 From: Kees Cook To: Peter Zijlstra Cc: Rick Edgecombe , dave.hansen@intel.com, luto@kernel.org, linux-mm@kvack.org, x86@kernel.org, akpm@linux-foundation.org, linux-hardening@vger.kernel.org, kernel-hardening@lists.openwall.com, ira.weiny@intel.com, rppt@kernel.org, dan.j.williams@intel.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC 0/9] PKS write protected page tables Message-ID: <202105051132.7958C3B@keescook> References: <20210505003032.489164-1-rick.p.edgecombe@intel.com> <202105042253.ECBBF6B6@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: B164E135 X-Stat-Signature: ne1i8fyn1pqcpb1jn51c3ewfxiftkkqt Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=Db7y3p0I; spf=pass (imf29.hostedemail.com: domain of keescook@chromium.org designates 209.85.216.43 as permitted sender) smtp.mailfrom=keescook@chromium.org; dmarc=pass (policy=none) header.from=chromium.org Received-SPF: none (chromium.org>: No applicable sender policy available) receiver=imf29; identity=mailfrom; envelope-from=""; helo=mail-pj1-f43.google.com; client-ip=209.85.216.43 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620239916-554239 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, May 05, 2021 at 10:37:29AM +0200, Peter Zijlstra wrote: > On Tue, May 04, 2021 at 11:25:31PM -0700, Kees Cook wrote: > > > It looks like PKS-protected page tables would be much like the > > RO-protected text pages in the sense that there is already code in > > the kernel to do things to make it writable, change text, and set it > > read-only again (alternatives, ftrace, etc). > > We don't actually modify text by changing the mapping at all. We modify > through a writable (but not executable) temporary alias on the page (on > x86). > > Once a mapping is RX it will *never* be writable again (until we tear it > all down). Yes, quite true. I was trying to answer the concern about "is it okay that there is a routine in the kernel that can write to page tables (via temporary disabling of PKS)?" by saying "yes, this is fine -- we already have similar routines in the kernel that bypass memory protections, and that's okay because the defense is primarily about blocking flaws that allow attacker-controlled writes to be used to leverage greater control over kernel state, of which the page tables are pretty central. :) -- Kees Cook