Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3748406rwb; Mon, 3 Oct 2022 21:40:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Xgy1bkr1moQJnrlIu1Ec/NLbm0HobNttJ0bRHGgepXqB++q8rZ6Tmc25K5srUXtl3ovyO X-Received: by 2002:a05:6402:1944:b0:457:fed7:5c30 with SMTP id f4-20020a056402194400b00457fed75c30mr21075267edz.278.1664858406727; Mon, 03 Oct 2022 21:40:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664858406; cv=none; d=google.com; s=arc-20160816; b=WbrHQwuAEsSqsxtIiE8r8CTpojT9RsPMNLzjMsveDPb+qoIk0YftkLUxZNnjiHCt1q SBsQZV8kKlY1yHP+ZtlJUTOd1xdsUB9r0KBUXAmDqOkSGbzK8MTlqWOgjo17wUSg6a65 YAy/KpiOJYQlbIJzGPFn89SZfjnNkcPRybFZh6rXh5JcEwimEg3lccOdus2T5MmPMH2K WrVgjZo59kXASo7USFOzxhMIMyLCICSevy90Q4/YVvjAOgzFzVyyCZmphFGxTAJYHw9y wR0GfgXB4ylkCXG8/Bp9Ati0u77YMC3/zOi3Qx72wvyw6G7koFY3ii/Wlv3qSraVNFDg +ulQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Uece0fM7JiJORIh7QBlH2yQn1WOcaEDf7Srsu/hsgUw=; b=s7Ls136kAb7uta08jfzHy462Htb1cEVmeCOxsXA58iSBYB4C8StlGRtI6q6Q6nd1pW hYvYY72Ul9t5KvO1F214H9yLhAjKfdrKZZvs1KilTjvlcp014gEwMSZwWKbPLmCaG8bk LXDYMocQAS3hph3/gABGOhOTtbc3tc9N+gJDu0cxEkAVU/qljAioyUWy9fM9MBmdmkqK NNmII0xf5Hny+xsSaS6fTdSMfRl+dCaQoqlUL4eQ6iK/ActhQK0Y6VhftDgwiZTtw4dv dlk+D4XICGnreHuxtRZsheQYEcB4iZA3Obp2Bmafrznsj7NUQfzMJdRPFwL3wIow67TD lyKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=IZPCBJgA; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y19-20020a056402271300b004548a74553esi10971727edd.445.2022.10.03.21.39.41; Mon, 03 Oct 2022 21:40:06 -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=@chromium.org header.s=google header.b=IZPCBJgA; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229446AbiJDEWK (ORCPT + 99 others); Tue, 4 Oct 2022 00:22:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbiJDEWE (ORCPT ); Tue, 4 Oct 2022 00:22:04 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBCA531EFC for ; Mon, 3 Oct 2022 21:22:00 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id d11so11650652pll.8 for ; Mon, 03 Oct 2022 21:22:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=Uece0fM7JiJORIh7QBlH2yQn1WOcaEDf7Srsu/hsgUw=; b=IZPCBJgARGka0cb7Qhti4Q0beiVA8VD+iN0oph+SF1rux57WDNrOg/IH/L2x8sF66T wE1b/47QrbUn/SS4rziRMS8qZhqgjpEkP5cpCXXbtgH5Bo+tSWTz06ERHb+jcyYipBRf Tfqd8ab5NKyZQQkEKz8IN56bLeH1Rh/dfyOqo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=Uece0fM7JiJORIh7QBlH2yQn1WOcaEDf7Srsu/hsgUw=; b=klmhyFSKSXoiiDcClIO6VW53+WYPsQ9cwMNBmL6qK0MWIybVwuBPyIyeYgBP6gxtW5 XwPraUFD29vT9mMu+tnf8+kCjHeIP/AK4R2N1LQfMThKfgOEDOW0kElMwc8DoZsKIPKP QmCym8HxTZCqoylpFKPh+Qb8UGD28kYr3UxFyRW98Z0dJUK5FM5rbflLSPMmjGFumWg9 9rofcIoFRjFitPWBwFCfcoBV6bpK7Xcci0JWDoU7W94U2RlllEZE3VNoGMTLd6SwUFdW D/ECuQmnAU2HrMRU7GPbUBNi93kXo9Bm4O2YvRWIq9WBepozR72wCux57Xw6WOPc7Eqp lJFQ== X-Gm-Message-State: ACrzQf3bIXjETuWeciHd504hDqy09Xy0vK4Hwr9c/O5yFSeNOhZW68yX gdUhoMkZYYJEnK5WoqMGxZkx6A== X-Received: by 2002:a17:902:7408:b0:17b:546a:17 with SMTP id g8-20020a170902740800b0017b546a0017mr23824925pll.134.1664857320258; Mon, 03 Oct 2022 21:22:00 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id e3-20020a17090301c300b001782f94f8ebsm8086293plh.3.2022.10.03.21.21.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 21:21:59 -0700 (PDT) Date: Mon, 3 Oct 2022 21:21:58 -0700 From: Kees Cook To: Andy Lutomirski Cc: Rick Edgecombe , x86@kernel.org, "H . Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H . J . Lu" , Jann Horn , Jonathan Corbet , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V . Shankar" , Weijiang Yang , "Kirill A . Shutemov" , joao.moreira@intel.com, John Allen , kcc@google.com, eranian@google.com, rppt@kernel.org, jamorris@linux.microsoft.com, dethoma@microsoft.com Subject: Re: [PATCH v2 22/39] mm: Don't allow write GUPs to shadow stack memory Message-ID: <202210032119.EF573F9E@keescook> References: <20220929222936.14584-1-rick.p.edgecombe@intel.com> <20220929222936.14584-23-rick.p.edgecombe@intel.com> <202210031134.B0B6B37@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 Mon, Oct 03, 2022 at 03:49:18PM -0700, Andy Lutomirski wrote: > On 10/3/22 11:39, Kees Cook wrote: > > On Thu, Sep 29, 2022 at 03:29:19PM -0700, Rick Edgecombe wrote: > > > [...] > > > Still allow FOLL_FORCE to write through shadow stack protections, as it > > > does for read-only protections. > > > > As I asked in the cover letter: why do we need to add this for shstk? It > > was a mistake for general memory. :P > > For debuggers, which use FOLL_FORCE, quite intentionally, to modify text. > And once a debugger has ptrace write access to a target, shadow stacks > provide exactly no protection -- ptrace can modify text and all registers. i.e. via ptrace? Yeah, I grudgingly accept the ptrace need for FOLL_FORCE. > But /proc/.../mem may be a different story, and I'd be okay with having > FOLL_PROC_MEM for legacy compatibility via /proc/.../mem and not allowing > that to access shadow stacks. This does seem like it may not be very > useful, though. I *really* don't like the /mem use of FOLL_FORCE, though. I think the rationale has been "using PTRACE_POKE is too slow". Again, I can live with it, I was just hoping we could avoid expanding that questionable behavior, especially since it's a bypass of WRSS. -- Kees Cook