* [PATCH] ARM: don't enter kgdb when userspace executes a kgdb break instruction.
@ 2014-08-01 3:05 Omar Sandoval
2014-08-01 8:10 ` Will Deacon
0 siblings, 1 reply; 2+ messages in thread
From: Omar Sandoval @ 2014-08-01 3:05 UTC (permalink / raw)
To: linux-arm-kernel
The kgdb breakpoint hooks (kgdb_brk_fn and kgdb_compiled_brk_fn) should only be
entered when a kgdb break instruction is executed from the kernel. Otherwise,
if kgdb is enabled, a userspace program can cause the kernel to drop into the
debugger by executing either KGDB_BREAKINST or KGDB_COMPILED_BREAK.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
---
On a kernel running with kgdb enabled, this program reproduces the problem:
.globl _start
_start:
udf #65006 @ KGDB_BREAKINST
The same problem has been fixed in ARM64.
arch/arm/kernel/kgdb.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/arm/kernel/kgdb.c b/arch/arm/kernel/kgdb.c
index 778c2f7..a74b53c 100644
--- a/arch/arm/kernel/kgdb.c
+++ b/arch/arm/kernel/kgdb.c
@@ -160,12 +160,16 @@ static int kgdb_compiled_brk_fn(struct pt_regs *regs, unsigned int instr)
static struct undef_hook kgdb_brkpt_hook = {
.instr_mask = 0xffffffff,
.instr_val = KGDB_BREAKINST,
+ .cpsr_mask = MODE_MASK,
+ .cpsr_val = SVC_MODE,
.fn = kgdb_brk_fn
};
static struct undef_hook kgdb_compiled_brkpt_hook = {
.instr_mask = 0xffffffff,
.instr_val = KGDB_COMPILED_BREAK,
+ .cpsr_mask = MODE_MASK,
+ .cpsr_val = SVC_MODE,
.fn = kgdb_compiled_brk_fn
};
--
2.0.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] ARM: don't enter kgdb when userspace executes a kgdb break instruction.
2014-08-01 3:05 [PATCH] ARM: don't enter kgdb when userspace executes a kgdb break instruction Omar Sandoval
@ 2014-08-01 8:10 ` Will Deacon
0 siblings, 0 replies; 2+ messages in thread
From: Will Deacon @ 2014-08-01 8:10 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Aug 01, 2014 at 04:05:20AM +0100, Omar Sandoval wrote:
> The kgdb breakpoint hooks (kgdb_brk_fn and kgdb_compiled_brk_fn) should only be
> entered when a kgdb break instruction is executed from the kernel. Otherwise,
> if kgdb is enabled, a userspace program can cause the kernel to drop into the
> debugger by executing either KGDB_BREAKINST or KGDB_COMPILED_BREAK.
>
> Signed-off-by: Omar Sandoval <osandov@osandov.com>
> ---
> On a kernel running with kgdb enabled, this program reproduces the problem:
> .globl _start
> _start:
> udf #65006 @ KGDB_BREAKINST
>
> The same problem has been fixed in ARM64.
>
> arch/arm/kernel/kgdb.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/arch/arm/kernel/kgdb.c b/arch/arm/kernel/kgdb.c
> index 778c2f7..a74b53c 100644
> --- a/arch/arm/kernel/kgdb.c
> +++ b/arch/arm/kernel/kgdb.c
> @@ -160,12 +160,16 @@ static int kgdb_compiled_brk_fn(struct pt_regs *regs, unsigned int instr)
> static struct undef_hook kgdb_brkpt_hook = {
> .instr_mask = 0xffffffff,
> .instr_val = KGDB_BREAKINST,
> + .cpsr_mask = MODE_MASK,
> + .cpsr_val = SVC_MODE,
> .fn = kgdb_brk_fn
> };
>
> static struct undef_hook kgdb_compiled_brkpt_hook = {
> .instr_mask = 0xffffffff,
> .instr_val = KGDB_COMPILED_BREAK,
> + .cpsr_mask = MODE_MASK,
> + .cpsr_val = SVC_MODE,
> .fn = kgdb_compiled_brk_fn
> };
Acked-by: Will Deacon <will.deacon@arm.com>
Please put this into rmk's patch system.
Cheers,
Will
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-08-01 8:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-01 3:05 [PATCH] ARM: don't enter kgdb when userspace executes a kgdb break instruction Omar Sandoval
2014-08-01 8:10 ` Will Deacon
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).