From: Oleg Nesterov <oleg@redhat.com>
To: Liao Chang <liaochang1@huawei.com>
Cc: jolsa@kernel.org, rostedt@goodmis.org, mhiramat@kernel.org,
ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
nathan@kernel.org, peterz@infradead.org, mingo@redhat.com,
mark.rutland@arm.com, linux-perf-users@vger.kernel.org,
linux-kernel@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next] uprobes: Fix the xol slots reserved for uretprobe trampoline
Date: Wed, 19 Jun 2024 16:38:52 +0200 [thread overview]
Message-ID: <20240619143852.GA24240@redhat.com> (raw)
In-Reply-To: <20240619013411.756995-1-liaochang1@huawei.com>
On 06/19, Liao Chang wrote:
>
> When the new uretprobe system call was added [1], the xol slots reserved
> for the uretprobe trampoline might be insufficient on some architecture.
Confused... this doesn't depend on the change above?
> 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.
Do you mean that on arm64 UPROBE_SWBP_INSN_SIZE > UPROBE_XOL_SLOT_BYTES ?
From arch/arm64/include/asm/uprobes.h
#define MAX_UINSN_BYTES AARCH64_INSN_SIZE
#define UPROBE_SWBP_INSN cpu_to_le32(BRK64_OPCODE_UPROBES)
#define UPROBE_SWBP_INSN_SIZE AARCH64_INSN_SIZE
#define UPROBE_XOL_SLOT_BYTES MAX_UINSN_BYTES
typedef __le32 uprobe_opcode_t;
struct arch_uprobe_task {
};
struct arch_uprobe {
union {
u8 insn[MAX_UINSN_BYTES];
u8 ixol[MAX_UINSN_BYTES];
So it seems that UPROBE_SWBP_INSN_SIZE == MAX_UINSN_BYTES and it must
be less than UPROBE_XOL_SLOT_BYTES, otherwise
arch_uprobe_copy_ixol(..., uprobe->arch.ixol, sizeof(uprobe->arch.ixol))
in xol_get_insn_slot() won't fit the slot as well?
OTOH, it look as if UPROBE_SWBP_INSN_SIZE == UPROBE_XOL_SLOT_BYTES, so
I don't understand the problem...
Oleg.
> [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
>
next prev parent reply other threads:[~2024-06-19 14:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=20240619143852.GA24240@redhat.com \
--to=oleg@redhat.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jolsa@kernel.org \
--cc=liaochang1@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=nathan@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.