From patchwork Fri Jun 29 22:39:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 10497719 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 3E2186022E for ; Fri, 29 Jun 2018 22:41:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B2AF28488 for ; Fri, 29 Jun 2018 22:41:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B0ED28595; Fri, 29 Jun 2018 22:41:45 +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,UNPARSEABLE_RELAY 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 DA4CE28488 for ; Fri, 29 Jun 2018 22:41:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0A3706B0269; Fri, 29 Jun 2018 18:41:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 053596B026A; Fri, 29 Jun 2018 18:41:42 -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 EABB26B026B; Fri, 29 Jun 2018 18:41:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f70.google.com (mail-pg0-f70.google.com [74.125.83.70]) by kanga.kvack.org (Postfix) with ESMTP id A9DBB6B0269 for ; Fri, 29 Jun 2018 18:41:42 -0400 (EDT) Received: by mail-pg0-f70.google.com with SMTP id u130-v6so4478136pgc.0 for ; Fri, 29 Jun 2018 15:41:42 -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=dK2POHR1ricfCG102wjuH5hBw6+RJPi1efOdEUmLe5c=; b=PN/JQy4Q3E9n24Am/iIoX3bwgXAwqaOAZnIr+33sAIxWUA4vWCn0J/olAsfHT1Rciu JzZkyFW4aTQhEW7NRRSwvlYw/dUgF4QtkOD8myLAqTGaw05fcyvCs2tSXkWpHxFwlqbp wQ4PjOhNLlhFMiwgKQb75l/tiV6MyBpiIr74vZ2lGt1Ov2ROuhaEWt8/2SoZS6IZOxh/ TGpTu4UCskRTpq8W4jnKVy5FLZcbfpHYcnIiTIulanc9IVrMJzVF5/Mui21GZ73mvHDp IBkzW3/vNhOH4MN5alRFaM9xTGK0FZWkLErUhNDSJIk4f5TSVM2OiMJp7hwugCN5Zbgu D0Iw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Gm-Message-State: APt69E1nEJ/Chuyxp3Fk/SLSJMjUBlv4rVAR2ssetYUXe7SfH3ZvMuSK BGh0BoTC/RNmZLK4nq+DWDV9VUf9FPIwDwGLBtcqay8h/oEJbuRe6gJhoAQ2JSvB/EdznNEDI2m bIFJXxv1FKBkkAJYiY5L+a/3IA85Xf9L0vNcMpsdd2zsTTrAzzgbvUrDtGqS5Y2At0A== X-Received: by 2002:a63:6501:: with SMTP id z1-v6mr14140180pgb.452.1530312102372; Fri, 29 Jun 2018 15:41:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKei0FZcbMm7zmaxCUk10NAE/KU2qYXfQ+SmkQv3twXTDZAFSe0R7C/nA7709PAfw6Ix2Eo X-Received: by 2002:a63:6501:: with SMTP id z1-v6mr14140151pgb.452.1530312101497; Fri, 29 Jun 2018 15:41:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530312101; cv=none; d=google.com; s=arc-20160816; b=wDgXTRqkVqjqNjkJXNJwdR9vSbaEtTD24lppsB0iXwlZvRMDys8NOMuowPCByJQvEL zRy+iqbj+b9rcOUfkBZszWtgsePM9Ow0ohm5cNR0YZ60mjv2hAuor4bJxpCy2QKv5oSA LHVfEb6MhtoQXILjAnhAM58Mhnv5xseCQsksJoWcR0mLghktotEMExY9v2TpzLKTgqH+ kKxMC2RgBw3Bzz4x48KN9w7b61lBffuk5GQFvjzuAU2k6pe0pbfqc3NIVh2RlaCAc0+V MXHt0v7nhum2jqcmwzJnp2+g2jSiRvaF+4UEMMB1SuThsrgNsckghoE3AaQI3ba7HP4G uz9g== 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=dK2POHR1ricfCG102wjuH5hBw6+RJPi1efOdEUmLe5c=; b=hLJ2fuFFzM1DmkK5+9X1k0YORGKE9D/WRPX5Na0HwzXQddeLErbNHokJJNIZgrfuJf VLdAMELVo+gA85VxPaROiivTfHBTgYfCOKCfBR10Gau9lG9pRAo35r7SD95qF4JrT9O2 1qgRcl4YvtrLv8QrNURmDmpdOxaW5aSvfXwt+VZJ6KxoUfjtU3SEkf4qQPwIl3IPwM5c UtIFfffe5/mdPnUmd/PeN65phQTxhfLFjR1VWzgM5tWR7R71T85+AfPAXA7Y6Ps3PTXx fBM6MDh3LOtze+S3NlluGBjkAV7YFfgfYXahRg9QAKpWj9Ut+Pqpq1BiIudsqz0l/LWf z8rA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com. [115.124.30.131]) by mx.google.com with ESMTPS id v12-v6si10721204plo.264.2018.06.29.15.41.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Jun 2018 15:41:41 -0700 (PDT) Received-SPF: pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.131 as permitted sender) client-ip=115.124.30.131; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R241e4; CH=green; FP=0|-1|-1|-1|0|-1|-1|-1; HT=e01f04455; MF=yang.shi@linux.alibaba.com; NM=1; PH=DS; RN=16; SR=0; TI=SMTPD_---0T3dXmHm_1530312021; Received: from e19h19392.et15sqa.tbsite.net(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0T3dXmHm_1530312021) by smtp.aliyun-inc.com(127.0.0.1); Sat, 30 Jun 2018 06:40:30 +0800 From: Yang Shi To: mhocko@kernel.org, willy@infradead.org, ldufour@linux.vnet.ibm.com, akpm@linux-foundation.org, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, tglx@linutronix.de, hpa@zytor.com Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org, x86@kernel.org, linux-kernel@vger.kernel.org Subject: [RFC v3 PATCH 5/5] x86: check VM_DEAD flag in page fault Date: Sat, 30 Jun 2018 06:39:45 +0800 Message-Id: <1530311985-31251-6-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530311985-31251-1-git-send-email-yang.shi@linux.alibaba.com> References: <1530311985-31251-1-git-send-email-yang.shi@linux.alibaba.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 Check VM_DEAD flag of vma in page fault handler, if it is set, trigger SIGSEGV. Cc: Michal Hocko Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Signed-off-by: Yang Shi --- arch/x86/mm/fault.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 9a84a0d..3fd2da5 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -1357,6 +1357,10 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs) bad_area(regs, error_code, address); return; } + if (unlikely(vma->vm_flags & VM_DEAD)) { + bad_area(regs, error_code, address); + return; + } if (error_code & X86_PF_USER) { /* * Accessing the stack below %sp is always a bug.