* [PATCH] arm64: kprobe: fix an error in single stepping support
@ 2025-01-11 9:56 1534428646
2025-01-12 8:31 ` Yeoreum Yun
0 siblings, 1 reply; 5+ messages in thread
From: 1534428646 @ 2025-01-11 9:56 UTC (permalink / raw)
To: catalin.marinas, will
Cc: mark.rutland, kristina.martsenko, liaochang1, linux-arm-kernel,
linux-kernel, stable, Yiren.Xie
From: "Yiren.Xie" <1534428646@qq.com>
It is obvious a conflict between the code and the comment.
And verified that with this modification it can read the DAIF status.
Signed-off-by: Yiren.Xie <1534428646@qq.com>
---
arch/arm64/kernel/probes/decode-insn.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/kernel/probes/decode-insn.c b/arch/arm64/kernel/probes/decode-insn.c
index 6438bf62e753..22383eb1c22c 100644
--- a/arch/arm64/kernel/probes/decode-insn.c
+++ b/arch/arm64/kernel/probes/decode-insn.c
@@ -40,7 +40,7 @@ static bool __kprobes aarch64_insn_is_steppable(u32 insn)
*/
if (aarch64_insn_is_mrs(insn))
return aarch64_insn_extract_system_reg(insn)
- != AARCH64_INSN_SPCLREG_DAIF;
+ == AARCH64_INSN_SPCLREG_DAIF;
/*
* The HINT instruction is steppable only if it is in whitelist
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] arm64: kprobe: fix an error in single stepping support
2025-01-11 9:56 1534428646
@ 2025-01-12 8:31 ` Yeoreum Yun
0 siblings, 0 replies; 5+ messages in thread
From: Yeoreum Yun @ 2025-01-12 8:31 UTC (permalink / raw)
To: 1534428646
Cc: catalin.marinas, will, mark.rutland, kristina.martsenko,
liaochang1, linux-arm-kernel, linux-kernel, stable
Hi Yiren,
> From: "Yiren.Xie" <1534428646@qq.com>
>
> It is obvious a conflict between the code and the comment.
> And verified that with this modification it can read the DAIF status.
>
> Signed-off-by: Yiren.Xie <1534428646@qq.com>
> ---
> arch/arm64/kernel/probes/decode-insn.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/kernel/probes/decode-insn.c b/arch/arm64/kernel/probes/decode-insn.c
> index 6438bf62e753..22383eb1c22c 100644
> --- a/arch/arm64/kernel/probes/decode-insn.c
> +++ b/arch/arm64/kernel/probes/decode-insn.c
> @@ -40,7 +40,7 @@ static bool __kprobes aarch64_insn_is_steppable(u32 insn)
> */
> if (aarch64_insn_is_mrs(insn))
> return aarch64_insn_extract_system_reg(insn)
> - != AARCH64_INSN_SPCLREG_DAIF;
> + == AARCH64_INSN_SPCLREG_DAIF;
>
> /*
> * The HINT instruction is steppable only if it is in whitelist
Nit:
When single-stepped, the DAIF bits are set, in setup_singlesteup(),
Reading a DAIF via mrs instruction isn't correct value as comments
describe.
What is conflict?
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] arm64: kprobe: fix an error in single stepping support
@ 2025-01-17 4:00 1534428646
2025-01-17 7:57 ` Yeoreum Yun
0 siblings, 1 reply; 5+ messages in thread
From: 1534428646 @ 2025-01-17 4:00 UTC (permalink / raw)
To: catalin.marinas, will
Cc: mark.rutland, kristina.martsenko, liaochang1, linux-arm-kernel,
linux-kernel, stable, yeoreum.yun, Yiren Xie
From: "Yiren Xie" <1534428646@qq.com>
It is obvious a conflict between the code and the comment.
The function aarch64_insn_is_steppable is used to check if a mrs
instruction can be safe in single-stepping environment, in the
comment it says only reading DAIF bits by mrs is safe in
single-stepping environment, and other mrs instructions are not. So
aarch64_insn_is_steppable should returen "TRUE" if the mrs instruction
being single stepped is reading DAIF bits.
And have verified using a kprobe kernel module which reads the DAIF bits by
function arch_local_irq_save with offset setting to 0x4, confirmed that
without this modification, it encounters
"kprobe_init: register_kprobe failed, returned -22" error while inserting
the kprobe kernel module. and with this modification, it can read the DAIF
bits in single-stepping environment.
Fixes: 2dd0e8d2d2a1 ("arm64: Kprobes with single stepping support")
Cc: stable@vger.kernel.org
Signed-off-by: Yiren Xie <1534428646@qq.com>
---
arch/arm64/kernel/probes/decode-insn.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/kernel/probes/decode-insn.c b/arch/arm64/kernel/probes/decode-insn.c
index 6438bf62e753..22383eb1c22c 100644
--- a/arch/arm64/kernel/probes/decode-insn.c
+++ b/arch/arm64/kernel/probes/decode-insn.c
@@ -40,7 +40,7 @@ static bool __kprobes aarch64_insn_is_steppable(u32 insn)
*/
if (aarch64_insn_is_mrs(insn))
return aarch64_insn_extract_system_reg(insn)
- != AARCH64_INSN_SPCLREG_DAIF;
+ == AARCH64_INSN_SPCLREG_DAIF;
/*
* The HINT instruction is steppable only if it is in whitelist
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] arm64: kprobe: fix an error in single stepping support
2025-01-17 4:00 [PATCH] arm64: kprobe: fix an error in single stepping support 1534428646
@ 2025-01-17 7:57 ` Yeoreum Yun
2025-02-04 11:31 ` Will Deacon
0 siblings, 1 reply; 5+ messages in thread
From: Yeoreum Yun @ 2025-01-17 7:57 UTC (permalink / raw)
To: 1534428646
Cc: catalin.marinas, will, mark.rutland, kristina.martsenko,
liaochang1, linux-arm-kernel, linux-kernel, stable
Hi,
>
> It is obvious a conflict between the code and the comment.
> The function aarch64_insn_is_steppable is used to check if a mrs
> instruction can be safe in single-stepping environment, in the
> comment it says only reading DAIF bits by mrs is safe in
> single-stepping environment, and other mrs instructions are not. So
> aarch64_insn_is_steppable should returen "TRUE" if the mrs instruction
> being single stepped is reading DAIF bits.
>
> And have verified using a kprobe kernel module which reads the DAIF bits by
> function arch_local_irq_save with offset setting to 0x4, confirmed that
> without this modification, it encounters
> "kprobe_init: register_kprobe failed, returned -22" error while inserting
> the kprobe kernel module. and with this modification, it can read the DAIF
> bits in single-stepping environment.
>
> Fixes: 2dd0e8d2d2a1 ("arm64: Kprobes with single stepping support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yiren Xie <1534428646@qq.com>
> ---
> arch/arm64/kernel/probes/decode-insn.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/kernel/probes/decode-insn.c b/arch/arm64/kernel/probes/decode-insn.c
> index 6438bf62e753..22383eb1c22c 100644
> --- a/arch/arm64/kernel/probes/decode-insn.c
> +++ b/arch/arm64/kernel/probes/decode-insn.c
> @@ -40,7 +40,7 @@ static bool __kprobes aarch64_insn_is_steppable(u32 insn)
> */
> if (aarch64_insn_is_mrs(insn))
> return aarch64_insn_extract_system_reg(insn)
> - != AARCH64_INSN_SPCLREG_DAIF;
> + == AARCH64_INSN_SPCLREG_DAIF;
>
> /*
> * The HINT instruction is steppable only if it is in whitelist
> --
> 2.34.1
>
Thanks to correct me. yes the comments seem conflict.
However, I couldn't agree to this change.
As I mention in last, when single-step runs, all DAIF bits set,
so, the result of reading DAIF is different between before install kprobe and after.
Also, I think reading some sys_reg in single-step seems ok (i.e. SYS_MIDR_EL1).
Therefore, allowing only install kprobe on DAIF reading doesn't seem
correct.
Thanks
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] arm64: kprobe: fix an error in single stepping support
2025-01-17 7:57 ` Yeoreum Yun
@ 2025-02-04 11:31 ` Will Deacon
0 siblings, 0 replies; 5+ messages in thread
From: Will Deacon @ 2025-02-04 11:31 UTC (permalink / raw)
To: Yeoreum Yun
Cc: 1534428646, catalin.marinas, mark.rutland, kristina.martsenko,
liaochang1, linux-arm-kernel, linux-kernel, stable
On Fri, Jan 17, 2025 at 07:57:32AM +0000, Yeoreum Yun wrote:
> > It is obvious a conflict between the code and the comment.
> > The function aarch64_insn_is_steppable is used to check if a mrs
> > instruction can be safe in single-stepping environment, in the
> > comment it says only reading DAIF bits by mrs is safe in
> > single-stepping environment, and other mrs instructions are not. So
> > aarch64_insn_is_steppable should returen "TRUE" if the mrs instruction
> > being single stepped is reading DAIF bits.
> >
> > And have verified using a kprobe kernel module which reads the DAIF bits by
> > function arch_local_irq_save with offset setting to 0x4, confirmed that
> > without this modification, it encounters
> > "kprobe_init: register_kprobe failed, returned -22" error while inserting
> > the kprobe kernel module. and with this modification, it can read the DAIF
> > bits in single-stepping environment.
> >
> > Fixes: 2dd0e8d2d2a1 ("arm64: Kprobes with single stepping support")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Yiren Xie <1534428646@qq.com>
> > ---
> > arch/arm64/kernel/probes/decode-insn.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/arm64/kernel/probes/decode-insn.c b/arch/arm64/kernel/probes/decode-insn.c
> > index 6438bf62e753..22383eb1c22c 100644
> > --- a/arch/arm64/kernel/probes/decode-insn.c
> > +++ b/arch/arm64/kernel/probes/decode-insn.c
> > @@ -40,7 +40,7 @@ static bool __kprobes aarch64_insn_is_steppable(u32 insn)
> > */
> > if (aarch64_insn_is_mrs(insn))
> > return aarch64_insn_extract_system_reg(insn)
> > - != AARCH64_INSN_SPCLREG_DAIF;
> > + == AARCH64_INSN_SPCLREG_DAIF;
> >
> > /*
> > * The HINT instruction is steppable only if it is in whitelist
> > --
> > 2.34.1
> >
>
> Thanks to correct me. yes the comments seem conflict.
>
> However, I couldn't agree to this change.
> As I mention in last, when single-step runs, all DAIF bits set,
> so, the result of reading DAIF is different between before install kprobe and after.
> Also, I think reading some sys_reg in single-step seems ok (i.e. SYS_MIDR_EL1).
>
> Therefore, allowing only install kprobe on DAIF reading doesn't seem
> correct.
Right, the code seems ok. I think we should just remove the comment
instead.
Will
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-02-04 11:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-17 4:00 [PATCH] arm64: kprobe: fix an error in single stepping support 1534428646
2025-01-17 7:57 ` Yeoreum Yun
2025-02-04 11:31 ` Will Deacon
-- strict thread matches above, loose matches on Subject: below --
2025-01-11 9:56 1534428646
2025-01-12 8:31 ` Yeoreum Yun
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).