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=unavailable 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 B0FF5C433E0 for ; Wed, 10 Feb 2021 19:47:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8002B64ED4 for ; Wed, 10 Feb 2021 19:47:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232682AbhBJTrW (ORCPT ); Wed, 10 Feb 2021 14:47:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232369AbhBJTrS (ORCPT ); Wed, 10 Feb 2021 14:47:18 -0500 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B369C061756 for ; Wed, 10 Feb 2021 11:46:32 -0800 (PST) Received: by mail-pf1-x433.google.com with SMTP id b145so1972057pfb.4 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=jdHmbDtnaV8BQx7Kw+4ZqN0l8ilkFwfVGwcbOlTNTJtdNd6+3eIrr4RmelGreH4Zek qBbDZqSysI0k7DLflK7JA9XB7v5lx0J7hPT0SI108WRDolLuoFT89nvNayChubiINrtn wutSx+Arsi0oJ+vxQMypyqIlvqy7OYOl1FuGHQ13EW/exl3FH/953pSx7TF3cly0jDEz TEieQfDn/iXFgIQqngyyQgW9mLSGAkRwuDHTOgZ6lOd0A1V7BlZCxUV2itHKB0XTidGb uRDsVgC5S5u8GFSOTbTn8nk6WUU0vZJIHkSUDgN559p6Vk7nq/SPLDTWCbCuduypIPJU aYUQ== X-Gm-Message-State: AOAM533w1u0pGnZa1FmSFLxagsrEPsa4ihxMbp2iLrTXfiSIT6J04QMK db3VbU/J0kHXxsgOwV+sA2pDPQ== 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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