From nobody Mon May 23 15:10:14 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 6173E1B51BAA for ; Mon, 23 May 2022 15:10:14 +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 4L6LNk0VPJz4dY9 for ; Mon, 23 May 2022 15:10:14 +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 E55C311C5B for ; Mon, 23 May 2022 15:10:13 +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 24NFADCS050221 for ; Mon, 23 May 2022 15:10:13 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 24NFADlo050220 for virtualization@FreeBSD.org; Mon, 23 May 2022 15:10:13 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 264177] guest can cause a crash in bhyve nvme emulation Date: Mon, 23 May 2022 15:10:14 +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=1653318614; 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=Cug07CTMNHaXc4oE9Wqaa5dJ39IzDKzd38k77HAZHn8=; b=hOrTuq9pSDgX1Gk6StrVVVieqAQy8p8sZROCzcTo+B0JZJeiL1syM3x4rj33Y4CvlVJK/3 6qqxrrIT5sf5o3YEmoBGmQA3yAL+YpYrSSHjEatkW7j+5bH0/CiNvgrlbpt/Kkpjj76IWv SRLF9QnupTJ7NEQiZQUBqvCkIYNH8PmAtzTzRu+Uv6lV5xISbiUjF3k27IQ6HdxRixQaod qq3T3QeYE1GzT7BvvAmOK9+oGKDUaw57mUAW2RqiO58w/oiTUMJ3C38LkWYl8MuDGOTnuQ OLF+RB73HV7JWQTD+w5SAiVenNyCbeoGqpF7fxA/7kaSab173D+VzVzxDNMH5g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653318614; a=rsa-sha256; cv=none; b=hREUTPXZY0P9NSsImTvmkgHWffqsKuyLi8Cm89JbXj/0oA4JwH+o9vJjysK24TAhLLrFgZ GtvCjgyMfpTZw9EyDoKHhOQIx9uqQsyAKUf/HOgTlu7Yn144l5FpvGvdHaCKA2c36N8b4h z07VXGrAMDM6U5nVi8jR3q9Y2+ZalHYCFdhkYyT+gEbHTxkzqXSir6VX4KHng+sBo/NSHJ MHJ6Fhes+Qjv7Ya0T1vd2SEIMXN9AGBj9HiIoX5qnec4qf3qWHwM2sKc/QsGhMSuZvLAc4 Th9XIxh/W6xwTv6YKsO4T1n2oOVD9MXqiW229yyTufcpphZy2L9ABnbqE/FawA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D264177 Bug ID: 264177 Summary: guest can cause a crash in bhyve nvme emulation 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 In bhyve's pci_nvme_append_iov_req(), if the guest provides a zero prp1 (i.e. gpaddr) for an I/O operation, then this code runs: if ((req->prev_gpaddr + req->prev_size) =3D=3D gpaddr) { iovidx =3D req->io_req.br_iovcnt - 1; ...; req->prev_size +=3D size; ...; req->io_req.br_iov[iovidx].iov_len =3D req->prev_size; prev_gpaddr, prev_size, and br_iovcnt are all ordinarily zero at this point. So iovidx =3D -1, and the assignment to br_iov[iovidx].iov_len actually overwrites io_req.br_param. This later causes a bad pointer dereference in pci_nvme_io_done(): struct pci_nvme_ioreq *req =3D br->br_param; struct nvme_submission_queue *sq =3D req->nvme_sq; You can see this happen if you boot a FreeBSD guest kernel in bhyve with an nvme device, after modifying the guest kernel's nvme_payload_map() in /sys/dev/nvme/nvme_qpair.c to set tr->req->cmd.prp1 to zero when it is called for the third time. --=20 You are receiving this mail because: You are the assignee for the bug.=