Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2318984imm; Thu, 11 Oct 2018 08:27:00 -0700 (PDT) X-Google-Smtp-Source: ACcGV63b5zZjCX7xSeM03HStzUBH3wvPw12v0agmrYN0MRKcriDJOXgh4soQiRT6rq5YIudbD9lm X-Received: by 2002:a17:902:5a45:: with SMTP id f5-v6mr2067997plm.26.1539271620364; Thu, 11 Oct 2018 08:27:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539271620; cv=none; d=google.com; s=arc-20160816; b=wvC1qpyt2lv3ac/XtVcAngzX/nfVC1kK3BDrIDf0ApsuqBWiu8FzzNVPj8lF8tq6rI hSPPL98s6J3IB/L2Znz3eJXCIF/kqF1+3nCCu1uHHG/iJ57BwaIB60GjPuyt4fmfiZEZ mIgcyV7dssoePKB5AYDLq6ywJOCE6B+GTdOwt8ZH4xQl6ZgFviJ438plfvJ6cNleZm+7 wH0O5ChrI8FNkZYJ+bjjkEvNqB/jALamFkKazoQ5AgXRk1hEexV32pffOuOtnLg4mMQq Fap9sAwHXuKMTXVK7hWhtYqto9ckh8JiW/RH6j4RLa9e2859Y57WBc7njrE9uLP1bMkB Q9Ow== 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=7Y58Ryx2gRr8JA0dxpo0qOiFv/hhGNbXLRWK46z7PDc=; b=CVClR7yPe6SiXX4KIN7/8wUCbE68+0it1/JzZ0/k0byihuZd4tnreGSJ7+UqHHzjc8 hPVgtqe2pkLmZ0+a6xQshpc/Wj93iwE3XjQov4+jkJ92PpeVDZhG08KCR1fTTyhWWSVw tcErlafcvECK4+vHnk3a3LS1POQW4wEN2MhgqLXEbMJ1a9oBM1VocZYFXMwFGES6uhwk c3tCXACVzseH52p73HL/ztz1BwZG/AM5fqWckajOPr4WwoWKBRa17x/kYJitCNzFIP/q hs76imSRMw2sOSbjygJo8HJuaSEGFR1/yrSC6UsLYGg0auGmM/JUsx1QmAqAISYZMlDK KnwQ== 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 n7-v6si20020857pgb.171.2018.10.11.08.26.46; Thu, 11 Oct 2018 08:27:00 -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 S1728941AbeJKWwF (ORCPT + 99 others); Thu, 11 Oct 2018 18:52:05 -0400 Received: from mga05.intel.com ([192.55.52.43]:3986 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728323AbeJKWsY (ORCPT ); Thu, 11 Oct 2018 18:48:24 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2018 08:20:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,368,1534834800"; d="scan'208";a="78019110" Received: from 2b52.sc.intel.com ([143.183.136.147]) by fmsmga008.fm.intel.com with ESMTP; 11 Oct 2018 08:20:44 -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 , 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 Cc: Yu-cheng Yu Subject: [PATCH v5 10/27] mm/mmap: Prevent Shadow Stack VMA merges Date: Thu, 11 Oct 2018 08:15:06 -0700 Message-Id: <20181011151523.27101-11-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181011151523.27101-1-yu-cheng.yu@intel.com> References: <20181011151523.27101-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, we 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 5f2b2b184c60..b85292014ec9 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1123,6 +1123,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