From nobody Mon Oct 21 04:30:15 2024
X-Original-To: virtualization@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 4XX2RF1C03z5bB4g
	for <virtualization@mlmmj.nyi.freebsd.org>; Mon, 21 Oct 2024 04:30:17 +0000 (UTC)
	(envelope-from bugzilla-noreply@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 "R11" (verified OK))
	by mx1.freebsd.org (Postfix) with ESMTPS id 4XX2RD4Kxkz4JVm
	for <virtualization@FreeBSD.org>; Mon, 21 Oct 2024 04:30:16 +0000 (UTC)
	(envelope-from bugzilla-noreply@freebsd.org)
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org;
	s=dkim; t=1729485016;
	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=lBz6wcJJIpk5MCHXiLZG8aJp7VopTl2D0XMceh+j0bk=;
	b=ASNGw7cAcLnIQajYd1Emagb0sgTvOF0+rUGjOKAWu1kARmsqZ1Dfrvn6TooxjpYJ+yAAu/
	GPJoqFJjRUa7HUfzkfG7rT+jbpHb9ipniuGukIy/1IZHGKKH5Fa1Y6teCrFFbDBoeKPGtw
	4+hoGg6y83VBSxGYgzOS2Vh6Ao4TgFL5A6R2HSE+og8rna35L+CzWXYa4mOBb7ldlC539H
	eQ3HtT/UeF1sIu0cxx6lqFcUWu3RDKq/++hZFLPRgmTT376kMYcgfaUFbl/ZAA52TZUWAL
	zENoa3LKO4G24zNqwjr+Ld+YKqgm4w9qkBKrQ4d6KJv0az+k9AnMLm64/+i9Dg==
ARC-Authentication-Results: i=1;
	mx1.freebsd.org;
	none
ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729485016; a=rsa-sha256; cv=none;
	b=UNOlcP9ZufVP1kb++zC4wtUYUAwW4rSw3M8aUyL/Q5+5zYaaddtzgGksg1ZrmKnw73NAzg
	RAij09IqJM/hloZ1KqDW4o3nAUs0T3H/4ITZoNNe26FBw1IGD8CoQDOYLOS2N+1gaTZBBt
	TExY73sCrY7P9MgFoeyRvERno0LuQkOeyTDi9TJZbVacJVqUMIwO7kCCN2SSCtNTCljjhx
	DZ8vHbzonstQ8yedZLb/icSidJTLq+WSUrqE/5JOYdReSjcMupHl9Lrk1ClNIu5gOXcWYC
	mqZKL6ToNDEpHXP+/jUUZ3jtAqao1G1MRwj+CTqQtozk92BEJJ/27wfHWYolSQ==
Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d])
	(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 4XX2RD3dm5zFxf
	for <virtualization@FreeBSD.org>; Mon, 21 Oct 2024 04:30:16 +0000 (UTC)
	(envelope-from bugzilla-noreply@freebsd.org)
Received: from kenobi.freebsd.org ([127.0.1.5])
	by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 49L4UGeS068427
	for <virtualization@FreeBSD.org>; Mon, 21 Oct 2024 04:30:16 GMT
	(envelope-from bugzilla-noreply@freebsd.org)
Received: (from www@localhost)
	by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 49L4UGRh068426
	for virtualization@FreeBSD.org; Mon, 21 Oct 2024 04:30:16 GMT
	(envelope-from bugzilla-noreply@freebsd.org)
X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f
From: bugzilla-noreply@freebsd.org
To: virtualization@FreeBSD.org
Subject: [Bug 282237] bhyve: usb_mouse.c segfaults due to incomplete NULL
 checking
Date: Mon, 21 Oct 2024 04:30:15 +0000
X-Bugzilla-Reason: AssignedTo
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: Base System
X-Bugzilla-Component: bhyve
X-Bugzilla-Version: CURRENT
X-Bugzilla-Keywords: 
X-Bugzilla-Severity: Affects Only Me
X-Bugzilla-Who: jackdbendtsen@gmail.com
X-Bugzilla-Status: New
X-Bugzilla-Resolution: 
X-Bugzilla-Priority: ---
X-Bugzilla-Assigned-To: virtualization@FreeBSD.org
X-Bugzilla-Flags: 
X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform
 op_sys bug_status bug_severity priority component assigned_to reporter
Message-ID: <bug-282237-27103@https.bugs.freebsd.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/
Auto-Submitted: auto-generated
List-Id: Discussion <freebsd-virtualization.freebsd.org>
List-Archive: https://lists.freebsd.org/archives/freebsd-virtualization
List-Help: <mailto:virtualization+help@freebsd.org>
List-Post: <mailto:virtualization@freebsd.org>
List-Subscribe: <mailto:virtualization+subscribe@freebsd.org>
List-Unsubscribe: <mailto:virtualization+unsubscribe@freebsd.org>
X-BeenThere: freebsd-virtualization@freebsd.org
Sender: owner-freebsd-virtualization@FreeBSD.org
MIME-Version: 1.0

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D282237

            Bug ID: 282237
           Summary: bhyve: usb_mouse.c segfaults due to incomplete NULL
                    checking
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bhyve
          Assignee: virtualization@FreeBSD.org
          Reporter: jackdbendtsen@gmail.com

Some of the cases inside umouse_request() (usr.sbin/bhyve/usb_mouse.c) use =
the
data component of an event, while only partially checking if it's NULL.

For example:
```
        case UREQ(UR_GET_STATUS, UT_READ_INTERFACE):
        case UREQ(UR_GET_STATUS, UT_READ_ENDPOINT):
                DPRINTF(("umouse: (UR_GET_STATUS, UT_READ_INTERFACE)"));
                if (data !=3D NULL && len > 1) {
                        USETW(udata, 0);
                        data->blen =3D len - 2;
                        data->bdone +=3D 2;
                }
                eshort =3D data->blen > 0;
                break;
```
As you can see, 'data' has a NULL check, but then 'data' is immediately
deferenced anyway after the check regardless of if it's NULL or not.

There are actually four occurrences of this same bug, each in a different c=
ase
in this switch block.

Here's a patch that can be applied to CURRENT that fixes the issue:
```
533c533
<               eshort =3D data->blen > 0;
---
> 		eshort =3D data !=3D NULL && data->blen > 0;
544c544
<               eshort =3D data->blen > 0;
---
> 		eshort =3D data !=3D NULL && data->blen > 0;
629c629
<               eshort =3D data->blen > 0;
---
> 		eshort =3D data !=3D NULL && data->blen > 0;
638c638
<               eshort =3D data->blen > 0;
---
> 		eshort =3D data !=3D NULL && data->blen > 0;
```

Cheers,
Jack Bendtsen

--=20
You are receiving this mail because:
You are the assignee for the bug.=