From patchwork Mon Nov 19 21:47:52 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: 10689531 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CBFE76C5 for ; Mon, 19 Nov 2018 21:54:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD7842A583 for ; Mon, 19 Nov 2018 21:54:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0BFE2A6EC; Mon, 19 Nov 2018 21:54:39 +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=ham 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 33DA52A583 for ; Mon, 19 Nov 2018 21:54:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3961E6B1C93; Mon, 19 Nov 2018 16:54:22 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2F66B6B1C94; Mon, 19 Nov 2018 16:54:22 -0500 (EST) 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 19D006B1C95; Mon, 19 Nov 2018 16:54:22 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id B0E2C6B1C94 for ; Mon, 19 Nov 2018 16:54:21 -0500 (EST) Received: by mail-pg1-f199.google.com with SMTP id h9so16485975pgm.1 for ; Mon, 19 Nov 2018 13:54:21 -0800 (PST) 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=SJCNv9K8928ck0TsHD88y6FaxV4o0U2tlV6oNjQ/XIc=; b=iRK0uXHRg3tlBP4ojmNlvYCzrHKGto7wbicS25QFG8DmL6qbSEjCBEqu4BdUQ5DpOT Yo/OBY0mkXJWGkn1Q8NvuaLZPYWKvMzv2/92r8upeXSJBRbZAr+rc/BQZbb/XzbkXukL 7ODGQNbFbGUnLoHyd/6IUBhvpWZuw3EV4j1F+jNfEFaympk/18NVkUsCkpuwJm8YEeek 90eYZTsnm4lsxFBzm6I2LItjf/DIkH+Ph/9yTCAStcDuKpYn5/un8UaFLeJsoHMnin7C JqqBS5dU+cmUKwgq8FTVOr9BFQBkzbJrB4+XvPaGSdzmr8yhzKma2xZKoxAeY1bDOAPn 4Fww== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.93 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: AA+aEWZhJ1j9WzqJxWXNAjznacI8janMgPeLmHUh7IxWeI/AGkxNGufc WMbKeIVXVkTTpEkPNpOb/ZvXD7QxpT/iTfxG9Ukxx/FrakxAm9MdS2snAXvRDXz4rimqsJlEViB PPdxBe39m6/e8KSLUrtxEd7jFwj+nJnCAnVsXfEc59m4waHa9hJ+oOH+jef991ihEkw== X-Received: by 2002:a17:902:3064:: with SMTP id u91mr10310412plb.325.1542664461428; Mon, 19 Nov 2018 13:54:21 -0800 (PST) X-Google-Smtp-Source: AFSGD/WhGnmm3WW39vMNNXXt0Mc029Q7bla/QEtesYMmLHZ2LRg5LNKKbZlLOkjvFEdueU3l1hPJ X-Received: by 2002:a17:902:3064:: with SMTP id u91mr10310383plb.325.1542664460724; Mon, 19 Nov 2018 13:54:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542664460; cv=none; d=google.com; s=arc-20160816; b=XLXd3f4nHHRmd2E7bavugXFdmC2dJctXpXiV8H0xqOdhXWJFThomqtEEXLH/cX0kdZ QzygakEMX+3fR4aXS0yLeVGhUX4StmgPs61eLUANget4YQ+IPQUl6JtPLWUjS/QzQvgP Z2ObSkMV8H2IDCuwyazEr5xh2RaB4K2YsjIrXLNQvZ5eEvIZAG8ei+WKyPzHoD8XyIUH T8xI/GohJjvTxcKLkAMFMONv/9JeKM8sg+UNAfMxS5NCYl5eJzpgiwXbwSCH69Ray1kG rtkSCZqMJbPKreNDEndUibDAhr6fr25rC7vY98WmrX+6Bcs2tkwP1YZCg81p4KQbSDhc FwMA== 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; bh=SJCNv9K8928ck0TsHD88y6FaxV4o0U2tlV6oNjQ/XIc=; b=Jjfpm0rFtKr8OecTHzta7eb06JgEWA/KqTLipd+TXYv7AqfL0AWcaKLvMh3jQIL6Tv Qex3A0hdbu3bYDoaVB2h9RhATTe0dw+Gldl9rrtDe0Au3oPU87zr44SwCkv5Opgl4GCg fxOLLDTCpWD6WGGkoYLmtDG96QYM6AQs7ZCPUKZRACwXOLSLdH9iqozZvHNx5fs5t2Lm +2NmqPjM+T3v8PoHpYIj9fjRgeYxOHM+jcx37YbLNBnjKuXJfeKOtim0VFkiQK+BsVPv NgEgaskOEKxsB3nuRmVec87YdGbnML0OlZq8LGvD9wbCrOa1/5SL56lC3J7kTPSL2Y+i Grfw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga11.intel.com (mga11.intel.com. [192.55.52.93]) by mx.google.com with ESMTPS id o12-v6si32492543plg.114.2018.11.19.13.54.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 13:54:20 -0800 (PST) Received-SPF: pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.93 as permitted sender) client-ip=192.55.52.93; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.93 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 orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Nov 2018 13:54:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,254,1539673200"; d="scan'208";a="93319857" Received: from yyu32-desk1.sc.intel.com ([143.183.136.147]) by orsmga008.jf.intel.com with ESMTP; 19 Nov 2018 13:54:19 -0800 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: [RFC PATCH v6 09/26] mm/mmap: Prevent Shadow Stack VMA merges Date: Mon, 19 Nov 2018 13:47:52 -0800 Message-Id: <20181119214809.6086-10-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181119214809.6086-1-yu-cheng.yu@intel.com> References: <20181119214809.6086-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 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 6c04292e16a7..30836512ca79 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1147,6 +1147,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