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 8C473C4708E for ; Sat, 3 Dec 2022 02:39:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235116AbiLCCjz (ORCPT ); Fri, 2 Dec 2022 21:39:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235083AbiLCCjk (ORCPT ); Fri, 2 Dec 2022 21:39:40 -0500 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F16A1FB8A1 for ; Fri, 2 Dec 2022 18:39:37 -0800 (PST) Received: by mail-pl1-x62d.google.com with SMTP id k7so6253295pll.6 for ; Fri, 02 Dec 2022 18:39:37 -0800 (PST) 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:message-id:reply-to; bh=puHWTnl4FttUivJr2fjCJ+XKoeeB18dHeiV6LUEyyFM=; b=Zlq5Fnhl2chjzNVLRCXkgHfNkIE0tfHyjGOMS2CEMjgttw/3wjFdU35d78bA06NTwJ r7yHGRy4iqmGmpEYp8tuRXboZ24+1jtm6m8MjiTOPK080wDEO7W6f5LU1UJx6Q81rxqi DbM3puGe2/WxwE1s5DHvG5IQfc/FlVtfPm5PE= 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 :message-id:reply-to; bh=puHWTnl4FttUivJr2fjCJ+XKoeeB18dHeiV6LUEyyFM=; b=sn3F1F6Y0Kah6se+iL63kMSQPUlIag+7HYfCJVazPbK2nnlIhkRBwLVov9BaxglRkS ax4Gt9T+X0ZZRZ4+TPI2QPgRlQJdYiLi1XZieQFV0tEC9Xny24aP8rKsIbKJttFJztsD l4mw1OoJqnOIg/BimgXEkuEDzHssWhVKpQwP2pHxZNsSBxOz07wIiOCQ9/x9xAqErx/c DQOdonZt+P9lf+BHeGRX6ca1aiyd9QKsUVzHCa8hj6Zeb9Qtu5N0/fymxd6Jp6Dc1gdj PS0bGljmsN+IDM50fGEJ2z7E/UPxghp6BXvP085fRs3cgvQyEVE1VSGK5xf++scqckUO D3Mw== X-Gm-Message-State: ANoB5pnGK68XX74RX70o7DuiV8dLtfsamLXpwrRJA+dqvzJtGgtKQ2yF KuRAuDIB7IWR1UDxOurIQaJ+Og== X-Google-Smtp-Source: AA0mqf4dQit9R82se8kWgKsx1FCknHa8rD7qiYgXLaoKAKcCKykz/uB+mYLnym6TuHUG0Vpre+iDAg== X-Received: by 2002:a17:90b:374f:b0:219:7bc8:f300 with SMTP id ne15-20020a17090b374f00b002197bc8f300mr10681194pjb.145.1670035177500; Fri, 02 Dec 2022 18:39:37 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id p2-20020a622902000000b00575acb243besm5707003pfp.1.2022.12.02.18.39.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 18:39:36 -0800 (PST) Date: Fri, 2 Dec 2022 18:39:36 -0800 From: Kees Cook To: Rick Edgecombe Cc: 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 , Andy Lutomirski , 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 , Weijiang Yang , "Kirill A . Shutemov" , John Allen , kcc@google.com, eranian@google.com, rppt@kernel.org, jamorris@linux.microsoft.com, dethoma@microsoft.com, akpm@linux-foundation.org, Andrew.Cooper3@citrix.com, christina.schimpe@intel.com Subject: Re: [PATCH v4 23/39] mm: Don't allow write GUPs to shadow stack memory Message-ID: <202212021839.32C9B178@keescook> References: <20221203003606.6838-1-rick.p.edgecombe@intel.com> <20221203003606.6838-24-rick.p.edgecombe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221203003606.6838-24-rick.p.edgecombe@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-api@vger.kernel.org On Fri, Dec 02, 2022 at 04:35:50PM -0800, Rick Edgecombe wrote: > The x86 Control-flow Enforcement Technology (CET) feature includes a new > type of memory called shadow stack. This shadow stack memory has some > unusual properties, which requires some core mm changes to function > properly. > > Shadow stack memory is writable only in very specific, controlled ways. > However, since it is writable, the kernel treats it as such. As a result > there remain many ways for userspace to trigger the kernel to write to > shadow stack's via get_user_pages(, FOLL_WRITE) operations. To make this a > little less exposed, block writable GUPs for shadow stack VMAs. > > Still allow FOLL_FORCE to write through shadow stack protections, as it > does for read-only protections. > > Tested-by: Pengfei Xu > Tested-by: John Allen > Signed-off-by: Rick Edgecombe Reviewed-by: Kees Cook -- Kees Cook