Patch "kdb: Censor attempts to set PROMPT without ENABLE_MEM_READ" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    kdb: Censor attempts to set PROMPT without ENABLE_MEM_READ

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     kdb-censor-attempts-to-set-prompt-without-enable_mem.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 03b0465e580090c36c885556160beb6d9966534d
Author: Daniel Thompson <daniel.thompson@xxxxxxxxxx>
Date:   Thu Feb 13 15:16:40 2020 +0000

    kdb: Censor attempts to set PROMPT without ENABLE_MEM_READ
    
    [ Upstream commit ad99b5105c0823ff02126497f4366e6a8009453e ]
    
    Currently the PROMPT variable could be abused to provoke the printf()
    machinery to read outside the current stack frame. Normally this
    doesn't matter becaues md is already a much better tool for reading
    from memory.
    
    However the md command can be disabled by not setting KDB_ENABLE_MEM_READ.
    Let's also prevent PROMPT from being modified in these circumstances.
    
    Whilst adding a comment to help future code reviewers we also remove
    the #ifdef where PROMPT in consumed. There is no problem passing an
    unused (0) to snprintf when !CONFIG_SMP.
    argument
    
    Reported-by: Wang Xiayang <xywang.sjtu@xxxxxxxxxxx>
    Signed-off-by: Daniel Thompson <daniel.thompson@xxxxxxxxxx>
    Reviewed-by: Douglas Anderson <dianders@xxxxxxxxxxxx>
    Stable-dep-of: 4f41d30cd6dc ("kdb: Fix a potential buffer overflow in kdb_local()")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index 7c96bf9a6c2c..f8f087193644 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -452,6 +452,13 @@ int kdb_set(int argc, const char **argv)
 	if (argc != 2)
 		return KDB_ARGCOUNT;
 
+	/*
+	 * Censor sensitive variables
+	 */
+	if (strcmp(argv[1], "PROMPT") == 0 &&
+	    !kdb_check_flags(KDB_ENABLE_MEM_READ, kdb_cmd_enabled, false))
+		return KDB_NOPERM;
+
 	/*
 	 * Check for internal variables
 	 */
@@ -1355,12 +1362,9 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs,
 		*(cmd_hist[cmd_head]) = '\0';
 
 do_full_getstr:
-#if defined(CONFIG_SMP)
+		/* PROMPT can only be set if we have MEM_READ permission. */
 		snprintf(kdb_prompt_str, CMD_BUFLEN, kdbgetenv("PROMPT"),
 			 raw_smp_processor_id());
-#else
-		snprintf(kdb_prompt_str, CMD_BUFLEN, kdbgetenv("PROMPT"));
-#endif
 		if (defcmd_in_progress)
 			strncat(kdb_prompt_str, "[defcmd]", CMD_BUFLEN);
 




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux