From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9C3E137914; Thu, 13 Jun 2024 12:09:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718280576; cv=none; b=VGrQ9cnKnqzQbEw1XECMkBsOn4SJ//2VBTrCtg5kRPXzNuPJX+TUwaU+/GMjZfL+UyUd7O/IboXSm8h0ADaew0UKaW6tJBcBck5Vf0JJHKZUV2P46wv9bGY8+tWagLATCsSZOlZZ9G/GAR0EDEemu+48hgOJ9UdhyH9Lp1FjHRc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718280576; c=relaxed/simple; bh=rMCu1FWwErkPNxr35T0E7We6xxsZlAjr0v1BkHPnAdM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CQanHkXroo2Vg047hW7GFv7z2pga0gi+bRW2hFRSaQVF/XU7LtfV2rPzIlGrsm45EL33CxAQ3RwK4VrJSghq7geQKLEE6vH4HfoQi3DKPn2EzlKHFTQvj7vYBe6GtNj4VBKMB9BIJjSX4/XMstV+EYP0fKlUZW5eCK133sxXPm0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Ztm73l1b; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Ztm73l1b" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42A2DC2BBFC; Thu, 13 Jun 2024 12:09:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1718280576; bh=rMCu1FWwErkPNxr35T0E7We6xxsZlAjr0v1BkHPnAdM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ztm73l1b0mcN9SbDQvig9ydGmyDY9XFkHjZVWD+QSkgCfEEqeBK87L/DrlttJCL+p 5ys8JrsIomEtBC/n3FA4FldK+ZUEJ4M0F32XZVNtLjMv1izJjsvWsxBoIdMF+sry1d Ey7ZAQC3+RRcm11ZjTPDueB0/QgynNMt6O+iUsNY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Douglas Anderson , Justin Stitt , Daniel Thompson Subject: [PATCH 6.6 100/137] kdb: Fix console handling when editing and tab-completing commands Date: Thu, 13 Jun 2024 13:34:40 +0200 Message-ID: <20240613113227.178011038@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613113223.281378087@linuxfoundation.org> References: <20240613113223.281378087@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Daniel Thompson commit db2f9c7dc29114f531df4a425d0867d01e1f1e28 upstream. Currently, if the cursor position is not at the end of the command buffer and the user uses the Tab-complete functions, then the console does not leave the cursor in the correct position. For example consider the following buffer with the cursor positioned at the ^: md kdb_pro 10 ^ Pressing tab should result in: md kdb_prompt_str 10 ^ However this does not happen. Instead the cursor is placed at the end (after then 10) and further cursor movement redraws incorrectly. The same problem exists when we double-Tab but in a different part of the code. Fix this by sending a carriage return and then redisplaying the text to the left of the cursor. Cc: stable@vger.kernel.org Reviewed-by: Douglas Anderson Tested-by: Justin Stitt Link: https://lore.kernel.org/r/20240424-kgdb_read_refactor-v3-3-f236dbe9828d@linaro.org Signed-off-by: Daniel Thompson Signed-off-by: Greg Kroah-Hartman --- kernel/debug/kdb/kdb_io.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c @@ -383,6 +383,8 @@ poll_again: kdb_printf("\n"); kdb_printf(kdb_prompt_str); kdb_printf("%s", buffer); + if (cp != lastchar) + kdb_position_cursor(kdb_prompt_str, buffer, cp); } else if (tab != 2 && count > 0) { /* How many new characters do we want from tmpbuffer? */ len_tmp = strlen(p_tmp) - len; @@ -396,6 +398,9 @@ poll_again: kdb_printf("%s", cp); cp += len_tmp; lastchar += len_tmp; + if (cp != lastchar) + kdb_position_cursor(kdb_prompt_str, + buffer, cp); } } kdb_nextline = 1; /* reset output line number */