From nobody Wed Mar 22 19:35:47 2023 X-Original-To: dev-commits-src-all@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 4PhdxJ03K0z41Cf1; Wed, 22 Mar 2023 19:35:48 +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 4PhdxH6Gx5z4DPm; Wed, 22 Mar 2023 19:35:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679513747; 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=Sv/CekILKvFxrcdfbegckKu/48k5tF9Eu6QstQez27k=; b=ayEMb9QojPSVaZM21ZWrHLLafHjUOzmH/qLLvg4eN5gqVdmnSZwM+o+cTgekJH82Uh46lx AZjDBsqGacbsOOD9TmrQTLSMiJligd1QqsDcmfnfjYOw9F96n5eXfU9dw48nsghofIx8dr tghvY2n7O810L0NcZPYKj0K4M8sOhbPV9giN/G7I5YnakxBrhUuSMlowWZ0FTys1hC9K65 u5BdzZsY38RRyNkn2UHLViIlP19ME4dIjF9se8iFcEP4yNRvPwxwHc95dZoA3QRHhf15nj d3URv81PoV1stZ8v01f9Ct9cSmgZfBTmpZfXZb0hGmOCERhEBvut82bWJdb2Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679513747; 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=Sv/CekILKvFxrcdfbegckKu/48k5tF9Eu6QstQez27k=; b=mDB254v0yP2e64a/aYPhkWDsIs2YWEOmX1ZRmm8XhoIQ/2oWdXqAjG8Tr0K/VdaNJ3MkMK VUORpxU2dY611B7CMMqMBI6aPioHfUxnwIxtx0nU4H6eQP7IMocg37PsPNsAw8XOM5sTEg jCQtzOFULc4+LiYUqWS9uFuxIWntF+jUBCp2RITasShRmA8Qte36DNDT9HTWtheO0AzDnt cww9Nycy3JzlImJgWX2kVl4t7fRudd38k14yudR9vfY266dfxat+WMQH37MOAnfBy1I9IA vJfA4Os2q+2S1DhA6JqT5dRI/VHxqLgwUH//MWvhKQKhcXfjQ7puEaPovqdvfQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1679513747; a=rsa-sha256; cv=none; b=ArNf3TuonPnTlBS7SU5N665lm9Z86XmzpxVJWpXDLh3bxAkqPFYMq3i5MvOUDj3CgNVu5a iwQpwk3VgUoxnuYk+hoIJ3Apk0RsOBwwTwg2m6yXAVFlZJ/yxW0AnsqAU6ZmIkAa+IQmXG 5tjWgSZrLtiYgwL/UZD/qoWCJG6Nfa5oaCmkXFW+In5X8TSyHWNmeLhBVGZfB32gtB8sNE ftxrKnGlfo2w/t3Ndwj9c1geHUKtjR9E8b2tQzHZ22TuJ0A8l9jdGshtFcrZMsjtz+LK4z fyUDG7OBKz2i6Vor3pueAih613SXNZ6XnMQRqrvjjlK+iO2/MDqi0Q9j0c8Uqw== 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 4PhdxH59pVz15y4; Wed, 22 Mar 2023 19:35:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 32MJZliT019773; Wed, 22 Mar 2023 19:35:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32MJZlHM019772; Wed, 22 Mar 2023 19:35:47 GMT (envelope-from git) Date: Wed, 22 Mar 2023 19:35:47 GMT Message-Id: <202303221935.32MJZlHM019772@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 61482760a0ca - main - bhyve: Accept a variable-length string name for qemu_fwcfg_add_file. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 61482760a0ca198a9310d450133e9ac792b67955 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=61482760a0ca198a9310d450133e9ac792b67955 commit 61482760a0ca198a9310d450133e9ac792b67955 Author: John Baldwin AuthorDate: 2023-03-22 19:34:34 +0000 Commit: John Baldwin CommitDate: 2023-03-22 19:34:34 +0000 bhyve: Accept a variable-length string name for qemu_fwcfg_add_file. It is illegal (UB?) to pass a shorter array to a function argument that takes a fixed-length array. Do a runtime check for names that are too long via strlen() instead. Reviewed by: markj Reported by: GCC -Wstringop-overread Differential Revision: https://reviews.freebsd.org/D39211 --- usr.sbin/bhyve/qemu_fwcfg.c | 6 ++++-- usr.sbin/bhyve/qemu_fwcfg.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/usr.sbin/bhyve/qemu_fwcfg.c b/usr.sbin/bhyve/qemu_fwcfg.c index 1b0b5e3e9931..2d91213dc7c5 100644 --- a/usr.sbin/bhyve/qemu_fwcfg.c +++ b/usr.sbin/bhyve/qemu_fwcfg.c @@ -261,9 +261,11 @@ qemu_fwcfg_register_port(const char *const name, const int port, const int size, } int -qemu_fwcfg_add_file(const uint8_t name[QEMU_FWCFG_MAX_NAME], - const uint32_t size, void *const data) +qemu_fwcfg_add_file(const char *name, const uint32_t size, void *const data) { + if (strlen(name) >= QEMU_FWCFG_MAX_NAME) + return (EINVAL); + /* * QEMU specifies count as big endian. * Convert it to host endian to work with it. diff --git a/usr.sbin/bhyve/qemu_fwcfg.h b/usr.sbin/bhyve/qemu_fwcfg.h index f59087250816..f3846d64085a 100644 --- a/usr.sbin/bhyve/qemu_fwcfg.h +++ b/usr.sbin/bhyve/qemu_fwcfg.h @@ -18,6 +18,6 @@ struct qemu_fwcfg_item { uint8_t *data; }; -int qemu_fwcfg_add_file(const uint8_t name[QEMU_FWCFG_MAX_NAME], +int qemu_fwcfg_add_file(const char *name, const uint32_t size, void *const data); int qemu_fwcfg_init(struct vmctx *const ctx);