Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp592404pxx; Wed, 28 Oct 2020 11:55:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykb7U+lnTDb3JL7a3Qvl+ziDcecmKVAhSCn7pgAFlHzc2uQkGG81oF79Gbna5UdgMr7JKX X-Received: by 2002:a17:906:791:: with SMTP id l17mr436624ejc.361.1603911327002; Wed, 28 Oct 2020 11:55:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603911326; cv=none; d=google.com; s=arc-20160816; b=DrRfWBpzaqYH6OevQ/q/bCzT8VI+X1JhhX7JsZH8DFDerfRFBuZffOEKj19FOsI1+Z 5XuycZJJxbZ2kQ6ynn5KWoprD6p1oWU9DJ6/ZGTG0rgDFhojBzlZWO2MvoR9TMq1Xsjp LjmfDKMzCEXk3BIq9pcRKhdE0RxsK4RY1C6KUZQL1LW9r+rR5Mb+LvNewDPngoUR8cO0 f9lp65Xqo6fQ6RSwSmOZbjUirSfZRtECWzLBquosh2c1WodcJs05Jgy1bf+Zz+kZcqci 7PE+H686wIzlF6DJbj0Kot5D5Aw708Xhq7SuD/2nszvPU7RWhu9MNZ5UTywRIEbh7gLw iSFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=33VqUmi+7qGAo5a8B8ynTWn8jZMH0qVanBlrLmdfJeA=; b=Shd1HKL0BKgc1tDESturvZCBG3ecP+Y5AbTUIIdCHTwE/qYyIjq3JzQIWIgVa+J2Ms 7XHxTi9H21NCToAN+gXpbUvI3jCNz/1AS01nQcjtn+fhoPXkZKQaFl1TaOFQg4Raj7k4 a9FBlfGZRZbZfB2u4hlfWONLeewqnfuEezLeU2q+XzsM/EcOMOB/1N50lCr/aELung/i Qh1c0Qv7kS0G9oEcNsN0BfXDSM0Xds+TwPESTYsTg7vrZbblAhmCnOcsoKFvw6WOdFMi WW3kgTITgOOLPqOYygXVGG00jszdcW9nGdnfAm82nMrFCYWUbB6ZaMnSM7dFLaCBDM0q Eulg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nG1v2iHM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c8si22307edl.252.2020.10.28.11.55.03; Wed, 28 Oct 2020 11:55:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nG1v2iHM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1826057AbgJ0SPj (ORCPT + 99 others); Tue, 27 Oct 2020 14:15:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:33692 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2507379AbgJ0OMd (ORCPT ); Tue, 27 Oct 2020 10:12:33 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 86E4C2072D; Tue, 27 Oct 2020 14:12:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807951; bh=2RU+PsPd0o+xNPcfjaO05Gfg4PkwgqFkzVMBW53GFgk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nG1v2iHMW5CDGaTjbh3siRXcuHiRtfxy9LY0YJ/ijlBeEtTE+Jh+rCazYb+5mbV9U oBf/dS1bca88CM8HLOmiYGF8l7lVLEhTrgdioZ17dtUFKV3TC8K61Ofc+DQR2ZOWSL TXcpeMECtf2rKr5+qNncGedXvOrB/ZGXHz7VcBmw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Douglas Anderson , Daniel Thompson , Sasha Levin Subject: [PATCH 4.14 100/191] kdb: Fix pager search for multi-line strings Date: Tue, 27 Oct 2020 14:49:15 +0100 Message-Id: <20201027134914.512356487@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134909.701581493@linuxfoundation.org> References: <20201027134909.701581493@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daniel Thompson [ 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@linaro.org Reviewed-by: Douglas Anderson Signed-off-by: Daniel Thompson Signed-off-by: Sasha Levin --- kernel/debug/kdb/kdb_io.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c index 6a4b41484afe6..b45576ca3b0da 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. -- 2.25.1