[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87tu05pvur.fsf@all.your.base.are.belong.to.us>
Date: Wed, 01 Feb 2023 10:40:12 +0100
From: Björn Töpel <bjorn@...nel.org>
To: guoren@...nel.org, guoren@...nel.org, palmer@...osinc.com,
conor.dooley@...rochip.com, liaochang1@...wei.com
Cc: linux-arch@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-riscv@...ts.infradead.org,
Guo Ren <guoren@...ux.alibaba.com>,
Bjorn Topel <bjorn.topel@...il.com>
Subject: Re: [PATCH] riscv: kprobe: Fixup misaligned load text
guoren@...nel.org writes:
> From: Guo Ren <guoren@...ux.alibaba.com>
>
> The current kprobe would cause a misaligned load for the probe point.
> This patch fixup it with two half-word loads instead.
>
> Fixes: c22b0bcb1dd0 ("riscv: Add kprobes supported")
> Signed-off-by: Guo Ren <guoren@...ux.alibaba.com>
> Signed-off-by: Guo Ren <guoren@...nel.org>
> Link: https://lore.kernel.org/linux-riscv/878rhig9zj.fsf@all.your.base.are.belong.to.us/
> Reported-by: Bjorn Topel <bjorn.topel@...il.com>
> ---
> arch/riscv/kernel/probes/kprobes.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/probes/kprobes.c b/arch/riscv/kernel/probes/kprobes.c
> index 41c7481afde3..c1160629cef4 100644
> --- a/arch/riscv/kernel/probes/kprobes.c
> +++ b/arch/riscv/kernel/probes/kprobes.c
> @@ -74,7 +74,9 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
> return -EILSEQ;
>
> /* copy instruction */
> - p->opcode = *p->addr;
> + p->opcode = (kprobe_opcode_t)(*(u16 *)probe_addr);
> + if (GET_INSN_LENGTH(p->opcode) == 4)
> + p->opcode |= (kprobe_opcode_t)(*(u16 *)(probe_addr + 2))
> << 16;
Ugh, those casts. :-( What about the memcpy variant you had in the other
thread?
Powered by blists - more mailing lists