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
This commit is contained in:
Robert Wing 2023-12-29 10:18:15 -09:00
parent 19bb1886be
commit 0600b57540
2 changed files with 17 additions and 20 deletions

View file

@ -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

View file

@ -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");