dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0382-gdb-Restrict-GDB-access-when-locked-down.patch

80913e
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
80913e
From: Javier Martinez Canillas <javierm@redhat.com>
80913e
Date: Wed, 24 Feb 2021 15:03:26 +0100
80913e
Subject: [PATCH] gdb: Restrict GDB access when locked down
80913e
80913e
The gdbstub* commands allow to start and control a GDB stub running on
80913e
local host that can be used to connect from a remote debugger. Restrict
80913e
this functionality when the GRUB is locked down.
80913e
80913e
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
80913e
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
80913e
---
80913e
 grub-core/gdb/gdb.c | 32 ++++++++++++++++++--------------
80913e
 1 file changed, 18 insertions(+), 14 deletions(-)
80913e
80913e
diff --git a/grub-core/gdb/gdb.c b/grub-core/gdb/gdb.c
80913e
index 847a1e1e36f..1818cb6f8eb 100644
80913e
--- a/grub-core/gdb/gdb.c
80913e
+++ b/grub-core/gdb/gdb.c
80913e
@@ -75,20 +75,24 @@ static grub_command_t cmd, cmd_stop, cmd_break;
80913e
 GRUB_MOD_INIT (gdb)
80913e
 {
80913e
   grub_gdb_idtinit ();
80913e
-  cmd = grub_register_command ("gdbstub", grub_cmd_gdbstub,
80913e
-			       N_("PORT"), 
80913e
-			       /* TRANSLATORS: GDB stub is a small part of
80913e
-				  GDB functionality running on local host
80913e
-				  which allows remote debugger to
80913e
-				  connect to it.  */
80913e
-			       N_("Start GDB stub on given port"));
80913e
-  cmd_break = grub_register_command ("gdbstub_break", grub_cmd_gdb_break,
80913e
-				     /* TRANSLATORS: this refers to triggering
80913e
-					a breakpoint so that the user will land
80913e
-					into GDB.  */
80913e
-				     0, N_("Break into GDB"));
80913e
-  cmd_stop = grub_register_command ("gdbstub_stop", grub_cmd_gdbstop,
80913e
-				    0, N_("Stop GDB stub"));
80913e
+  cmd = grub_register_command_lockdown ("gdbstub", grub_cmd_gdbstub,
80913e
+					N_("PORT"),
80913e
+					/*
80913e
+					 * TRANSLATORS: GDB stub is a small part of
80913e
+					 * GDB functionality running on local host
80913e
+					 * which allows remote debugger to
80913e
+					 * connect to it.
80913e
+					 */
80913e
+					N_("Start GDB stub on given port"));
80913e
+  cmd_break = grub_register_command_lockdown ("gdbstub_break", grub_cmd_gdb_break,
80913e
+					      /*
80913e
+					       * TRANSLATORS: this refers to triggering
80913e
+					       * a breakpoint so that the user will land
80913e
+					       * into GDB.
80913e
+					       */
80913e
+					      0, N_("Break into GDB"));
80913e
+  cmd_stop = grub_register_command_lockdown ("gdbstub_stop", grub_cmd_gdbstop,
80913e
+					     0, N_("Stop GDB stub"));
80913e
 }
80913e
 
80913e
 GRUB_MOD_FINI (gdb)