From patchwork Thu Jun 7 14:38:06 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: 10452315 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 2426160146 for ; Thu, 7 Jun 2018 14:42:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 141E1294DB for ; Thu, 7 Jun 2018 14:42:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 087C029508; Thu, 7 Jun 2018 14:42:07 +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 93F7B294DB for ; Thu, 7 Jun 2018 14:42:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 969A46B028B; Thu, 7 Jun 2018 10:41:36 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 91C056B028F; Thu, 7 Jun 2018 10:41:36 -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 7C1AD6B0290; Thu, 7 Jun 2018 10:41:36 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f69.google.com (mail-pl0-f69.google.com [209.85.160.69]) by kanga.kvack.org (Postfix) with ESMTP id 287F16B028B for ; Thu, 7 Jun 2018 10:41:36 -0400 (EDT) Received: by mail-pl0-f69.google.com with SMTP id 31-v6so5521659plf.19 for ; Thu, 07 Jun 2018 07:41:36 -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=PMT+XatEyji00HKFm06FGH8cyqQ1CberXAqMdlFtiGU=; b=Zka8jn7oTFXa2PTgU4yLgreTyKTNPxIU8XkN5z4B1Kj6xnS7kPr9PumYSZ2dsn0QWF Hiir2d7JxwvNse0Rms5uqgdllRvnfVUVjYnoCvCx3ri6LLEuI83YVquTFwXBkt33dt6G HEpcrUKwsYOTPi2tYCDo53Judu49UGUgtdBW6G8kLX/dXzEKMLKhvNYzlvm/C2m2L9bd 8j6b97wfaImQ/t9m2nZZbWdlk8PsoKVSfuFiLWseSpWy3o6+8dUHXMZFBYMxCzE/Yy9c SELcBRAl6MAvnEplHp3cfFlG7WDbxDDoLevCShloYGycEaUZk2giuhIMG/NYXZp6P2mR pVBg== 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: APt69E2pby3yZJq327TkS5zE8pX9Hxnz4R4EElQXP0k4L2mi0bFIvVPM 15cFwOwYI2UyNTGTwGDk1i1EWbWbE7DgPTDUFH9xAENV4YuIGH/jiltDD4oUzbx/tjLAed2puFb er0PE2ZSoDhMMuXh9CcNNXXxC4498a1HWHI5zNmYYvQgl63TkNKZXT+Yzjr2Vd+DPlQ== X-Received: by 2002:a63:9902:: with SMTP id d2-v6mr1861638pge.166.1528382495863; Thu, 07 Jun 2018 07:41:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJcRcP9a1dY3ejD7qpzFtWOyRKoRkh4SsecFyI3XJvqABD8JKEGdl/ay2WPzzcIYVM63hw5 X-Received: by 2002:a63:9902:: with SMTP id d2-v6mr1861612pge.166.1528382495253; Thu, 07 Jun 2018 07:41:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528382495; cv=none; d=google.com; s=arc-20160816; b=UbTZSwTYY4nNgroaHFw4r1mDtCP+09Rm9VlT9ITuQC7nWY3keOzDrO289hGfT0r7jl 5rboYSq0GjMsl5abiYP7b/SmuIKvI6lcN7jWC2eIepekm8JQrlnTPE3ilQn5JJkviimz iwp/GOgz/MWP2V0WTyC8wPeFaCgJ/b5XxPy7X+HPqa3igCdMoMc5RWUdUOEa5Zqp9tiY pg4ZJJdFmvQRkZW+JipoztRNgdfQ3dpdDRBWuHuLZIhleBkNLe93kGRIEiqkhbY7K8L5 +9LaomUijPSI8taSZ4yYVAFnDEf0DFebXFGaOS5x4gZmYLQM0iYrVAyQDFvArLplYI8f ZVaQ== 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=PMT+XatEyji00HKFm06FGH8cyqQ1CberXAqMdlFtiGU=; b=oh3gNIj4QS3Ny3eixLLnK6SbzDANqatVsehMjg+U7eUXa/KMXjU24alE6tiu5m+iHe 1AYpHDi1nQRvr0Hrm1QMSEFGXh1QPK7kPFKl7z/LPuSF2iIs07nER5Rsiz34qniBnyH5 TjVd4i8EWt4PwJ7Dgnsr0wbZV4muEvhzo4GDHTHUof8oO1hrzvPrcEVs1Yw4nPA5XmhN N63zghFmB/n64WP+D7mEFXVpjMxx0LXlzds0oYUJcGQnQeFEX+eG2fdMduIJNMuqojgc sVrKBoSNPPzSidvnS78MI/+6UvGLhIdZOsWkZJxuZG3kzATrIKvU2PCtUylwM1W3+g1t 9mRQ== 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.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 07:41:35 -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="62632655" Received: from 2b52.sc.intel.com ([143.183.136.51]) by orsmga001.jf.intel.com with ESMTP; 07 Jun 2018 07:41:34 -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 09/10] mm: Prevent madvise from changing shadow stack Date: Thu, 7 Jun 2018 07:38:06 -0700 Message-Id: <20180607143807.3611-10-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/madvise.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/madvise.c b/mm/madvise.c index 4d3c922ea1a1..2a6988badd6b 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -839,6 +839,14 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior) if (vma && start > vma->vm_start) prev = vma; + /* + * Don't do anything on shadow stack. + */ + if (vma->vm_flags & VM_SHSTK) { + error = -EINVAL; + goto out_no_plug; + } + blk_start_plug(&plug); for (;;) { /* Still start < end. */ @@ -876,6 +884,7 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior) } out: blk_finish_plug(&plug); +out_no_plug: if (write) up_write(¤t->mm->mmap_sem); else