Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp783001imm; Fri, 21 Sep 2018 08:13:35 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYc6RaiEwfbKUxj+je5x20nzHbBNCulR+ems1pueTJ6hs4VungTJo6VdZ/3CyCY+Db1B+z/ X-Received: by 2002:a63:2bc9:: with SMTP id r192-v6mr42395378pgr.386.1537542815507; Fri, 21 Sep 2018 08:13:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537542815; cv=none; d=google.com; s=arc-20160816; b=obiBO1dGos9pOXeb1W4suwAkO5fdpFwl3g53ASJrnkH7sW5HhkvJOmeM6fS/aYZuis 6Nb6VW8kUham1QCcGmDp9XRqaeXinDfSTvq8VpXr/sBSzYRRUEJJj2n/itT4ivdSqSny pOH1y7HAC1xzcGl5kJCuDWFYbjZ7h9fFnTbsiuOS8TRU+6vChjhy6ElKn0T4Q7k5z3Ew Y0InDbijVYda+4+6nW/dnX92HpITnr9D+33B9ROUmJfS/J5QENB5ORrDjyTbiwg8xFIl di1QeD2inn84GJkpOuNCAxbQYoNe6ov4G1emZNa55/CQfh1P0KjbLOdhjIh5shFFDLnV ZKBg== 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=AOHK0mK6OMLhyVWfypXS6nFx+0YXj0Cflh1jDhzHtRg=; b=ho9RopRohbcjt+QAm7oxV0iVSzRJgEiO0HRTY77gOnId1JhaYDwQYPbUQnIZNH/p3m Zv2Jn8ReK+fA615PvVtZAyleO2OBt27snqlO/IuXVezzIldsR9OMvi0QHJQRZeQr8Xcc NoA8xzl2ZiA+cFmiQicnYmzfq8VGX/1oFf1BsDlVtYAGc5ywqM2uAyMMEhz4VdrvkTts 3ogVUmU3fDwO7tswRgWFMT6dUU9Z8VsojqtA/kFq3th9YONatKTHzpiag8TNhPDFZwEB 5edIckth9AotEimQDmGqz5myxnImcLgQgX9SsuuIrRvI9bSa0EgikLJ0g+WL8+HOQJQY rIsA== 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 e14-v6si26478494pgj.413.2018.09.21.08.13.17; Fri, 21 Sep 2018 08:13:35 -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 S2390787AbeIUU7n (ORCPT + 99 others); Fri, 21 Sep 2018 16:59:43 -0400 Received: from mga11.intel.com ([192.55.52.93]:13761 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390777AbeIUU7m (ORCPT ); Fri, 21 Sep 2018 16:59:42 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Sep 2018 08:10:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,285,1534834800"; d="scan'208";a="71856872" Received: from 2b52.sc.intel.com ([143.183.136.51]) by fmsmga007.fm.intel.com with ESMTP; 21 Sep 2018 08:09:54 -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 , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue Cc: Yu-cheng Yu Subject: [RFC PATCH v4 25/27] mm/mmap: Prevent Shadow Stack VMA merges Date: Fri, 21 Sep 2018 08:03:49 -0700 Message-Id: <20180921150351.20898-26-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180921150351.20898-1-yu-cheng.yu@intel.com> References: <20180921150351.20898-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 Function returns could unwind stacks beyond its allocated area. We do not merge shadow stack areas. This and VMA guards prevent shadow stack underflow. 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 de2d0faa1c61..fa581ced3f56 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