Skip to content

Commit

Permalink
UBUNTU: SAUCE: debug: Lock down kgdb
Browse files Browse the repository at this point in the history
KGDB and KDB allow read and write access to kernel memory, and thus
should not be allowed during lockdown. An attacker with access to a
serial port (for example, via a hypervisor console, which some cloud
vendors provide over the network) could trigger the debugger and use it
to bypass lockdown. Ensure KDB and KGDB cannot be used during lockdown.

This fixes CVE-2022-21499.

Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
CVE-2022-21499
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Acked-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
Acked-by: Andrea Righi <andrea.righi@canonical.com>
  • Loading branch information
Stephen Brennan authored and Thadeu Lima de Souza Cascardo committed May 25, 2022
1 parent 3eed95f commit abcd64c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/linux/security.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ enum lockdown_reason {
LOCKDOWN_DEBUGFS,
LOCKDOWN_XMON_WR,
LOCKDOWN_BPF_WRITE_USER,
LOCKDOWN_KGDB,
LOCKDOWN_INTEGRITY_MAX,
LOCKDOWN_KCORE,
LOCKDOWN_KPROBES,
Expand Down
3 changes: 3 additions & 0 deletions kernel/debug/debug_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include <linux/vmacache.h>
#include <linux/rcupdate.h>
#include <linux/irq.h>
#include <linux/security.h>

#include <asm/cacheflush.h>
#include <asm/byteorder.h>
Expand Down Expand Up @@ -748,6 +749,8 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs,

while (1) {
cpu_master_loop:
if (security_locked_down(LOCKDOWN_KGDB))
break;
if (dbg_kdb_mode) {
kgdb_connected = 1;
error = kdb_stub(ks);
Expand Down
1 change: 1 addition & 0 deletions security/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1] = {
[LOCKDOWN_DEBUGFS] = "debugfs access",
[LOCKDOWN_XMON_WR] = "xmon write access",
[LOCKDOWN_BPF_WRITE_USER] = "use of bpf to write user RAM",
[LOCKDOWN_KGDB] = "KDB or KGDB access",
[LOCKDOWN_INTEGRITY_MAX] = "integrity",
[LOCKDOWN_KCORE] = "/proc/kcore access",
[LOCKDOWN_KPROBES] = "use of kprobes",
Expand Down

0 comments on commit abcd64c

Please sign in to comment.