-
Notifications
You must be signed in to change notification settings - Fork 10
[ciqlts8_6] lockdown: also lock down previous kgdb use #895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: ciqlts8_6
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -168,10 +168,46 @@ struct task_struct *kdb_curr_task(int cpu) | |
| } | ||
|
|
||
| /* | ||
| * Check whether the flags of the current command and the permissions | ||
| * of the kdb console has allow a command to be run. | ||
| * Update the permissions flags (kdb_cmd_enabled) to match the | ||
| * current lockdown state. | ||
| * | ||
| * When the kernel is locked down, strip all memory/register read and | ||
| * write permissions as well as flow control from kdb_cmd_enabled. | ||
| * | ||
| * The remaining permitted flags are: INSPECT, SIGNAL, REBOOT | ||
| * (and ALWAYS_SAFE). | ||
| * | ||
| * INSPECT commands are not blocked during lockdown because they are | ||
| * not arbitrary memory reads. INSPECT covers the backtrace family | ||
| * (sometimes forcing them to have no arguments) and lsmod. These | ||
| * commands do expose some kernel state but do not allow the developer | ||
| * seated at the console to choose what state is reported. SIGNAL and | ||
| * REBOOT should not be controversial, given these are allowed for | ||
| * root during lockdown already. | ||
|
Comment on lines
+171
to
+186
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment doesn't match the upstream commit (see interdiff output). Copy the function comment from the upstream commit wholesale. |
||
| */ | ||
| static void kdb_check_for_lockdown(void) | ||
| { | ||
| const int write_flags = KDB_ENABLE_MEM_WRITE | | ||
| KDB_ENABLE_REG_WRITE | | ||
| KDB_ENABLE_FLOW_CTRL; | ||
| const int read_flags = KDB_ENABLE_MEM_READ | | ||
| KDB_ENABLE_REG_READ; | ||
|
|
||
| if (!kernel_is_locked_down("Use of kgdb/kdb to read/write kernel RAM")) | ||
| return; | ||
|
|
||
| /* De-compose KDB_ENABLE_ALL if required */ | ||
| if (kdb_cmd_enabled & KDB_ENABLE_ALL) | ||
| kdb_cmd_enabled = KDB_ENABLE_MASK & ~KDB_ENABLE_ALL; | ||
|
|
||
| kdb_cmd_enabled &= ~(write_flags | read_flags); | ||
|
Comment on lines
+196
to
+203
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are two subtle differences between this code and the upstream code:
Resolve both points by copying+pasting the entire kdb_check_for_lockdown() function from the upstream commit and then make the following two changes:
|
||
| } | ||
|
|
||
| /* | ||
| * Check whether the flags of the current command, the permissions of the kdb | ||
| * console and the lockdown state allow a command to be run. | ||
| */ | ||
| static inline bool kdb_check_flags(kdb_cmdflags_t flags, int permissions, | ||
| static bool kdb_check_flags(kdb_cmdflags_t flags, int permissions, | ||
| bool no_args) | ||
| { | ||
| /* permissions comes from userspace so needs massaging slightly */ | ||
|
|
@@ -1169,6 +1205,9 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs, | |
| kdb_curr_task(raw_smp_processor_id()); | ||
|
|
||
| KDB_DEBUG_STATE("kdb_local 1", reason); | ||
|
|
||
| kdb_check_for_lockdown(); | ||
|
|
||
| kdb_go_count = 0; | ||
| if (reason == KDB_REASON_DEBUG) { | ||
| /* special case below */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first letter of this message isn't capitalized in the upstream commit. Change the message to
"use of kgdb/kdb to write kernel RAM"to match upstream.