ARM: don't enter kgdb when userspace executes a kgdb break instruction.
PATCH 1/1 ARM: don't enter kgdb when userspace executes a kgdb break instruction.
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.
---
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(+)
arch/arm/kernel/kgdb.c +4 -0
@@ -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 };
Signature · 1 line
2.0.3
Quoted 27 lines · Omar Sandoval
The kgdb breakpoint hooks (
kgdb_brk_fnandkgdb_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 eitherKGDB_BREAKINSTorKGDB_COMPILED_BREAK.Signed-off-by Omar Sandoval <[email protected]>---
On a kernel running with kgdb enabled, this program reproduces the problem:
.globl_start_start:udf #65006 @ KGDB_BREAKINSTThe same problem has been fixed in ARM64.
arch/arm/kernel/kgdb.c | 4 ++++ 1 file changed, 4 insertions(+)arch/arm/kernel/kgdb.c +2
-0@@ -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 ,
arch/arm/kernel/kgdb.c static int kgdb_compiled_brk_fn(struct pt_regs *regs, unsigned int instr) · line 174
Quoted 10 lines
arch/arm/kernel/kgdb.c +2
-0.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 };
Please put this into rmk's patch system.
Cheers,
Will