From patchwork Thu Jun 7 14:38:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu-cheng Yu X-Patchwork-Id: 10452311 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 29D9F60375 for ; Thu, 7 Jun 2018 14:42:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B788294DB for ; Thu, 7 Jun 2018 14:42:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10209294DF; Thu, 7 Jun 2018 14:42:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF821294DB for ; Thu, 7 Jun 2018 14:42:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D88F46B0289; Thu, 7 Jun 2018 10:41:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CE8E26B028B; Thu, 7 Jun 2018 10:41:35 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB5D56B028E; Thu, 7 Jun 2018 10:41:35 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f72.google.com (mail-pg0-f72.google.com [74.125.83.72]) by kanga.kvack.org (Postfix) with ESMTP id 58FF66B028B for ; Thu, 7 Jun 2018 10:41:35 -0400 (EDT) Received: by mail-pg0-f72.google.com with SMTP id e1-v6so3584338pgp.20 for ; Thu, 07 Jun 2018 07:41:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=dXWSiahTvZtRvHQ0wwL46ulL8h8lt2YqB4AhipcEOMo=; b=AKMFA6GZGVXZICwvBe2x3jqio51cnPn0yaFnVIKTKe716R2mFmpL5WcZ6ShyuUEMKu irz+sWMqXLwyuEonVhZ9yO24JoldudrYy2W4IQzi6lW8DDcE0s6gZyJiFX7aDITybK+X 6h39H6TQR3f584Xj4ghzQXVrt78ZFc+sLkwafWjlZC+yGbxU1aVjOjuznP26sRAlVUZ4 x0t0qvVH7IBhhTtAFTL9KiskoqmZ5H8ZgqeJLC/aaJClhxw5IFRIhXxqPhdNwp601Q1z JBoawBugS1EzxUQDv1w+AEzNNWXl0LRMFGzmzvXifMkdnDQcgHOrbYFc41x51ko4Ntul tcBQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APt69E05gANi14+kQMz0e3gSPqHJk6ko9dg3olSXPuImxDyDO3knRmcb Z4WDnrgWB3CDzNNSCE1qA/jlp74/FmBDUSTcslIgzxaD5mw/jhWPC7yzZYEj7cB4auDa3X3E7qF WuosHJ7L5lUsOMpDpRmd+uSJhkRA/qHmUB08XsyVOHjbur+fE7GYEjVqqcx1jkn1aVg== X-Received: by 2002:a17:902:5a4c:: with SMTP id f12-v6mr2329139plm.85.1528382495083; Thu, 07 Jun 2018 07:41:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIm4M/03TLXNNfzKLrdLFsZ8KIVsFQaSyu6UFMuL8TFAmLp07Ovj5Pk58em++HPOcW2Ohpm X-Received: by 2002:a17:902:5a4c:: with SMTP id f12-v6mr2329106plm.85.1528382494568; Thu, 07 Jun 2018 07:41:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528382494; cv=none; d=google.com; s=arc-20160816; b=gfnEsCWdhbQRns/2eNKKcBgrF5Ofi75QPzqMPlTxWNDEoOozwcX0JuylCe7UY/vQWE FoI7DTmeIBz8tbzaiooQUXzV75/KsuJs8yqr6bBKVL79Ktu0C9DDc8UI0z/QwsrpfbHC qZzwpKgsChWaZfsBYi7IAGhs4Nt7XdXGyW2i3pstG37z7NF49C+GXfWVDBhevBeNQSJn C3JCYo9EMdaEGpOBQfPBZKoVYbSDnAIKG/m9fWbRMxyTPMyPl8GqGZ3GJM4M3MKDKejQ L98cNNOsbH+VT7cJ9Jr4grU7KD6HFZzTAVfE9EdLd4BaHsAGZBdqrvHMUT4zb4Cmtar6 5V2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=dXWSiahTvZtRvHQ0wwL46ulL8h8lt2YqB4AhipcEOMo=; b=fI0rZF1lDDAeB2/zazaifJNIlW82I714beq0UoBMkFEmJ7dKvU5LyiJD5dVXWJ63uk hNygREEXB0AAsG59Il3Y5ZVX+QtznT96hNVnlksHtCLGpufRelajAONo/zdT+nGwlRnn SLcWMP1auAoZQC20KUxlgnQFtQu2hT/dotfDwqOOuT9+FdlkIx15YG2psOmxIrrcF3ng lwdbb8gwVth/bgVy99V1BHyyzPYvhjh5ghOwzxE47K6frMvTIKzcJXCDKDbEN3BbKa1L BqoOdIwnlXB55JkHT/geYIkSh/3xAykAq8knl7FzJrgwRmiWDc3WvFtpGIfBvlukGURa OqaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga05.intel.com (mga05.intel.com. [192.55.52.43]) by mx.google.com with ESMTPS id i74-v6si8716254pgc.188.2018.06.07.07.41.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 07:41:34 -0700 (PDT) Received-SPF: pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.43 as permitted sender) client-ip=192.55.52.43; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jun 2018 07:41:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,486,1520924400"; d="scan'208";a="62632648" Received: from 2b52.sc.intel.com ([143.183.136.51]) by orsmga001.jf.intel.com with ESMTP; 07 Jun 2018 07:41:33 -0700 From: Yu-cheng Yu To: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , "H.J. Lu" , Vedvyas Shanbhogue , "Ravi V. Shankar" , Dave Hansen , Andy Lutomirski , Jonathan Corbet , Oleg Nesterov , Arnd Bergmann , Mike Kravetz Cc: Yu-cheng Yu Subject: [PATCH 08/10] mm: Prevent mremap of shadow stack Date: Thu, 7 Jun 2018 07:38:05 -0700 Message-Id: <20180607143807.3611-9-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180607143807.3611-1-yu-cheng.yu@intel.com> References: <20180607143807.3611-1-yu-cheng.yu@intel.com> 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: X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Yu-cheng Yu --- mm/mremap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/mremap.c b/mm/mremap.c index 049470aa1e3e..70f20edb248e 100644 --- a/mm/mremap.c +++ b/mm/mremap.c @@ -525,7 +525,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len, unsigned long, new_addr) { struct mm_struct *mm = current->mm; - struct vm_area_struct *vma; + struct vm_area_struct *vma = find_vma(mm, addr); unsigned long ret = -EINVAL; unsigned long charged = 0; bool locked = false; @@ -533,6 +533,9 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len, LIST_HEAD(uf_unmap_early); LIST_HEAD(uf_unmap); + if (vma->vm_flags & VM_SHSTK) + return ret; + if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE)) return ret;