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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6847C433FE for ; Tue, 4 Oct 2022 04:22:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229509AbiJDEWL (ORCPT ); Tue, 4 Oct 2022 00:22:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbiJDEWE (ORCPT ); Tue, 4 Oct 2022 00:22:04 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA4282FFE3 for ; Mon, 3 Oct 2022 21:22:00 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d24so11655950pls.4 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=m6j3G25LiaKOGSnmW6iKYiAfNZb7cyMRzviwXhc2UDswzQZGXKTQhCghAJgJskqHuw q8SpqYRtZk3tGy6eHzF7ZkQ7pyPa7QziEvGb774M8FjJPyoPueKDhqzL/ggvJSrtlwcR iTpqUhsIKJ7fSJ4mkhTlkIAlIf/aedHfXsb2fDygBDfv1VgOkr/X6QwQx1EVsixDlqFj kOjyMbPSu3vQz0hyBclXIN8JYJ+hQNe4/qyeMW4+N57YcApL+MtUsNj71dZ1YGfhRicq 0Hnrq+Pr9dZ7KKRHqrHy+42mfBKOcEDO4MbflBkpfPSY0XPkQuwgx5I08/EuonS2Gsan 2nMg== X-Gm-Message-State: ACrzQf1hfHSkf+AiNhzWAxomneTF1KcqBtGacU5VefPTnOfffXvIGs1l O1S2HelylXpK6foKzlOsxIivlQ== X-Google-Smtp-Source: AMsMyM61KNxyPA9BhzyQ+UiKn0Jm9LQ+eZMj7fa8DZwgn3vRmElmfsAwichq5aJoTDxwBEmVW2pxWw== 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: Precedence: bulk List-ID: X-Mailing-List: linux-api@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