From: dave.long@linaro.org (David Long)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH v4] ARM: uprobes xol write directly to userspace
Date: Wed, 16 Apr 2014 16:24:18 -0400 [thread overview]
Message-ID: <534EE6F2.3050005@linaro.org> (raw)
In-Reply-To: <20140416.153734.675854782374654510.davem@davemloft.net>
On 04/16/14 15:37, David Miller wrote:
> From: Oleg Nesterov <oleg@redhat.com>
> Date: Wed, 16 Apr 2014 21:18:25 +0200
>
>> The last question... area->page = alloc_page(GFP_HIGHUSER), and I am
>> not sure that arch/arm/mm/highmem.c:kmap_atomic() can't break the
>> aliasing, __fix_to_virt() in this case will use the same (per-cpu) idx.
>>
>> Looks like, __kunmap_atomic()->__cpuc_flush_dcache_area() should take
>> care, but could you please ack/nack my understanding?
>
> Good point, it might therefore make sense to use a low-mem page.
>
The following test code seems to have the same problems with stale user
icache. It works if I put the dcache flush back in. Am I missing
something?
-dl
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 04709b6..10ad973 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -34,6 +34,7 @@
#include <linux/ptrace.h> /* user_enable_single_step */
#include <linux/kdebug.h> /* notifier mechanism */
#include "../../mm/internal.h" /* munlock_vma_page */
+#include <linux/mman.h>
#include <linux/percpu-rwsem.h>
#include <linux/task_work.h>
@@ -1141,7 +1142,7 @@ static int xol_add_vma(struct mm_struct *mm, struct xol_area *area)
if (!area->vaddr) {
/* Try to map as high as possible, this is only a hint. */
area->vaddr = get_unmapped_area(NULL, TASK_SIZE - PAGE_SIZE,
- PAGE_SIZE, 0, 0);
+ PAGE_SIZE, page_to_pfn(area->page), MAP_SHARED);
if (area->vaddr & ~PAGE_MASK) {
ret = area->vaddr;
goto fail;
@@ -1175,7 +1176,7 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
if (!area->bitmap)
goto free_area;
- area->page = alloc_page(GFP_HIGHUSER);
+ area->page = alloc_page(GFP_USER);
if (!area->page)
goto free_bitmap;
@@ -1299,11 +1300,8 @@ static unsigned long xol_get_insn_slot(struct uprobe *uprobe)
/* Initialize the slot */
copy_to_page(area->page, xol_vaddr,
&uprobe->arch.ixol, sizeof(uprobe->arch.ixol));
- /*
- * We probably need flush_icache_user_range() but it needs vma.
- * This should work on supported architectures too.
- */
- flush_dcache_page(area->page);
+/* Temporary hard-core icache flush for testing */
+ __flush_icache_all();
return xol_vaddr;
}
next prev parent reply other threads:[~2014-04-16 20:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-16 5:31 [RFC PATCH v4] ARM: uprobes xol write directly to userspace Victor Kamensky
2014-04-16 5:31 ` Victor Kamensky
2014-04-16 14:51 ` Oleg Nesterov
2014-04-16 15:00 ` David Miller
2014-04-16 16:43 ` Oleg Nesterov
2014-04-16 17:38 ` David Miller
2014-04-16 19:18 ` Oleg Nesterov
2014-04-16 19:37 ` David Miller
2014-04-16 20:24 ` David Long [this message]
2014-04-16 21:21 ` David Miller
2014-04-16 22:01 ` Victor Kamensky
2014-04-16 22:25 ` Russell King - ARM Linux
2014-04-16 23:19 ` David Long
2014-04-21 16:16 ` David Long
2014-04-21 16:41 ` Linus Torvalds
2014-04-21 17:56 ` Victor Kamensky
2014-04-16 19:53 ` Russell King - ARM Linux
2014-04-16 20:23 ` Oleg Nesterov
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=534EE6F2.3050005@linaro.org \
--to=dave.long@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).