Patch "kdb: Fix pager search for multi-line strings" 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: Fix pager search for multi-line strings

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-fix-pager-search-for-multi-line-strings.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 72f08330f4d8f1a9688003ec012a01c62525a304
Author: Daniel Thompson <daniel.thompson@xxxxxxxxxx>
Date:   Wed Sep 9 15:17:08 2020 +0100

    kdb: Fix pager search for multi-line strings
    
    [ Upstream commit d081a6e353168f15e63eb9e9334757f20343319f ]
    
    Currently using forward search doesn't handle multi-line strings correctly.
    The search routine replaces line breaks with \0 during the search and, for
    regular searches ("help | grep Common\n"), there is code after the line
    has been discarded or printed to replace the break character.
    
    However during a pager search ("help\n" followed by "/Common\n") when the
    string is matched we will immediately return to normal output and the code
    that should restore the \n becomes unreachable. Fix this by restoring the
    replaced character when we disable the search mode and update the comment
    accordingly.
    
    Fixes: fb6daa7520f9d ("kdb: Provide forward search at more prompt")
    Link: https://lore.kernel.org/r/20200909141708.338273-1-daniel.thompson@xxxxxxxxxx
    Reviewed-by: Douglas Anderson <dianders@xxxxxxxxxxxx>
    Signed-off-by: Daniel Thompson <daniel.thompson@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
index 3a5184eb6977d..46821793637a1 100644
--- a/kernel/debug/kdb/kdb_io.c
+++ b/kernel/debug/kdb/kdb_io.c
@@ -679,12 +679,16 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap)
 			size_avail = sizeof(kdb_buffer) - len;
 			goto kdb_print_out;
 		}
-		if (kdb_grepping_flag >= KDB_GREPPING_FLAG_SEARCH)
+		if (kdb_grepping_flag >= KDB_GREPPING_FLAG_SEARCH) {
 			/*
 			 * This was a interactive search (using '/' at more
-			 * prompt) and it has completed. Clear the flag.
+			 * prompt) and it has completed. Replace the \0 with
+			 * its original value to ensure multi-line strings
+			 * are handled properly, and return to normal mode.
 			 */
+			*cphold = replaced_byte;
 			kdb_grepping_flag = 0;
+		}
 		/*
 		 * at this point the string is a full line and
 		 * should be printed, up to the null.



[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