Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1003055imm; Wed, 11 Jul 2018 15:11:06 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcsfxjwjyOlzHQQnXmOJVGiS2iCdOnFmOldqlHvvhohMLP1ySRc1rnid5bKVASahAssxHU7 X-Received: by 2002:a63:24c:: with SMTP id 73-v6mr374183pgc.252.1531347066310; Wed, 11 Jul 2018 15:11:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531347066; cv=none; d=google.com; s=arc-20160816; b=NgN3lc8QQUdc5wqyeER5MvtY3wBZRSJVoeO+6RBeYv9ZeUmL6qiwFR4HXMlaDyH6rf cbrTXikLXQ2GlP7fl0uu9rzDBjk2pF5XFbVFACsjGqacHmU8Blpg4qIF70zFdSe+CtWx d6ta/CWD0ibgTd0DyCFXyzNDf22MiqNg/ZsJz0dDBtz46lldS9De1hHQNUJFPXQMW+RB KZRQm/csCZ221nzmAijtjchDVOOg9U8GSvKJTxu+UXPpKUUGpYSObyYqsnsJC4y3f+cZ ehcs3uE2HuJ0XMyyewblKkhGmTrbIps3JLWA9jQ6xwjNQfABRht3Ac3Bw0fR21OQO5lV kZnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=z6ELSmiPEpcn2XHvGgDggiud2AiFP1gaIIyR40dT+vg=; b=SDKFfh5ohIFsVyd9XwzBnXdkvRTR8unPfWvh6ml31403aY9fGXK1twbMDIRm//com6 GU2ILuJIZEwHb4WIdSPrAOv+PXTij28yCNbMBcwJp1wFGsn1qpdAPOscYXLGeBnzc0Aw bTw726GZoLZGVEcRV0Rxin1FPJr7UQYfdQUSVBSYXd/aqC6QGhXYv+uNbBbt6kaIxog+ DK5b3xMNFmG27zPcGRIzqeWLFODPfT00VlSXUoSH/UiUIQH/RH2WMor/uxijHNk1VWEs /VkahqS6pQAv0MJWHFwbNn+XC4w0yWgAChwa8tXSwkIpu1re+g5bjQthSMxMomvFvhS0 KgQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 77-v6si21693457pfh.332.2018.07.11.15.10.51; Wed, 11 Jul 2018 15:11:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389615AbeGKQQd (ORCPT + 99 others); Wed, 11 Jul 2018 12:16:33 -0400 Received: from mga06.intel.com ([134.134.136.31]:45856 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726457AbeGKQQc (ORCPT ); Wed, 11 Jul 2018 12:16:32 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jul 2018 09:11:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,338,1526367600"; d="scan'208";a="66141725" Received: from 2b52.sc.intel.com ([143.183.136.52]) by orsmga003.jf.intel.com with ESMTP; 11 Jul 2018 09:11:29 -0700 Message-ID: <1531325272.13297.27.camel@intel.com> Subject: Re: [RFC PATCH v2 15/27] mm/mprotect: Prevent mprotect from changing shadow stack From: Yu-cheng Yu To: Peter Zijlstra , Dave Hansen 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 , Cyrill Gorcunov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , "Ravi V. Shankar" , Vedvyas Shanbhogue Date: Wed, 11 Jul 2018 09:07:52 -0700 In-Reply-To: <20180711091232.GU2476@hirez.programming.kicks-ass.net> References: <20180710222639.8241-1-yu-cheng.yu@intel.com> <20180710222639.8241-16-yu-cheng.yu@intel.com> <04800c52-1f86-c485-ba7c-2216d8c4966f@linux.intel.com> <20180711091232.GU2476@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2018-07-11 at 11:12 +0200, Peter Zijlstra wrote: > On Tue, Jul 10, 2018 at 04:10:08PM -0700, Dave Hansen wrote: > > > > On 07/10/2018 03:26 PM, Yu-cheng Yu wrote: > > > > > > Signed-off-by: Yu-cheng Yu > > This still needs a changelog, even if you think it's simple. > > > > > > --- a/mm/mprotect.c > > > +++ b/mm/mprotect.c > > > @@ -446,6 +446,15 @@ static int do_mprotect_pkey(unsigned long > > > start, size_t len, > > >   error = -ENOMEM; > > >   if (!vma) > > >   goto out; > > > + > > > + /* > > > +  * Do not allow changing shadow stack memory. > > > +  */ > > > + if (vma->vm_flags & VM_SHSTK) { > > > + error = -EINVAL; > > > + goto out; > > > + } > > > + > > I think this is a _bit_ draconian.  Why shouldn't we be able to use > > protection keys with a shadow stack?  Or, set it to PROT_NONE? > Right, and then there's also madvise() and some of the other > accessors. > > Why do we need to disallow this? AFAICT the worst that can happen is > that a process wrecks itself, so what? Agree.  I will remove the patch.