From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
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 [thread overview]
Message-ID: <20170608194139.9250-2-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <20170608194139.9250-1-ard.biesheuvel@linaro.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 <ard.biesheuvel@linaro.org>
---
fs/proc/kcore.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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))
--
2.9.3
next prev parent reply other threads:[~2017-06-08 19:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-08 19:41 [PATCH 0/2] arm64: fix crash when reading /proc/kcore Ard Biesheuvel
2017-06-08 19:41 ` Ard Biesheuvel [this message]
2017-06-08 19:41 ` [PATCH 2/2] arm64: mm: select CONFIG_ARCH_PROC_KCORE_TEXT Ard Biesheuvel
2017-06-09 10:00 ` [PATCH 0/2] arm64: fix crash when reading /proc/kcore Mark Rutland
2017-06-09 18:05 ` Laura Abbott
2017-06-13 2:00 ` Tan Xiaojun
2017-06-13 7:17 ` Ard Biesheuvel
2017-06-13 14:06 ` Jiri Olsa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170608194139.9250-2-ard.biesheuvel@linaro.org \
--to=ard.biesheuvel@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).