Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp473266pxk; Wed, 9 Sep 2020 10:04:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvHBglE1ACudnKKOAdE5MO7V/Y3f8c3i34gyZD4+qtcNxgkfc547R4L5wZaZ930Rqs6YxE X-Received: by 2002:a50:8524:: with SMTP id 33mr5307643edr.123.1599671063267; Wed, 09 Sep 2020 10:04:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599671063; cv=none; d=google.com; s=arc-20160816; b=PtRgM/BKwGiA2FWeJrbg+G8bPh9oIY2p7yB2o+IcDNH6lQN/4CJUo9yQbI5TJWPPYv 6KvsMCqPf4wRg0byYvnOrpO9GYARZh7bhejh6aOoKqnl2D7f8WXGzW1YPv7s271auvK1 5fuWA1ZmLYMwGPHjapQCZFyiWyLmOykJS7JsubIP/LJHFeg/c+sNOMxposWoSrhLtn+3 CKvCzWmmTibSZxHItXaplILgeKMy/lrdUpj6n/YFWrtYc9oY1ZYpJ8KU1AI3CcDq88Mo R8AKlshXuGWdizeGpLi4xJs31jwA7o869/QsIiczWkV/RIs/Z1UI3ZB9K7dOerOuay/T gknQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=z9k53vYT+N1BhX48Rij3GUI6/3bZme1pQPIscVRVPBk=; b=oNEEH0xrRp0ltp57vG1pKr+fN1Rs8ljmxcLoMPv4JcHjq+6wjDeb3hjv0J8x9ktoyI +pTzF5q7nYp/y4lvjombCFaKHLTga6wTIv5Vm2yvfU1kXaR92rad7eb8KrHqRxkZk7Dc j374is/AhUPkGF9QHvcTVrWq9glb7ux0AF2FvOiQTS/PSoIqTWV7S3ZwjRe1u2YLJwmm vpIXkybaHqnjwSRwMAamp3lkCD9LryHnkoM18QEc2nUxAhDbG1niCIqhr2HNbXqlFhpG OzVXrf8uzqZP0rB/BaCAql0Dl3FYeg39pjBNidN2DiyRVrpvyzQPS9Bqfa4bSmHoWS0S YlUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w7pR2L08; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oi22si1978922ejb.85.2020.09.09.10.03.48; Wed, 09 Sep 2020 10:04:23 -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=@linaro.org header.s=google header.b=w7pR2L08; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730898AbgIIRCY (ORCPT + 99 others); Wed, 9 Sep 2020 13:02:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730502AbgIIPr0 (ORCPT ); Wed, 9 Sep 2020 11:47:26 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DAE2C061374 for ; Wed, 9 Sep 2020 07:18:07 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id w5so3139414wrp.8 for ; Wed, 09 Sep 2020 07:18:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=z9k53vYT+N1BhX48Rij3GUI6/3bZme1pQPIscVRVPBk=; b=w7pR2L08zpdeRf35Al+3qzs7BazoxXi4K4IFvtwZqlJyksSS0c7H3PF2KZ2sgSSDpP FujlD1ob/vsHrx5wxZLDonYVVHtcd+AXdHbZfNbNzsCZkbidsTZ+Lr4Nfn2Nd9M9vZBu 6WI2b+ZvoxZ3zrP6nAIC6cjUK0kdYgTnytIoeXk4TNJlyjW7FMxZBxbkvHoOBZ82Zlrd kIL8pIbKnrXxflQBzM8bWpfk3tpF7rBN8mZm195zu+18tAAPCku7Da+vnsHdKAA/FT74 EElHBXICQCjxCOv9+mZ/k2kk1GjvOPKLrcQ7X/wJpKqivHZx1iP9jiI/2aQIvbMhY/jx h32Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=z9k53vYT+N1BhX48Rij3GUI6/3bZme1pQPIscVRVPBk=; b=OKNq2X7Sf36qBMU9dW1WyW1WWtRkxX7FFaH08Shmsu1Ca4P/5sd6LYEZeM4bwzPeh9 H/Ru9KDkf3oGeFyIlZhntW5lRWiR5i71+d+yLG/KwdztD3mIbBlAWKERX626n/m7UX9+ 7eVTAmsEzvmsd6gSqUxEU4e2TJ1vnY1LN4HzBMKvFVfrMufZgR/ezIF7vCp5eaf2e2jo 5NXKcEGwdiPaAKMeCoS8IEbEC3up9M5mpKXGVvAeRc9gAamJrW3e5OTThS+PpuoHQ8vi BzOhQqAfnq+VNumq0zjo0CCqdm7LbGvUO8yshWE8pX50+lXTuUFSYiYguO62TkWyn5Vp 8toA== X-Gm-Message-State: AOAM533ZE8OS7pBWvqzbWV7G4XtFKCi39LHvprwzlVSPAVnOBXGLIH8m DLMXgevQqe8Lq7/ZBFzhdu06ng== X-Received: by 2002:a5d:5042:: with SMTP id h2mr4138682wrt.409.1599661085905; Wed, 09 Sep 2020 07:18:05 -0700 (PDT) Received: from wychelm.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id q18sm4463736wre.78.2020.09.09.07.18.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 07:18:05 -0700 (PDT) From: Daniel Thompson To: Douglas Anderson , Jason Wessel Cc: Daniel Thompson , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, patches@linaro.org Subject: [PATCH] kdb: Fix pager search for multi-line strings Date: Wed, 9 Sep 2020 15:17:08 +0100 Message-Id: <20200909141708.338273-1-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 acordingly. Fixes: fb6daa7520f9d ("kdb: Provide forward search at more prompt") Signed-off-by: Daniel Thompson --- Notes: In the long term the kdb pager code would probably benefit from a bigger rewrite since the way it handles newlines is still quirky and confusing. However this fix is easy to backport so I decided not to hold it back whilst we wait for code that is not yet written. 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 9d847ab851db..e240c97086e2 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c @@ -706,12 +706,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. base-commit: f75aef392f869018f78cfedf3c320a6b3fcfda6b -- 2.25.4