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)) From patchwork Thu Jun 8 19:41:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 103404 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp2392344obh; Thu, 8 Jun 2017 12:42:09 -0700 (PDT) X-Received: by 10.98.55.198 with SMTP id e189mr39209307pfa.38.1496950929490; Thu, 08 Jun 2017 12:42:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496950929; cv=none; d=google.com; s=arc-20160816; b=yens6aZLOX8dSSRNj8wls4tswvHthTrf8b7jRUTwKd/Uaasq4CDF/W6Gt/jqetcud8 EypkCqUMFxduurQXXbvkW/aIiu/lOIN2KjSYyVJUlFjiBvbOBvoOkvOcU4ukb21ZLK5I M99ZJGWv7gJpRGGC9D/+den2H11FENdzdFm5S5ns3FPLqT/6PwqeHduj9IWe+21jYtCm RK5TjHCTHRecplYEMH4tCkXo/qWWFSoxxfqB4jdxWDfZwnFWBL6kZi1wATuQ2CwEA2kt qwvkc7kl/+gYXuAKKTb6K2asps3hDDDXuONhOzlR1B0EMSqiQdgrnIdW55mP2Qk9XdmJ Onpg== 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=+65y7sZFqARmFMNVMF5fGEgR2F2Ppas1ZfGDSS1cVak=; b=ejv6TFkfpcUxTqgnKmkP+xdp8QZofJdgGpSr957HpKYmlWTzQ+nqSZocMmB85BAv9s TrRhcZNi5ElWRQBfqESnDIxKJDvUhknqGOXgcInfRvXsepLd6IOv8YyCpa6rNRZHgmHH OsyqibST+G95IPN0YoYmRLJ8LoO5uJKkQP3hMHMPuucSlwomrRa3ZYQIxbAXieWucClt VBIVRJ29WDr+wT6aylv0E2frsirVxqge+UyZyK5SCtspOswXYeVQEpXTmX4e+zQW3zd1 golYEZzGEeJA+8KvYkRurt7akV8z+hsYVDURSAmMk7vruvCgLRK9/5x56R559hGh4R+c BWKw== 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 t22si5340818plj.119.2017.06.08.12.42.09; Thu, 08 Jun 2017 12:42:09 -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 S1751848AbdFHTmB (ORCPT + 25 others); Thu, 8 Jun 2017 15:42:01 -0400 Received: from mail-wm0-f51.google.com ([74.125.82.51]:38004 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751626AbdFHTl7 (ORCPT ); Thu, 8 Jun 2017 15:41:59 -0400 Received: by mail-wm0-f51.google.com with SMTP id n195so37585750wmg.1 for ; Thu, 08 Jun 2017 12:41:58 -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=+65y7sZFqARmFMNVMF5fGEgR2F2Ppas1ZfGDSS1cVak=; b=TdwcyScBWPw0ZV2/UFhiDGm1FtXfMze5fMwrtCB1rQawlwuCvdwuIr12Oh+SoNItVS MmtHoC2NV/QqiBhaG+zd0zl8cADa0rfTZIQRZKsEeJnZ3v/Qn2QeHJlEblL4q1N4iuB6 ULI04QvKRuWc6SPtZ7idiTVqyDxlIIyTHA5wU= 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=+65y7sZFqARmFMNVMF5fGEgR2F2Ppas1ZfGDSS1cVak=; b=HtJIHxOmt2VIxY+DFGyKjWu9ErIxDDJk4WPo2MJiVFi36rLiu3BY8fqI9UMQ4gjtOZ PqNz1E9uEUNB6HcNV4Xpiov0upYbJMolHnJlIxUqhAVcszNgWHaUwO9woynV1IJdBvwS UXtdC0pRAb9OXB8CjCh30rHP0NPbbQUOOfP2AUxxsL5taxcvr6NosNCAFOR19093yh8J FQLob90p1Klcwr3eY0RFbPaQupmC4fXncAGdJQ4RE8U3DZ99ZZH+wORIpzIXR6fUuJui HebZg+ExhmCnOmEp5WoqffgtOXN6I8MjZS2BiZqSDRyllZGwCRPbuBmwksSt3aiCauN+ hDOQ== X-Gm-Message-State: AKS2vOxoRC0ziC4J3mHt7IYA83+U5q42D3ICC0ZIl28Tm+Qp9HhtO3Zc qXV+Wj8LNKBXOjUJGXWh7w== X-Received: by 10.28.47.138 with SMTP id v132mr1683271wmv.77.1496950912743; Thu, 08 Jun 2017 12:41:52 -0700 (PDT) Received: from localhost.localdomain ([160.162.216.209]) by smtp.gmail.com with ESMTPSA id x20sm5585038wrd.63.2017.06.08.12.41.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jun 2017 12:41:51 -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 2/2] arm64: mm: select CONFIG_ARCH_PROC_KCORE_TEXT Date: Thu, 8 Jun 2017 19:41:39 +0000 Message-Id: <20170608194139.9250-3-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 To avoid issues with the /proc/kcore code getting confused about the kernels block mappings in the VMALLOC region, enable the existing facility that describes the [_text, _end) interval as a separate KCORE_TEXT region, which supersedes the KCORE_VMALLOC region that it intersects with on arm64. Signed-off-by: Ard Biesheuvel --- arch/arm64/Kconfig | 3 +++ 1 file changed, 3 insertions(+) -- 2.9.3 diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 3dcd7ec69bca..65173b39cfc2 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -244,6 +244,9 @@ config PGTABLE_LEVELS config ARCH_SUPPORTS_UPROBES def_bool y +config ARCH_PROC_KCORE_TEXT + def_bool y + source "init/Kconfig" source "kernel/Kconfig.freezer"