From nobody Sun Jun 7 17:11:44 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 4gYMCj1LRfz6gyqC for ; Sun, 07 Jun 2026 17:11: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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gYMCh4yT5z42Dd for ; Sun, 07 Jun 2026 17:11:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780852304; 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=mJ+TLFjkm7zIkYnwn1ojS1uCsRFLQTYC9isHmRpluYs=; b=AK61BQecsJQtKeIOrsKAmbIUUC8Ng00933fGQpF0fNyPF1BQeU5z6pCM/+lt22AwapkoWt fLDL7gcDMjUwxju/oF6OoUGZDx8SFx+phFbBNGjQ77Av0KahmdnqFi9Im6eMm3ZrINeN0L OHXTVpZfYBgoRbWaPkNrgz6I8FgmDjrcpYa0TIxYEVftV+D0CLaQJnZ0XARlS8XOuZIqBf fFbO2ophWUvb/Y+P8HQ0aTXUYrYXi99IPrWgfqH5KmtNNRWECOr1IS0zht9F64GVf7h3ze PSD8mSgX4sSLFNkiv0rLey7DtFPToG1mCLphX7kVIXKIc8ffWRkRB7G8eeAFdA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1780852304; a=rsa-sha256; cv=none; b=OlYmGl/UlYJRowk3C/v8hst8FUr/+fEz8Hglsikyz/nXkTr23/SJD1zIvv5Pn+rppmNVGV mopbsReiIZxHNvN5isUyV0n/oKNYHqazhPghKDTJ71w9e+KiBKZHwDRnpVjYXiFUJgx0wE eAbql9mapVdTVRl2iaCPlxouTq6A0vsev8PeQU4MgAB4HJ+ChQGerCjkgR1Em2/k9By+Nn fALqG6NEfy73JiNe2hIFkDrdVKvUS+59P6R7enDEZuWvCsZ03WoV5C5iNGlj0AD5eY6Af2 55fkXhYBZM7JRjqYgJJUBFbZaABzTr5Of7KiwvmWjcQTmwy88NwSU9k1EiWr+A== 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=1780852304; 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=mJ+TLFjkm7zIkYnwn1ojS1uCsRFLQTYC9isHmRpluYs=; b=CCKS+te9DLI9JhyIFsNDTb18F+xgtLc98iDlcH7AQcykpy8TLmCZ6kShghYry8gbGUBi3X Xu8p7g0JrSpHFCkkAg78+SOMBN7qAhmViWcOwIKBTTeRZUQw/qXRPwLLV6tFwz1hH1Se9D OQM1bWiTskTcVqdvOXumFib4m3tqEe4GIYGroM2DvbGXb2VaibqeGD44PYNK/3kDPIpM0G q4S2T2WBxSfxVgkzhyMokadzEMtNeEibwJMToxHujz3iAw1sNT2IoYEyhH8maYgZk/gEk8 kCyeej8vByq6pdROMUv1p+bQPJcH59c/N2eFfv6QTdaHW13dE3MnXi7eix1ggQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gYMCh4J1Fz18cB for ; Sun, 07 Jun 2026 17:11:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 27aa9 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 07 Jun 2026 17:11:44 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: deaaddf1d3c4 - stable/15 - 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/15 X-Git-Reftype: branch X-Git-Commit: deaaddf1d3c4283649945553ad7e3208c8424308 Auto-Submitted: auto-generated Date: Sun, 07 Jun 2026 17:11:44 +0000 Message-Id: <6a25a650.27aa9.68553b6@gitrepo.freebsd.org> The branch stable/15 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=deaaddf1d3c4283649945553ad7e3208c8424308 commit deaaddf1d3c4283649945553ad7e3208c8424308 Author: Ed Maste AuthorDate: 2026-05-26 16:19:47 +0000 Commit: Ed Maste CommitDate: 2026-06-07 17:10:53 +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) --- 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 e1e4ebc23491..43657fcecbdc 100644 --- a/sys/dev/vt/vt_buf.c +++ b/sys/dev/vt/vt_buf.c @@ -499,7 +499,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; @@ -510,10 +509,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 8360f0b80fb5..922b44028a23 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -2798,8 +2799,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);