From nobody Fri Dec 29 20:39:01 2023 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 4T1y060rlrz55B3d; Fri, 29 Dec 2023 20:39:02 +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 4T1y060JG6z3W1T; Fri, 29 Dec 2023 20:39:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703882342; 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=V1gwxiUoDdvNnlyCT39KHjty/6mKBlSHh4FjIMCcAtk=; b=uz7VdJnflAUQpzxFNNY+LqRyOJ8UB2jaO7omy87RGGEJiHAtxU3HT1yLOo0rCXlXvXlp+v LYis896S7/FI3CEuvWOyuBVgB1yvlvXaHvd33hwuILjx1RDHwiLXMpkSohPlzIdDeeDLEY PU4MbnEhRX6jOO6R1Lxl38N2Pfcv1g/YxlEHIjfOg6MSHyxKv3o5o67UVfMY0ucOpTLHJ1 jvAXCaHDuxeeCureJtvRKhtmQuYkLq00TqdOSO/Dd2Qd0k0Dcc5ExqOoiwMT4PaA1ty7QZ iJeWUR+OfhvLa53YKdJG8GL2PbMoBKKBL2XTU5/P+dqKPdMNe/dPDM35yKtlTQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703882342; a=rsa-sha256; cv=none; b=SVj65R1G5FrVj2QvkrbnMRFv3NNwevgOvTu6I84EzrJUCfRUxnxUatcq4JsATI7uO7OWVB QHPsuQQs+Cu3iZjVZ0Avev0G7S8jkHWUZbucy/72b+JozNz4z8Qf3tSJtn5oAhQurB4PDF jz+oK8HpPdHOh+D4Q1/Fltqxnbm2/lAJJ29kbtWBNIScGL5VYDJS7l9ORc63gAGD+N/dYO GzUmQulQIFd4dqp91ztyNkAsTX/xZNA82f2GnBrY35sKkhmlczFQqweKJA9Yhbb6OXeWTm Yp8LxAghB6OOWDdyqudcqqRuMrYHtV4kuYdZS+l2o71RMm4qYQKVWmSt4POSiw== 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=1703882342; 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=V1gwxiUoDdvNnlyCT39KHjty/6mKBlSHh4FjIMCcAtk=; b=A+GK+t2xMz3nPTc/k+hM4WLyIgnhJNvaS8nJxXOd1SfiGiWYRqNp7I63l9AgsKmEPTCK8C 7BWJn9P8q1sW4ROAfzk4SLfBdbwpXf8syAXNbKwQ0XtGroX0qhLJhgZl6F2J6SnqlDPU3D QpswmkWGR0xAkkZC8TSiO2+NDlRx25gUrWejro4oQoPQ4Mw0ss/9gYZhiom5jUIHQupH3/ WCQMnzDApfZrj73VRxQQqfVsnMRTXiqhyR/HDLcKs6rKla/bXnxk6To3/5A7Li1kx30e9i Jxaxf+bPc85uqmpe4lTEZ8ld6Ju8O4fT/h2q5VPUzEWyPfxtzCK8zjDFyPM3wQ== 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 4T1y056MK5z64C; Fri, 29 Dec 2023 20:39:01 +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 3BTKd1DC023127; Fri, 29 Dec 2023 20:39:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BTKd1BR023124; Fri, 29 Dec 2023 20:39:01 GMT (envelope-from git) Date: Fri, 29 Dec 2023 20:39:01 GMT Message-Id: <202312292039.3BTKd1BR023124@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Robert Wing Subject: git: 0600b575402f - main - bhyve: verify that user provided fbuf values fall within limits 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0600b575402feb180ba9aed52ebad1c4c08ead71 Auto-Submitted: auto-generated The branch main has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=0600b575402feb180ba9aed52ebad1c4c08ead71 commit 0600b575402feb180ba9aed52ebad1c4c08ead71 Author: Robert Wing AuthorDate: 2023-12-29 19:18:15 +0000 Commit: Robert Wing CommitDate: 2023-12-29 20:37:57 +0000 bhyve: verify that user provided fbuf values fall within limits The upper limits for height/width are already checked, this commit enforces the lower limit as well. The behavior is also changed such that, the framebuffer fails to initialize if the provided values don't parse cleanly. Reviewed by: corvink, jhb Differential Revision: https://reviews.freebsd.org/D42692 --- usr.sbin/bhyve/bhyve.8 | 4 ++-- usr.sbin/bhyve/pci_fbuf.c | 33 +++++++++++++++------------------ 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/usr.sbin/bhyve/bhyve.8 b/usr.sbin/bhyve/bhyve.8 index 3612251d7f7b..12e3f3ba926e 100644 --- a/usr.sbin/bhyve/bhyve.8 +++ b/usr.sbin/bhyve/bhyve.8 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd November 20, 2023 +.Dd December 29, 2023 .Dt BHYVE 8 .Os .Sh NAME @@ -778,7 +778,7 @@ optional zone identifier. A display resolution, width and height, respectively. If not specified, a default resolution of 1024x768 pixels will be used. Minimal supported resolution is 640x480 pixels, -and maximum is 1920x1200 pixels. +and maximum is 3840x2160 pixels. .It Cm vga= Ns Ar vgaconf Possible values for this option are .Cm io diff --git a/usr.sbin/bhyve/pci_fbuf.c b/usr.sbin/bhyve/pci_fbuf.c index 247b7cb69c9a..798e9b41f0b0 100644 --- a/usr.sbin/bhyve/pci_fbuf.c +++ b/usr.sbin/bhyve/pci_fbuf.c @@ -312,26 +312,23 @@ pci_fbuf_parse_config(struct pci_fbuf_softc *sc, nvlist_t *nvl) } value = get_config_value_node(nvl, "w"); - if (value != NULL) { - sc->memregs.width = atoi(value); - if (sc->memregs.width > COLS_MAX) { - EPRINTLN("fbuf: width %d too large", sc->memregs.width); - return (-1); - } - if (sc->memregs.width == 0) - sc->memregs.width = 1920; - } + if (value != NULL) + sc->memregs.width = strtol(value, NULL, 10); value = get_config_value_node(nvl, "h"); - if (value != NULL) { - sc->memregs.height = atoi(value); - if (sc->memregs.height > ROWS_MAX) { - EPRINTLN("fbuf: height %d too large", - sc->memregs.height); - return (-1); - } - if (sc->memregs.height == 0) - sc->memregs.height = 1080; + if (value != NULL) + sc->memregs.height = strtol(value, NULL, 10); + + if (sc->memregs.width > COLS_MAX || + sc->memregs.height > ROWS_MAX) { + EPRINTLN("fbuf: max resolution is %ux%u", COLS_MAX, ROWS_MAX); + return (-1); + } + if (sc->memregs.width < COLS_MIN || + sc->memregs.height < ROWS_MIN) { + EPRINTLN("fbuf: minimum resolution is %ux%u", + COLS_MIN, ROWS_MIN); + return (-1); } value = get_config_value_node(nvl, "password");