From: Oleg Nesterov <oleg@redhat.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
Anton Arapov <aarapov@redhat.com>,
David Smith <dsmith@redhat.com>,
"Frank Ch. Eigler" <fche@redhat.com>,
Martin Cermak <mcermak@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 3/6] uprobes: Teach __create_xol_area() to accept the predefined vaddr
Date: Fri, 18 Oct 2013 17:50:18 +0200 [thread overview]
Message-ID: <20131018155018.GA15033@redhat.com> (raw)
In-Reply-To: <20131018154947.GA15002@redhat.com>
Currently xol_add_vma() uses get_unmapped_area() for area->vaddr,
but the next patches need to use the fixed address. So this patch
adds the new "vaddr" argument to __create_xol_area() which should
be used as area->vaddr if it is nonzero.
xol_add_vma() doesn't bother to verify that the predefined addr is
not used, insert_vm_struct() should fail if find_vma_links() detects
the overlap with the existing vma.
Also, __create_xol_area() doesn't need __GFP_ZERO to allocate area.
Cc: stable@vger.kernel.org # 3.9+
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
---
kernel/events/uprobes.c | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 0e3e956..c836135 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1104,11 +1104,14 @@ static int xol_add_vma(struct mm_struct *mm, struct xol_area *area)
if (mm->uprobes_state.xol_area)
goto fail;
- /* 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);
- if (area->vaddr & ~PAGE_MASK) {
- ret = area->vaddr;
- goto fail;
+ 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);
+ if (area->vaddr & ~PAGE_MASK) {
+ ret = area->vaddr;
+ goto fail;
+ }
}
ret = install_special_mapping(mm, area->vaddr, PAGE_SIZE,
@@ -1124,13 +1127,13 @@ static int xol_add_vma(struct mm_struct *mm, struct xol_area *area)
return ret;
}
-static struct xol_area *__create_xol_area(void)
+static struct xol_area *__create_xol_area(unsigned long vaddr)
{
struct mm_struct *mm = current->mm;
uprobe_opcode_t insn = UPROBE_SWBP_INSN;
struct xol_area *area;
- area = kzalloc(sizeof(*area), GFP_KERNEL);
+ area = kmalloc(sizeof(*area), GFP_KERNEL);
if (unlikely(!area))
goto out;
@@ -1142,6 +1145,7 @@ static struct xol_area *__create_xol_area(void)
if (!area->page)
goto free_bitmap;
+ area->vaddr = vaddr;
init_waitqueue_head(&area->wq);
/* Reserve the 1st slot for get_trampoline_vaddr() */
set_bit(0, area->bitmap);
@@ -1172,7 +1176,7 @@ static struct xol_area *get_xol_area(void)
struct xol_area *area;
if (!mm->uprobes_state.xol_area)
- __create_xol_area();
+ __create_xol_area(0);
area = mm->uprobes_state.xol_area;
smp_read_barrier_depends(); /* pairs with wmb in xol_add_vma() */
--
1.5.5.1
next prev parent reply other threads:[~2013-10-18 15:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-18 15:49 [PATCH v2 0/6] uprobes: fix fork() with the pending ret-probe(s) Oleg Nesterov
2013-10-18 15:50 ` [PATCH v2 1/6] uprobes: Change the callsite of uprobe_copy_process() Oleg Nesterov
2013-10-18 15:50 ` [PATCH v2 2/6] uprobes: Introduce __create_xol_area() Oleg Nesterov
2013-10-18 15:50 ` Oleg Nesterov [this message]
2013-10-18 15:50 ` [PATCH v2 4/6] uprobes: Change uprobe_copy_process() to dup return_instances Oleg Nesterov
2013-10-18 15:50 ` [PATCH v2 5/6] uprobes: Change uprobe_copy_process() to dup xol_area Oleg Nesterov
2013-10-18 15:50 ` [PATCH v2 6/6] uprobes: Teach uprobe_copy_process() to handle CLONE_VFORK 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=20131018155018.GA15033@redhat.com \
--to=oleg@redhat.com \
--cc=aarapov@redhat.com \
--cc=ananth@in.ibm.com \
--cc=dsmith@redhat.com \
--cc=fche@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mcermak@redhat.com \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=srikar@linux.vnet.ibm.com \
/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