From nobody Mon May 30 09:52:03 2022 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 23CC31B5B420 for ; Mon, 30 May 2022 09:52:04 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LBW0M6C91z4hL4 for ; Mon, 30 May 2022 09:52:03 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) 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 B5C1915207 for ; Mon, 30 May 2022 09:52:03 +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 24U9q3qV026019 for ; Mon, 30 May 2022 09:52:03 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 24U9q3Ls026017 for virtualization@FreeBSD.org; Mon, 30 May 2022 09:52:03 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 264347] bhyve guest can cause access beyond end of pci_xhci.c's ep_sctx_trbs[] array Date: Mon, 30 May 2022 09:52:03 +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: Unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: rtm@lcs.mit.edu 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: 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 List-Archive: https://lists.freebsd.org/archives/freebsd-virtualization List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-virtualization@freebsd.org X-BeenThere: freebsd-virtualization@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653904323; 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=Fxz/Y4UPkZqSpQ6/yCueRaoCqQ3etoBc5lMI7t7QJao=; b=dd5/RdwtwypMBz8cWRG79j6U7q3jh5o+MZ8Dx06I3RpntpLpQE+8MVjssrTOkyxj8XoamK V8LTHeZH+v+fIsLoH4nDn6hpmS8YMvVnlx0vvtcfOuY5dY3RSkkES7XCLZBzsZhgMXnTZ3 7B1rlPPlagcBjF5x/K4/7YHgBkNIDbMxWx1c5PcuBiMiDo7Sh2TDLm/9gXKYzpkaShfIeM vYoQWp0jm06oe9U4h0ycbmid83kAwjVmMwpSNBENjznUlGlC+SUm0wKeHGCiFVmhBJ3Hzf gs41H4FtNVCC8sZ+N6aZN+62WHAke9jGyLpeYr3FZfaX66Gh9YLZd9lFzx5RhA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653904323; a=rsa-sha256; cv=none; b=bjlFDvaqZFjP/25NDvLq2E8sGLEHpsTmi84iZbVpP9SHLtr3ayGbC2Ydah+lc4dq0Cpo9q FP6MscWWjzlzq0eE6+KGM34r1FIr9otsB6NRvN0GTgf71IQ6vja+lpzrJs95OqDpEvoYEz FEkOVxH91UVc8qx6OPnm6XANdtN+epcUuH/QEwOXzb+Hz3o8tzYNRP+v2yf/LobOIUnwlp 5Eyu0xNBoFVTqYmU2C4cHZsvu0x08LJb8dioGByfbMDLvGSZb245Z+Pl5YAY1cMnwgIuQ8 LU0g15lXQxywi1U0MZNJQA0Vev31y5Ms20t0jf1Nx4UE558aUK7zKpG4Fcyaiw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D264347 Bug ID: 264347 Summary: bhyve guest can cause access beyond end of pci_xhci.c's ep_sctx_trbs[] array Product: Base System Version: Unspecified Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: bhyve Assignee: virtualization@FreeBSD.org Reporter: rtm@lcs.mit.edu Bhyve's pci_xhci_init_ep() allocates space for multiple streams if the guest asks for them: pstreams =3D XHCI_EPCTX_0_MAXP_STREAMS_GET(ep_ctx->dwEpCtx0); if (pstreams > 0) { ...; devep->ep_sctx_trbs =3D calloc(pstreams, sizeof(struct pci_xhci_trb_ring)); So if the guest asks for one stream, only devep->ep_sctx_trbs[0] is valid. ep_sctx_trbs[] is used in pci_xhci_device_doorbell(): if (XHCI_EPCTX_0_MAXP_STREAMS_GET(ep_ctx->dwEpCtx0) !=3D 0) { /* * Stream IDs of 0, 65535 (any stream), and 65534 * (prime) are invalid. */ if (streamid =3D=3D 0 || streamid =3D=3D 65534 || streamid = =3D=3D 65535) { DPRINTF(("pci_xhci: invalid stream")); return; } ...; sctx_tr =3D &devep->ep_sctx_trbs[streamid]; ...; ringaddr =3D sctx_tr->ringaddr; But here, if the guest asks for one stream, the code requires streamid to be 1, and thus indexes beyond the end of ep_sctx_trbs[]. --=20 You are receiving this mail because: You are the assignee for the bug.=