From nobody Fri Jun 5 17:56:26 2026 X-Original-To: dev-commits-src-main@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 4gX8JC0ST7z6gFLd for ; Fri, 05 Jun 2026 17:56:27 +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 4gX8JB71hGz4Gcs for ; Fri, 05 Jun 2026 17:56:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780682187; 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=Y/pP2dEMQQtwC8FiOlgptklTZ1UrINYTGFzkh3fr2Do=; b=BMNuWL1gsXaMt3mgnUH1No6ftGA23V3Vk8x1D2JshI7FNlDwcoOeQlC+h3/PJYT2nM07Ka iXCtcWjFq20wKP32WBOkW3riWeBOog3MImxAg24LN4hBwg45b8g/sAvLrLq8Fs484+A+RR DTd/yiNBWUIvLbUWpP/AWGRrSlabJHrCLnVOMYsfTA7KX9v9oUDDVX1Vjsj+3dSy8/QbyM wsDlYv/AuO265AAz2Xj7OzKkm0baZGaWYEVNqpOf8Ovt7pVmlhrZ9Z6/WwlOfL3gDxN6jd cAVSjH0tsPjv18UX87Hetz621cfp9oat2Qt5oH8V6RCYqRffJrW+5gHZmnfABg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1780682187; a=rsa-sha256; cv=none; b=HMvnLamXU/Cb1W36EerrvSw0nMEI9fg09G//KkEPIO1ZrfAIyvHsQBiAgAo2FI4m4S+yBp MXWEIfuSYRWIQOA4HV8VMHz3WmAHSop9r/MMfuZK/eSRMSVm7XIhJCABdhQEg7Y8jFRGPF SG2glHLcbSvs87TTIxIhb4k5nByWyp0kJHtLBb7HlP6hGjlRtURyk5GL4kHktYxB9ms4OQ k7DIK/BP/Ylu6hPRAUbF7aMJvtDG+2D+h5jVnspoHxAiWpBbJL+pLC0mKi7L6IzT7eR9DE CYZkdq8kaX5xC0z7vGwI00NIGSpky1j1eHzMMKoiLP5m2tOyLl0ncmKkdjni6Q== 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=1780682187; 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=Y/pP2dEMQQtwC8FiOlgptklTZ1UrINYTGFzkh3fr2Do=; b=PyC6b7aaI7C7uusGKf7hCwVH2m9pCi2nGKu6W/+W0IbannwKxyXRcdoZdA96I+yBuhPUVB 3T9i6PWQEcDTzJ5kUcynhZKm/PycqjSWjwISCSALMQ3nJfvuEu/5O3ssY6MDyJ9elQtklJ rIYDn7tQBzrCKtxva2zGTu+KRZdMDxaGCy2AHdMmGwgWsBa8/V+xYQ4SDq8bXwOV1Lb1PL eTgAO5B1UzZBWUghTpNtPlW3sKyyxzAypACDAp4Daq/R3gAVJBNaIx+cb8Bm7iwTSpAIXc nWsD9olovPrw1eMCMCQpwHjO4LtoV4WDbVQdAr1XCUDZIodw2DHgDK73FGD7xw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gX8JB6J81zgPl for ; Fri, 05 Jun 2026 17:56:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 207c0 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 05 Jun 2026 17:56:26 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 0ae946e7223d - main - vt: Avoid integer overflow in CONS_HISTORY ioctl List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 0ae946e7223df5ef3f7980af1d774d7f593f6421 Auto-Submitted: auto-generated Date: Fri, 05 Jun 2026 17:56:26 +0000 Message-Id: <6a230dca.207c0.6b29a30f@gitrepo.freebsd.org> The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=0ae946e7223df5ef3f7980af1d774d7f593f6421 commit 0ae946e7223df5ef3f7980af1d774d7f593f6421 Author: Ed Maste AuthorDate: 2026-05-26 16:19:47 +0000 Commit: Ed Maste CommitDate: 2026-06-05 17:56:12 +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 --- 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 8596342c139a..9b65a7cb889c 100644 --- a/sys/dev/vt/vt_buf.c +++ b/sys/dev/vt/vt_buf.c @@ -529,7 +529,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; @@ -540,10 +539,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 db54cb426844..81487d27a6fc 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 @@ -2802,8 +2803,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);