Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1516659ybl; Tue, 13 Aug 2019 14:07:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqxVg7HOTJKiiAGIhfEH+sXdbZxdqcqMuxJ7ZWdmHVQwTeieN9ViASM2NFZ64WG+zXwYxaXb X-Received: by 2002:aa7:9092:: with SMTP id i18mr42524713pfa.101.1565730461081; Tue, 13 Aug 2019 14:07:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565730461; cv=none; d=google.com; s=arc-20160816; b=cJN+O7ImIKdBkV7B+j2kUa+zBimjLlZcUOK81pmYiXKTmNgHrCEfgg7vchJPn0N4oZ 1/5/VO4JzYC8IdCgoyXwxAgRdP52+uZTiHb5b28jWPxv3jN35kVR+lHojXqL7E/38K24 Ju9exlQXhcb8rT5WkqBwhX+bfWvsR84YZLhR7/i3AMwZ6dNmt6mDO/JYEIcpgt56onsg UVTZcxDQlQySn/HVEDqyLLsE1gAauUQHpM3xuVJsI1IUqx7By/GdQn/KdHxslfSEqPlS 3h/AnoibVbz86S1QC8TP+O//eP5ufxCIqjzrVS4p6rfMMMaUoh7HZVymPA3zpsl7BTm5 rLDg== 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; bh=PRMK9B749M2GnYFCAYLMoGKG7TrNJ06MBXvb3sJHopg=; b=ltY8I/kuIxQfvgvhsT94Su5JtNYQBjyC5iCIXLan9mQAyOK/gTQyOfOdBcsLYB74bD yaV1H04W6/wf17tCdwaw9ivlQk9umPFAyhDrRbp5sv5EIQt+Q6zSuv8M4rPROL5lq4au topNPF0jr0NvqLB+RNZSyEYUscPlnpiPTlLVomBcIwWdkLjWQ7vDKXpQPWE9RVwP2Ppt B2X5eUJZBaRyMRMfWP9oIi6dSd466ySHw5hz91yDPlD+OTA4Uhaxvpf6RZ1+SRflrEYb E90WWufQEU+C5ZcoYU9U2TFFr/UREtvcRUGzQtfQ9Co/trYjc2a2EBzaM/tyvjJxDT6c dBrg== 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 i1si62073085pld.173.2019.08.13.14.07.25; Tue, 13 Aug 2019 14:07:41 -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 S1727145AbfHMVFo (ORCPT + 99 others); Tue, 13 Aug 2019 17:05:44 -0400 Received: from mga06.intel.com ([134.134.136.31]:16072 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726756AbfHMVCp (ORCPT ); Tue, 13 Aug 2019 17:02:45 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Aug 2019 14:02:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,382,1559545200"; d="scan'208";a="187901377" Received: from yyu32-desk1.sc.intel.com ([10.144.153.205]) by orsmga002.jf.intel.com with ESMTP; 13 Aug 2019 14:02:43 -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 , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin Cc: Yu-cheng Yu Subject: [PATCH v8 09/27] mm/mmap: Prevent Shadow Stack VMA merges Date: Tue, 13 Aug 2019 13:52:07 -0700 Message-Id: <20190813205225.12032-10-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190813205225.12032-1-yu-cheng.yu@intel.com> References: <20190813205225.12032-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 To prevent function call/return spills into the next shadow stack area, do not merge shadow stack areas. Signed-off-by: Yu-cheng Yu --- mm/mmap.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/mmap.c b/mm/mmap.c index 7e8c3e8ae75f..b1a921c0de63 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1149,6 +1149,12 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm, if (vm_flags & VM_SPECIAL) return NULL; + /* + * Do not merge shadow stack areas. + */ + if (vm_flags & VM_SHSTK) + return NULL; + if (prev) next = prev->vm_next; else -- 2.17.1