From nobody Wed May 03 00:29:39 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 4Q9yWS0ZG2z48Nh5; Wed, 3 May 2023 00:29:40 +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 4Q9yWR74ZRz3mGn; Wed, 3 May 2023 00:29:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683073780; 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=78ERe93ui4A/H3aEZzZwgH7+//3A9NZn9mlfG8gdImo=; b=VO0FGSC4UU3phDplvBEBlODB8E6HaOaD6QugXYWqrZD6boxaPYQy2D9W4WNxpziGTm7foO BEJYK8GvTWxvCgs67JAVs+gBxi5M12NNc7+/Gt9xQOYwqhjclc2DG2Yk2wHi/LnG6S8jH7 zAuaHqcPwvbNWl2q3JivtJjTCgrcl3pgfbCbsweaEXuJTJrZWso3vtS2tNnjVGRHz6lLao hgaUxuva7qI/WXMeXm7xXsCcdh47XF/f4ZCnJelETtiTV0i/6S6m3NZdR+88LfivIF95YL 8ZOJRlbbJnmUKk8IPXWSGltnYb7cw7wwmyC0IrZBtL3CEW3VG94wJvwvoDzJeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683073780; 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=78ERe93ui4A/H3aEZzZwgH7+//3A9NZn9mlfG8gdImo=; b=g8rr+Li0oHVoak4i5/ZDo7bd0KYsXgD+XIFgBHkZqS9P+M5ioElPIA9Rm48J89lqbHTfW4 hrsQ7EtcVsgIZIGoyEqBqekz0/4EQPsKHuwydoLydLywI1aXiO9FpI+jQ0iRU1/Rk9ojFW yfAuK7HQQLwur3lIJcbtdCY47Fxjv85M9TD3FRqcRvYnwyMDpHoswgNI/vg8PD9aHR1X8l 77Bmy3xD74orOtWmBQxOU2UyqurGFewfH8i/3yOhyI8JnQB+UVysKwL1cha9ua09gnEYd3 4eAQeir5yIhXy+Nof1e7TbVQpxxIpnAv4YTkMXkbtnfRfUbtY3sA6yfQhvs9ng== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1683073780; a=rsa-sha256; cv=none; b=VDIC0RzLtaETVTbvXL1E1kR0dF+DQk03M8aVgjcuC6QOJZxNXU/iOgW+kW7rrUoI4+D3Vc LYG4cflhTbDJSIOZSK3JVRPzAq95zzzM5nVN761x+Ivo87QXOnRzy37TYaT/gddqAl0JC8 e6/BSLdGOj1IvaQ4I2LH/FqJjvUoR/NElZbVYQlQ5gcibhtsEiCgQJ90kibuBPBzMiuQLM ysFhKkyOoDcY5L7a2fgNbShmS2ws3ZAkf5wrV13wtTX651RFk0fYQ36P4p7YHzDkCS/2mY Lvzx+tttaHyLSMbPY5ob4cg+2hfLLIC9teRkJHUbY0qapPZIWj8f2MtbFtR7NQ== 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 4Q9yWR67bCz18Fh; Wed, 3 May 2023 00:29:39 +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 3430TdE4072004; Wed, 3 May 2023 00:29:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 3430TdhM072003; Wed, 3 May 2023 00:29:39 GMT (envelope-from git) Date: Wed, 3 May 2023 00:29:39 GMT Message-Id: <202305030029.3430TdhM072003@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 2c63333240f2 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 2c63333240f259ec57d748e9b4b3520b35b15f24 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=2c63333240f259ec57d748e9b4b3520b35b15f24 commit 2c63333240f259ec57d748e9b4b3520b35b15f24 Author: John Baldwin AuthorDate: 2023-03-22 19:34:34 +0000 Commit: John Baldwin CommitDate: 2023-05-03 00:06:52 +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 (cherry picked from commit 61482760a0ca198a9310d450133e9ac792b67955) --- 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 2c5324dffdaa..95e713f9df4e 100644 --- a/usr.sbin/bhyve/qemu_fwcfg.c +++ b/usr.sbin/bhyve/qemu_fwcfg.c @@ -296,9 +296,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);