Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp622770pxx; Wed, 28 Oct 2020 12:39:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpJd0k2zhcNMzn/rNjfG31nljWdZ4HrGJfnGwAKWAZSqe0SI/32LIpdy2yX6mB8RrMNHbG X-Received: by 2002:aa7:c704:: with SMTP id i4mr500581edq.51.1603913978560; Wed, 28 Oct 2020 12:39:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603913978; cv=none; d=google.com; s=arc-20160816; b=q9uwLEjS23h6pE37yUyOvYf/8/rq6FGxTV0Jb9hWZBduAIHiXdCamib7W3kJ+jfI/A ui/7G1hqmcbr8Z3B0r5iEd/4BWh1TAR7S9NFPDkLxp18UqVpplnaq3CQq6nxqbR84tmI j0YRoGgud5HPq3tozHC9AbcoflzfQxB084fbMDwPSCxSrbUMVrA1aZLchUr8vg4xYrMB b8ts3lPon6FaIIM0CYXNV3pp3i13noZCgO2BNdUmV64lmeQEPl0l5sfLQV9sR5slwg29 V33Jb9HvgyLoSMXNMkuDrOAiDfD70BZZtqCuNvmx/KRUzZ+1tpfhLuh5PnwWINA3gVfb JffQ== 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=u4vmAYFVffkUJeR73tFf/zyLMxBMna8ruDy86nA/dQM=; b=mFufBtS621xa7hEEqUiL6kzTRW7WwyMUeQwtMFhzm8Z2UU/xsHPCjJtrGFDBW2Mdjp LJnb5k/VP35mRxWDS3Rsn8MNpn5TnlTJ3BUPmQ5yA40KSref2V9c7LFnT0n4iiqKmNtA PGgAFzN5LJrDCgm4q9pxvZjgOSCM2omJ2ZgpA4CJ1SeBdpQ8DNVrgbV1f78K1/ttKQWG xfSrXGj5JEbvGNKbjQR7/Y1JcckFtghF7tjfuUry+r5jCUBHEIy4stG/7bnhLEYe/CzI j1tdsOhJ3aZzAeEzwXXHXKp9PQ2OD77JJkUM0J7BJFaGKiXVS//7DYG5XcsbDqrZLOie kaMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EdAn1RqT; 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 m26si11386edq.372.2020.10.28.12.39.15; Wed, 28 Oct 2020 12:39:38 -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=EdAn1RqT; 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 S1827673AbgJ0S0a (ORCPT + 99 others); Tue, 27 Oct 2020 14:26:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:48180 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2504321AbgJ0OAj (ORCPT ); Tue, 27 Oct 2020 10:00:39 -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 BA9CC221F8; Tue, 27 Oct 2020 14:00:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807239; bh=kLqIkf1/SE8r4Wp0lP0UfuPx18W515CGoNhTtTNwxRQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EdAn1RqTjjfX1ZHINkxDtPfp3iBJR0rSn42ju9uvkXLQ+nxKrPktO09Lb4ebS8b6L Lpp1eY9XV78fIGbxm3Pc08KHL4V+ENlhNMx9ahGCVcAgvFvq+O6hU8liJMa4BVCJRS MgbCw0L3TySOa7DhmkVVn5obzO+LOHwbhtmNYYck= 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.4 063/112] kdb: Fix pager search for multi-line strings Date: Tue, 27 Oct 2020 14:49:33 +0100 Message-Id: <20201027134903.552351943@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134900.532249571@linuxfoundation.org> References: <20201027134900.532249571@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 cc892a9e109d8..ae39b014b7d6c 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c @@ -683,12 +683,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