From patchwork Thu Jun 8 19:41:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 103403 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp2392270obh; Thu, 8 Jun 2017 12:41:56 -0700 (PDT) X-Received: by 10.101.70.12 with SMTP id v12mr9123284pgq.160.1496950916853; Thu, 08 Jun 2017 12:41:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496950916; cv=none; d=google.com; s=arc-20160816; b=Hya2WZrz/Ytt8IZXRXeSwxgOgPOt4XcltqHOeQS2xmuth342LhQdFmGbdpaLO+RAEG HQCFiPq8YowQ678/X9EFNvlRFYdYhp3wr+kbAtt1vee4unzh52OI9FeEk+aLt702k+/3 7PHKhmeWb9AXFRw6fcRY8BG3P6PIqhRy9mmvGprJ183sM0bC1RAEIMjHNAe3ezZ4udYK XrHLZRrNTNVF4snkuVs+oJdKknYn7Yx3gzwQeLtRG3UMrBxWD1muffy8CRpacD3t6avt dkADeF5rYpNCaTZdlRk/9dxBkeafZvDapML4aFZ3ZOSK5Hbo0hB0IBhiBi0iX2ckRIMD Ireg== 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:dkim-signature:arc-authentication-results; bh=WIRYOc/MW9eQvsEUiYgltPwSgu6rgOtPXs/DIYPOuU4=; b=kTkmnUAyLviHPFevXvaus8lEwY5vqV3PSzAPz2xoyONvAa+TZd7cPMIlPtdzfzn/X2 lt8/kY20k0dfQOaxvbNc9frCVeaozsLMel4iqZpwomBZrbHye1YOgIqFJNTmyzq1ieym cK6EMDLjG4ClzeW+6p5PUmamlwVIrtfqBE8PstZBgW0Sj8RuNLpn4sEJ9stATh9WuOG7 AUEEATFsLdJRBcAVAe91esPBK95RZCES4YzFVFhICR84bHnXerxoHyf+pew4x7lnRAZj Ii5sluJz+2T71tEx9PPyyfUqHWKFtDwCHNwibq3FXDgupdIwxIlGr2yygFx3T/JPMeP9 2rqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a13si229291pfc.9.2017.06.08.12.41.56; Thu, 08 Jun 2017 12:41:56 -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; dkim=pass header.i=@linaro.org; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751831AbdFHTly (ORCPT + 25 others); Thu, 8 Jun 2017 15:41:54 -0400 Received: from mail-wr0-f170.google.com ([209.85.128.170]:36132 "EHLO mail-wr0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751753AbdFHTlw (ORCPT ); Thu, 8 Jun 2017 15:41:52 -0400 Received: by mail-wr0-f170.google.com with SMTP id v111so22495613wrc.3 for ; Thu, 08 Jun 2017 12:41:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WIRYOc/MW9eQvsEUiYgltPwSgu6rgOtPXs/DIYPOuU4=; b=eTsl2I4idGHk1PEKCqWap0xkljr2pmzKyQ3HB423GYNhbRuSUnI4eK4vpRlOFhsGzR IYAA2HeaPH2erlyQij64ySUlIrwlZOQ2nr24EeaDeIcQIqDXKn063S9YiKPGoKKxnQGI LOygKcNk8NqYjhbvLND+Zw7OAvr00NasOeJQ8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WIRYOc/MW9eQvsEUiYgltPwSgu6rgOtPXs/DIYPOuU4=; b=n2iKnGoTY98YfDVUmmWpP80V7jH5wTl2O3483jzZ0YEbQwrV0qiq5CXSqfoD5lwcbO rW1/zaE36zV7AgsUIchpNBy96rT15eUr+iE8Va4PSRiKXm8RUjJa1Q82LmBMw2/uqS5+ 3sa5NZktUbrxj4Gqc3O5DzzWTi3wgfJQ7YIRm+RMK6RqjWjt1HlUZxL8eOpdgi6w5SbC i3aUpetCwJ/t6Y5gVGEg5h08hP6k0qpAqorj7zvnUjAMGqUepXIvFrOr4wxwBO4HHo0n 9P7u6c0l0Z377floKWzWivPpkZ7NRdItE/au51MCechyEcPHD4t3fPx4f8pIa6sh5CKE esXQ== X-Gm-Message-State: AODbwcA8NKr821rIEIRUW0SaikxlKl/paH1EbO0leoyly4fH/5PyHRtL HNXdY9fqTV2XIClkKV8EQA== X-Received: by 10.223.181.132 with SMTP id c4mr12457313wre.167.1496950910445; Thu, 08 Jun 2017 12:41:50 -0700 (PDT) Received: from localhost.localdomain ([160.162.216.209]) by smtp.gmail.com with ESMTPSA id x20sm5585038wrd.63.2017.06.08.12.41.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jun 2017 12:41:49 -0700 (PDT) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, jolsa@kernel.org, mingo@kernel.org, akpm@linux-foundation.org, zhongjiang@huawei.com, labbott@fedoraproject.org, mark.rutland@arm.com, Ard Biesheuvel Subject: [PATCH 1/2] fs/proc: kcore: use kcore_list type to check for vmalloc/module address Date: Thu, 8 Jun 2017 19:41:38 +0000 Message-Id: <20170608194139.9250-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170608194139.9250-1-ard.biesheuvel@linaro.org> References: <20170608194139.9250-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of passing each start address into is_vmalloc_or_module_addr() to decide whether it falls into either the VMALLOC or the MODULES region, we can simply check the type field of the current kcore_list entry, since it will be set to KCORE_VMALLOC based on exactly the same conditions. As a bonus, when reading the KCORE_TEXT region on architectures that have one, this will avoid using vread() on the region if it happens to intersect with a KCORE_VMALLOC region. This is due the fact that the KCORE_TEXT region is the first one to be added to the kcore region list. Signed-off-by: Ard Biesheuvel --- fs/proc/kcore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.9.3 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index 4ee55274f155..45629f4b5402 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c @@ -504,7 +504,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) if (&m->list == &kclist_head) { if (clear_user(buffer, tsz)) return -EFAULT; - } else if (is_vmalloc_or_module_addr((void *)start)) { + } else if (m->type == KCORE_VMALLOC) { vread(buf, (char *)start, tsz); /* we have to zero-fill user buffer even if no read */ if (copy_to_user(buffer, buf, tsz))