From: osandov@osandov.com (Omar Sandoval)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: don't enter kgdb when userspace executes a kgdb break instruction.
Date: Thu, 31 Jul 2014 20:05:20 -0700 [thread overview]
Message-ID: <20140801030520.GA27665@mew> (raw)
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
WARNING: multiple messages have this Message-ID (diff)
From: Omar Sandoval <osandov@osandov.com>
To: will.deacon@arm.com, linux-arm-kernel@lists.infradead.org,
linux@arm.linux.org.uk, linux-kernel@vger.kernel.org,
Catalin.Marinas@arm.com
Subject: [PATCH] ARM: don't enter kgdb when userspace executes a kgdb break instruction.
Date: Thu, 31 Jul 2014 20:05:20 -0700 [thread overview]
Message-ID: <20140801030520.GA27665@mew> (raw)
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
next reply other threads:[~2014-08-01 3:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-01 3:05 Omar Sandoval [this message]
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
2014-08-01 8:10 ` Will Deacon
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=20140801030520.GA27665@mew \
--to=osandov@osandov.com \
--cc=linux-arm-kernel@lists.infradead.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.