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=-11.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 76924C433E0 for ; Wed, 10 Feb 2021 19:46:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2775464E38 for ; Wed, 10 Feb 2021 19:46:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2775464E38 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 AACDB8D0003; Wed, 10 Feb 2021 14:46:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A5DDA6B0093; Wed, 10 Feb 2021 14:46:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8FEFD8D0003; Wed, 10 Feb 2021 14:46:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0171.hostedemail.com [216.40.44.171]) by kanga.kvack.org (Postfix) with ESMTP id 7B84F6B0092 for ; Wed, 10 Feb 2021 14:46:33 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 3D8C1D237 for ; Wed, 10 Feb 2021 19:46:33 +0000 (UTC) X-FDA: 77803390266.27.80A7CE6 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by imf03.hostedemail.com (Postfix) with ESMTP id AB6D2C0001F7 for ; Wed, 10 Feb 2021 19:46:31 +0000 (UTC) Received: by mail-pg1-f178.google.com with SMTP id e7so1936626pge.0 for ; Wed, 10 Feb 2021 11:46:32 -0800 (PST) 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=LOBexJVZl5O63ei2PKVTk/yEoofE8UPxbzZ4mG3AdFU=; b=TKGDKYbQHgIOPRKX8liktIsLemZyxUCEJfXoV6JuwuzbpfwUT19ClQa0tNbeh1kwjO peMEEpmUf/iJ9RMFYheTYcMNCbcH/fnYMVujd4ZvlaoHo7ETnnZNO/VAjDsY4D6U6AEl jJNufnxus0dZeQfIXmnTep06cZ8AGCzmOmAi4= 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=LOBexJVZl5O63ei2PKVTk/yEoofE8UPxbzZ4mG3AdFU=; b=M0s8p6tViqGDM8STMrxCin2dWwd2JmEdNEgj/STdJQ8lm0+22FET/uLaQ98wWIXZ+T mwOZfG9hjiq4ME7yJU3mxqRYxqoscCEZst6i6AQTxEleijef7ilYBHxTD1T2wVewXqLw m6vvBfP1F2hKm39v7p+ckbHxL4bhBaPtksb3mZWZljprbgTZBGuFroaUxsO006V4U1L2 vIjMMrllf+kPAq7AqQ1JscLjdy1dIB7hRyQAV2z8gCQYyWzc0F/748XlIyAZNjy1pGBu 1k7ZBnEg+EKheX7OPLe64LRJOhPMJ7B3ghFN9CExyuLlsKpR9ErglBnqufmREsHvBDAO 7g/Q== X-Gm-Message-State: AOAM5336d18/n0aCU7IHWTKpAqL5+Bau3ObzHn+U+31uZIkR/n4XVVIy rPQE5AHMNdRiEr2CBHXU224YdA== X-Google-Smtp-Source: ABdhPJzU36iPUZB59irH169GzgM6TNqXFDVT4lz6gU6IaKnXXV8mNiT8RQ8Q6WVoTQsGfLesTa299A== X-Received: by 2002:a65:520d:: with SMTP id o13mr4568903pgp.57.1612986391981; Wed, 10 Feb 2021 11:46:31 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id v23sm2966724pgo.43.2021.02.10.11.46.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Feb 2021 11:46:31 -0800 (PST) Date: Wed, 10 Feb 2021 11:46:30 -0800 From: Kees Cook To: Yu-cheng Yu 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 , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang , Pengfei Xu , haitao.huang@intel.com Subject: Re: [PATCH v20 25/25] mm: Introduce PROT_SHSTK for shadow stack Message-ID: <202102101145.7DE8B381@keescook> References: <20210210175703.12492-1-yu-cheng.yu@intel.com> <20210210175703.12492-26-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210210175703.12492-26-yu-cheng.yu@intel.com> X-Stat-Signature: ew4rh8zzadmkbk86imqt4mzhc3e81d9n X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: AB6D2C0001F7 Received-SPF: none (chromium.org>: No applicable sender policy available) receiver=imf03; identity=mailfrom; envelope-from=""; helo=mail-pg1-f178.google.com; client-ip=209.85.215.178 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1612986391-73287 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, Feb 10, 2021 at 09:57:03AM -0800, Yu-cheng Yu wrote: > There are three possible options to create a shadow stack allocation API: > an arch_prctl, a new syscall, or adding PROT_SHSTK to mmap()/mprotect(). > Each has its advantages and compromises. > > An arch_prctl() is the least intrusive. However, the existing x86 > arch_prctl() takes only two parameters. Multiple parameters must be > passed in a memory buffer. There is a proposal to pass more parameters in > registers [1], but no active discussion on that. > > A new syscall minimizes compatibility issues and offers an extensible frame > work to other architectures, but this will likely result in some overlap of > mmap()/mprotect(). > > The introduction of PROT_SHSTK to mmap()/mprotect() takes advantage of > existing APIs. The x86-specific PROT_SHSTK is translated to VM_SHSTK and > a shadow stack mapping is created without reinventing the wheel. There are > potential pitfalls though. The most obvious one would be using this as a > bypass to shadow stack protection. However, the attacker would have to get > to the syscall first. > > Since arch_calc_vm_prot_bits() is modified, I have moved arch_vm_get_page > _prot() and arch_calc_vm_prot_bits() to x86/include/asm/mman.h. > This will be more consistent with other architectures. This portion of the patch seems logically separate from the PROT_SHSTK implementation. Can you please separate it into its own patch? > > [1] https://lore.kernel.org/lkml/20200828121624.108243-1-hjl.tools@gmail.com/ > > Signed-off-by: Yu-cheng Yu With that done: Reviewed-by: Kees Cook -- Kees Cook