linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] uprobes: Fix the xol slots reserved for uretprobe trampoline
@ 2024-06-19  1:34 Liao Chang
  2024-06-19 14:38 ` Oleg Nesterov
  2024-06-19 16:22 ` Jiri Olsa
  0 siblings, 2 replies; 12+ messages in thread
From: Liao Chang @ 2024-06-19  1:34 UTC (permalink / raw)
  To: jolsa, rostedt, mhiramat, oleg, ast, daniel, andrii, nathan,
	peterz, mingo, mark.rutland
  Cc: linux-perf-users, linux-kernel, bpf

When the new uretprobe system call was added [1], the xol slots reserved
for the uretprobe trampoline might be insufficient on some architecture.
For example, on arm64, the trampoline is consist of three instructions
at least. So it should mark enough bits in area->bitmaps and
and area->slot_count for the reserved slots.

[1] https://lore.kernel.org/all/20240611112158.40795-4-jolsa@kernel.org/

Signed-off-by: Liao Chang <liaochang1@huawei.com>
---
 kernel/events/uprobes.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 2816e65729ac..efd2d7f56622 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1485,7 +1485,7 @@ void * __weak arch_uprobe_trampoline(unsigned long *psize)
 static struct xol_area *__create_xol_area(unsigned long vaddr)
 {
 	struct mm_struct *mm = current->mm;
-	unsigned long insns_size;
+	unsigned long insns_size, slot_nr;
 	struct xol_area *area;
 	void *insns;
 
@@ -1508,10 +1508,13 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
 
 	area->vaddr = vaddr;
 	init_waitqueue_head(&area->wq);
-	/* Reserve the 1st slot for get_trampoline_vaddr() */
-	set_bit(0, area->bitmap);
-	atomic_set(&area->slot_count, 1);
 	insns = arch_uprobe_trampoline(&insns_size);
+	/* Reserve enough slots for the uretprobe trampoline */
+	for (slot_nr = 0;
+	     slot_nr < max((insns_size / UPROBE_XOL_SLOT_BYTES), 1);
+	     slot_nr++)
+		set_bit(slot_nr, area->bitmap);
+	atomic_set(&area->slot_count, slot_nr);
 	arch_uprobe_copy_ixol(area->pages[0], 0, insns, insns_size);
 
 	if (!xol_add_vma(mm, area))
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-07-03  8:54 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-19  1:34 [PATCH bpf-next] uprobes: Fix the xol slots reserved for uretprobe trampoline Liao Chang
2024-06-19 14:38 ` Oleg Nesterov
2024-06-20  2:39   ` Liao, Chang
2024-06-20  8:36     ` Oleg Nesterov
2024-06-20  9:06       ` Jiri Olsa
2024-06-20 11:27         ` Liao, Chang
2024-07-03  8:54           ` Liao, Chang
2024-06-20  9:58       ` Liao, Chang
2024-06-20 10:52         ` Oleg Nesterov
2024-06-20 11:58           ` Liao, Chang
2024-06-19 16:22 ` Jiri Olsa
2024-06-20  2:58   ` Liao, Chang

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).