From nobody Tue Jan 11 18:32:05 2022 X-Original-To: dev-commits-src-branches@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 493BA19453FB; Tue, 11 Jan 2022 18:32:06 +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 4JYK6Y3KZ3z4YlG; Tue, 11 Jan 2022 18:32:05 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 38D371E317; Tue, 11 Jan 2022 18:32:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20BIW5NY024083; Tue, 11 Jan 2022 18:32:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20BIW5ju024082; Tue, 11 Jan 2022 18:32:05 GMT (envelope-from git) Date: Tue, 11 Jan 2022 18:32:05 GMT Message-Id: <202201111832.20BIW5ju024082@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 9c9d0d90512f - releng/12.2 - vt: bound buffer access in redraw optimization List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.2 X-Git-Reftype: branch X-Git-Commit: 9c9d0d90512f0e5950b179d1a07f717ad7c8fe28 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641925925; 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=KTlVDpP1FLhy6yb2F25+mEDRR0DVA8HRmPobfiyEGWo=; b=mJM2DbUfxltLiEKx7PkVDUEo2MAxA9u2HDt6pgXW2ljjnK2q/7uupWmBERHhWo9tlLGS0W 9MlVwg52oFvdlJxL2waYGq3oJCWTFY7fDu+KLC/KAwWe0FHfBe4s/tkW8GtuM89bT3DQtL ShB5wgPkJhl8zwWr12vZY5z+Y1xErs9739ZJmyMmeCdfHM3x0BK+r7mxDYsvVwjpLeYhiy lneY04IxgDSGhJ/t2JeP3V9+pxwxytUYdJ0XYYTosP4rB8W+VTsM9zXw+VV+steEYlxNbu NOCCo0G6j2dQmvji5bDxSgf1+MUuFcv5hJSx6BK75ciOCsIO3oKozL1ZD1uO9Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641925925; a=rsa-sha256; cv=none; b=rPKcVN3fCPzQEJ6FK7PoixusxxDZ/LfS2gHUHH3+73iG2x1cNoI7qYCslQmkTCxKKLI34i CjX7+7PI8QCyMQOuk1C/DFK/HUldmhdVuY+74sDvoiOlVbbaveL5eNQQl/hjXXUMa6U/G/ WcZRDekhb3veAYvOpW5SZ1HbGqlO1gjgl+wjBsv5iAPQE5NHv+OGlL+8II6G8VsACzhq1I BJAUp8E9UWOCA9yFOhSziGEHxHSv5mBpwYxj/V1+W1OmEuJD63apvZ+oiOdojD+9bFJ60W mSasfiH/jXqtaRFGIsVbzeGmTUDDQeQ3w1jHai/cFCPZShrhXJrY1eFoX5jFpg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch releng/12.2 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=9c9d0d90512f0e5950b179d1a07f717ad7c8fe28 commit 9c9d0d90512f0e5950b179d1a07f717ad7c8fe28 Author: Ed Maste AuthorDate: 2021-09-22 18:41:00 +0000 Commit: Ed Maste CommitDate: 2022-01-10 18:04:06 +0000 vt: bound buffer access in redraw optimization PR: 248628 Reported by: oleg Reviewed by: cem, oleg (both earlier) Fixes: ee97b2336aa4 ("Speed up vt(4) by keeping...") MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32059 (cherry picked from commit dbc7ca59451561a179f9852642e13ef024169d84) (cherry picked from commit e4fcff8ee124f8faed2f1fcc1e15b7ae6906d4d7) Approved by: so Security: FreeBSD-SA-22:01.vt --- sys/dev/vt/hw/fb/vt_fb.c | 6 ++++++ sys/dev/vt/hw/vga/vt_vga.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/sys/dev/vt/hw/fb/vt_fb.c b/sys/dev/vt/hw/fb/vt_fb.c index 62a52dd9e017..5c14be1c15ba 100644 --- a/sys/dev/vt/hw/fb/vt_fb.c +++ b/sys/dev/vt/hw/fb/vt_fb.c @@ -354,6 +354,9 @@ vt_fb_bitblt_text(struct vt_device *vd, const struct vt_window *vw, VTBUF_ISCURSOR(&vw->vw_buf, row, col), &fg, &bg); z = row * PIXEL_WIDTH(VT_FB_MAX_WIDTH) + col; + if (z >= PIXEL_HEIGHT(VT_FB_MAX_HEIGHT) * + PIXEL_WIDTH(VT_FB_MAX_WIDTH)) + continue; if (vd->vd_drawn && (vd->vd_drawn[z] == c) && vd->vd_drawnfg && (vd->vd_drawnfg[z] == fg) && vd->vd_drawnbg && (vd->vd_drawnbg[z] == bg)) @@ -404,6 +407,9 @@ vt_fb_invalidate_text(struct vt_device *vd, const term_rect_t *area) for (col = area->tr_begin.tp_col; col < area->tr_end.tp_col; ++col) { z = row * PIXEL_WIDTH(VT_FB_MAX_WIDTH) + col; + if (z >= PIXEL_HEIGHT(VT_FB_MAX_HEIGHT) * + PIXEL_WIDTH(VT_FB_MAX_WIDTH)) + continue; if (vd->vd_drawn) vd->vd_drawn[z] = 0; if (vd->vd_drawnfg) diff --git a/sys/dev/vt/hw/vga/vt_vga.c b/sys/dev/vt/hw/vga/vt_vga.c index 88a9b1c47338..563867399e53 100644 --- a/sys/dev/vt/hw/vga/vt_vga.c +++ b/sys/dev/vt/hw/vga/vt_vga.c @@ -888,6 +888,9 @@ vga_bitblt_text_txtmode(struct vt_device *vd, const struct vt_window *vw, &fg, &bg); z = row * PIXEL_WIDTH(VT_FB_MAX_WIDTH) + col; + if (z >= PIXEL_HEIGHT(VT_FB_MAX_HEIGHT) * + PIXEL_WIDTH(VT_FB_MAX_WIDTH)) + continue; if (vd->vd_drawn && (vd->vd_drawn[z] == c) && vd->vd_drawnfg && (vd->vd_drawnfg[z] == fg) && vd->vd_drawnbg && (vd->vd_drawnbg[z] == bg)) @@ -941,6 +944,9 @@ vga_invalidate_text(struct vt_device *vd, const term_rect_t *area) col < area->tr_end.tp_col; ++col) { z = row * PIXEL_WIDTH(VT_FB_MAX_WIDTH) + col; + if (z >= PIXEL_HEIGHT(VT_FB_MAX_HEIGHT) * + PIXEL_WIDTH(VT_FB_MAX_WIDTH)) + continue; if (vd->vd_drawn) vd->vd_drawn[z] = 0; if (vd->vd_drawnfg)