From nobody Sun Jun 07 17:13:17 2026 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 4gYMFV0HqJz6gyMb for ; Sun, 07 Jun 2026 17:13:18 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gYMFT5jcnz434r for ; Sun, 07 Jun 2026 17:13:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780852397; 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=AbwCLNPzg9c8LM/LAyG9apHYAD/CSDC8O/Dzz/QtvBg=; b=Aekh+v6GJxumWz0fYKFqWkRMvQ75j7IRiQc/Kqc9imNck4ZVHpKFwzetxq1LMPikHM1y7f nLUcuAqUE5l7k0yO+ERCEL9R7mNmc/UKE5ryFM3jWjDEWxiTTcAY73JhSePIWiW2dra1bg DphniMkkcXWkhnV7kfcZ98ix0VsS5dgF3JLiXsMQUZ0FYVHtroVWPVY8yrSIVjSF35Ciu2 M121uzu993wtjNmiwzINOes+2AuU2Zgp5X/BQavaEtqMjrz2DmLQgZhMMo49CodTLNhiDg Bn255z2YvmUYKHuDZQMtklZTzf/mQ+ik4Dvs7Bbw/PHQR0THqPhBVgfRoPqjDQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1780852397; a=rsa-sha256; cv=none; b=HItScbRJIwhqw2JPM3JWEZemOjMMhOPN6h2tlb1p8rd5NeUk0pKIopgo7Yjs4FDRLln1/Q VLicuC6ieyjsUOD5yaItDNCzVnxNquoUUIiNMeHQe4fNrX0lKNT5T8oUeLJnFiRynWsarM oYok7wtE+NGiZznD53ISA9uQ8xAErZza3NCyYYUYcHbBlI3HKGfpN3jDHHz/wMShYW5g4x eZ3WFWPXhNyPj3p4yMaxKDgiL3OHZ0KHrsXGchULP3pv3FXFb6hvUqujKTS0APfhinDVJN SDlyDYefcr4Y2az0J7zTiu9MDFvMYAFinzSb/JL0IzMuAJ0AzdrX5J6ZwVsc4g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780852397; 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=AbwCLNPzg9c8LM/LAyG9apHYAD/CSDC8O/Dzz/QtvBg=; b=rqR54rRJFG0eDFux6D5V6b2Uien6CtsdNA4puCrFuweyEuDK1mI/CulwS3VXDS5ivhTcLL I9YxsRbHDAg8vW2TQYxZIrKDhXPdYXMuXraFr5Ab/IzXVMfaRKvq3jk4x4x6BH2jj49hM0 qmeoSIYLJ4g2qX/3j9ntr36gBhi7XT+HLbDtrKwIWBO9YDBA6vk+8Bus6yimK8SrfiysMZ uIHitb6eUKPFQ5ayQJYk4Za1yxeg3KWTx8PZz1aeo4CT9t+mIudwUGaDhC5gMmCHVtgQw2 DBHOtQImAK4QipMk3xeSy0xe1AS6A68lXMhMLuTkd6hMdqui6Nv6Sc+nzSpWXA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gYMFT5Hscz19cW for ; Sun, 07 Jun 2026 17:13:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 27c08 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 07 Jun 2026 17:13:17 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: b1ad74074d4d - stable/13 - vt: Avoid integer overflow in CONS_HISTORY ioctl 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: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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/stable/13 X-Git-Reftype: branch X-Git-Commit: b1ad74074d4d5139106680ac766348f5d8b6873a Auto-Submitted: auto-generated Date: Sun, 07 Jun 2026 17:13:17 +0000 Message-Id: <6a25a6ad.27c08.20d04c92@gitrepo.freebsd.org> The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=b1ad74074d4d5139106680ac766348f5d8b6873a commit b1ad74074d4d5139106680ac766348f5d8b6873a Author: Ed Maste AuthorDate: 2026-05-26 16:19:47 +0000 Commit: Ed Maste CommitDate: 2026-06-07 17:13:07 +0000 vt: Avoid integer overflow in CONS_HISTORY ioctl Reviewed by: markj, vexeduxr Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D57250 (cherry picked from commit 0ae946e7223df5ef3f7980af1d774d7f593f6421) (cherry picked from commit deaaddf1d3c4283649945553ad7e3208c8424308) (cherry picked from commit b5a4f4bfbc95d5d5361da708728f7f4a6db2ee60) --- sys/dev/vt/vt_buf.c | 9 ++++----- sys/dev/vt/vt_core.c | 6 ++++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/sys/dev/vt/vt_buf.c b/sys/dev/vt/vt_buf.c index ea27ea8a5ebf..0fd301bb662a 100644 --- a/sys/dev/vt/vt_buf.c +++ b/sys/dev/vt/vt_buf.c @@ -500,7 +500,6 @@ vtbuf_grow(struct vt_buf *vb, const term_pos_t *p, unsigned int history_size) { term_char_t *old, *new, **rows, **oldrows, **copyrows, *row, *oldrow; unsigned int w, h, c, r, old_history_size; - size_t bufsize, rowssize; int history_full; const teken_attr_t *a; term_char_t ch; @@ -511,10 +510,10 @@ vtbuf_grow(struct vt_buf *vb, const term_pos_t *p, unsigned int history_size) history_size = MAX(history_size, p->tp_row); /* Allocate new buffer. */ - bufsize = history_size * p->tp_col * sizeof(term_char_t); - new = malloc(bufsize, M_VTBUF, M_WAITOK | M_ZERO); - rowssize = history_size * sizeof(term_pos_t *); - rows = malloc(rowssize, M_VTBUF, M_WAITOK | M_ZERO); + new = mallocarray(history_size, p->tp_col * sizeof(term_char_t), + M_VTBUF, M_WAITOK | M_ZERO); + rows = mallocarray(history_size, sizeof(term_pos_t *), M_VTBUF, + M_WAITOK | M_ZERO); /* Toggle it. */ VTBUF_LOCK(vb); diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index 80d9ae1f22c2..c290e34648f4 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -2558,8 +2559,9 @@ skip_thunk: /* XXX */ return (0); case CONS_HISTORY: - if (*(int *)data < 0) - return EINVAL; + if (*(int *)data < 0 || + *(int *)data > UINT_MAX / USHRT_MAX / sizeof(term_char_t)) + return (EINVAL); if (*(int *)data != vw->vw_buf.vb_history_size) vtbuf_sethistory_size(&vw->vw_buf, *(int *)data); return (0);