From nobody Mon Nov 13 18:04:45 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4STclK5qRBz4wWNH; Mon, 13 Nov 2023 18:04:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4STclK5JMGz4VCR; Mon, 13 Nov 2023 18:04:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699898685; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=80oliCS3sivn+RudEYtH+nEI551ja4wTFg7Erl4s64A=; b=Uebelp3j22zXlf9KcroSyFTdBpPyxrUNo23zyhdgPjhgPkd6JPc4i9CmnvtNZLJyzu4VEm Z1oKJcFQnDF4ExEy/Yv8oiRwdzdsPrjQTWqR7tpmquUusprYtlyH2UQptItcz7AlloY9Sy ox7bgnh0acZuVJMNO28B3mILSLIHSb4lH7u/+PCsIXzVxQ9DagkuTuHxB1J7tA0ICN3NhM lKROIGI7157RBrVXvfDygMXhgySf101Q39hWRWmwgW0eP//LcODPkas5jhp0XyqcT+Gruz EN+GPO1ZfdgYGr5nAAoouLF/6n5ekhgcZ1ouanDvnCPSCFZxhofbzCsTaG65lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699898685; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=80oliCS3sivn+RudEYtH+nEI551ja4wTFg7Erl4s64A=; b=YOkADG0jKteccDzelten3mnSZOMInGw68qhgWcQl4EOqRp5hgHIvGuHXPvkFokAlR7L0/U jUr2nGyMKAc0IQKcng7z9Hy6ZO8QI07Iun7FPPlLIlHtsfd/uKfeGHImzy+QMswyqUOslb p+VzLfQNVTwzC+AwkOzyxdGGOUTsWzbtVbb10cxa2/zu4fAdDEvfd6VoCop21OwJvMEQLl FnfatqPMsinFbU8cqlpBvXDmZL/Uq/NteELfKxHSRdWfOU5j+0IiBtht3XlxpOFuyXOt/q bzk3PvjBO5R6NG9dtMZOPDvsBFzvmLdtPqyrieVQRSLNe4bjla3mVjmGE+8Vqg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699898685; a=rsa-sha256; cv=none; b=XY+ZGaalOAOfxm4CjdJ1oajtLJb26us0+zNnfdw6hCiJ7U1f9yz37SjtxPUpH2qvgz7Q7R UWu4a0RYNNPBUQZXDs3U6kHfzAWgs6P48PwOLb5N//v8zog+wA2+pQe7vFOX/9WeRN1iOO UblwlNR9eOZ2lTWBo6rLE7H2FPIFY3M6REhSiVt9I1jtMo0PNPHVMdrju1wGGS0lOcz4HQ H28dI+z0TwrO9AT5KolrJ9DHJNfNQ7GmKSsm3CmzVUn8/gNCvvWMCts65oUEhThdS52gad KDH80D0JVrWXAuRk5++satkMiK7mj1z1F692ogvmmQCrjS/hw5LbQUN2j5jHsg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4STclK4FPyz11F; Mon, 13 Nov 2023 18:04:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3ADI4j11028387; Mon, 13 Nov 2023 18:04:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3ADI4j4b028384; Mon, 13 Nov 2023 18:04:45 GMT (envelope-from git) Date: Mon, 13 Nov 2023 18:04:45 GMT Message-Id: <202311131804.3ADI4j4b028384@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Christos Margiolis Subject: git: c6d7be214811 - main - tty: properly check character position when handling IUTF8 backspaces List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: christos X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c6d7be214811c315d234d64c6cbaa92d4f55d2c1 Auto-Submitted: auto-generated The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=c6d7be214811c315d234d64c6cbaa92d4f55d2c1 commit c6d7be214811c315d234d64c6cbaa92d4f55d2c1 Author: Bojan Novković AuthorDate: 2023-11-13 18:02:30 +0000 Commit: Christos Margiolis CommitDate: 2023-11-13 18:04:11 +0000 tty: properly check character position when handling IUTF8 backspaces The tty_rubchar() code handling backspaces for UTF-8 characters didn't properly check whether the beginning of the current line was reached. This resulted in a kernel panic in ttyinq_unputchar() when prodded with certain malformed UTF-8 sequences. Fixes: PR 275009 Reviewed by: christos MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D42564 --- sys/kern/tty_ttydisc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/kern/tty_ttydisc.c b/sys/kern/tty_ttydisc.c index c46579cefbb1..cb5bf672d040 100644 --- a/sys/kern/tty_ttydisc.c +++ b/sys/kern/tty_ttydisc.c @@ -822,7 +822,13 @@ ttydisc_rubchar(struct tty *tp) /* Loop back through inq until we hit the * leading byte. */ while (CTL_UTF8_CONT(c) && nb < UTF8_STACKBUF) { - ttyinq_peekchar(&tp->t_inq, &c, "e); + /* + * Check if we've reached the beginning + * of the line. + */ + if (ttyinq_peekchar(&tp->t_inq, &c, + "e) != 0) + break; ttyinq_unputchar(&tp->t_inq); bytes[curidx] = c; curidx--;