Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2212253imm; Tue, 10 Jul 2018 15:34:29 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe/b69rVpLkjWHedugxXQsLT9Ujin1ANojmKmTD6cjl/aXee/JTfdX9qq806V3DBbdHIpbF X-Received: by 2002:a63:d613:: with SMTP id q19-v6mr20953406pgg.327.1531262069115; Tue, 10 Jul 2018 15:34:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531262069; cv=none; d=google.com; s=arc-20160816; b=A+q33yPme2cOzDyywEFQybgs2T2UL7r51ezhA9NqitQj7+VRrT5cdnar95kQzMuYZ1 j7MjBv8dhkcauRA7wPqDKYdrK2mGUzAgvP3ZzQT4xAPzp/OSfGlK9+k3xy+Z5SUuj0/7 YVu3FYZDB/NVbv9epFmW+5IG9oxWqfucoV01fqk69tMRE3NO5By55irPjd27Tw46RdLy BCMDmXol18A9he4ytxBFmN91hN/2MD1rJQnzBzX4oEwgv3OXY/m51DvJ/chHzlHKUu8a 1WAP+ueLneAe3gnSsy1U4a2DmbQQUZj2kvylMhfNewKwH0Dy1PfIXA+W9ZXumufVQ+V+ 8uBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=7E6u/3CoLaE9LAEqZKlXyKmBYPaGvaDA0UWbGv0I6dA=; b=LsPxRekL+MkAFFgj6Ncq2xy+AQ1kiJZztxHAwI8Hwkjk9mNN+oJGYVZraNnacCYgJH nQUxcuS9AUjO+uY2EZynuapGtmcttJ1EAggo2hLHydEg9AgUBIsi3xLJ7w211/vIT2vF +zj+s/ExJ6oOwInuqJNYncGuJOZu074nGlKUx+DekcY33CcvnsRNKSYAit+wHipYV0tO HJp4Xa5GEQ02oLxvT96Ge1cYkUHp0FEcS82KEcI7Tw5nRXl4QkRX5dvSVHxux14+mu7l UBErpisF11d5A4MpChvhsl4/AzyIdiyLEELiBkJ2xUu6yMWLAdo3YZgvFZ9Tphan5ZBh PPqQ== 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 p20-v6si16589184pgb.195.2018.07.10.15.34.14; Tue, 10 Jul 2018 15:34:29 -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 S1732700AbeGJWeP (ORCPT + 99 others); Tue, 10 Jul 2018 18:34:15 -0400 Received: from mga12.intel.com ([192.55.52.136]:33776 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732385AbeGJWcY (ORCPT ); Tue, 10 Jul 2018 18:32:24 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jul 2018 15:31:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,335,1526367600"; d="scan'208";a="70305420" Received: from 2b52.sc.intel.com ([143.183.136.52]) by fmsmga004.fm.intel.com with ESMTP; 10 Jul 2018 15:31:14 -0700 From: Yu-cheng Yu To: 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 , Dave Hansen , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , "Ravi V. Shankar" , Vedvyas Shanbhogue Cc: Yu-cheng Yu Subject: [RFC PATCH v2 15/27] mm/mprotect: Prevent mprotect from changing shadow stack Date: Tue, 10 Jul 2018 15:26:27 -0700 Message-Id: <20180710222639.8241-16-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180710222639.8241-1-yu-cheng.yu@intel.com> References: <20180710222639.8241-1-yu-cheng.yu@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Yu-cheng Yu --- mm/mprotect.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/mprotect.c b/mm/mprotect.c index 625608bc8962..128dcb880c12 100644 --- 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; + } + prev = vma->vm_prev; if (unlikely(grows & PROT_GROWSDOWN)) { if (vma->vm_start >= end) -- 2.17.1