]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
bhyve: Fully reset the fwctl state machine if the guest requests a reset.
authorJohn Baldwin <jhb@FreeBSD.org>
Thu, 29 Jun 2023 18:27:12 +0000 (11:27 -0700)
committerMark Johnston <markj@FreeBSD.org>
Tue, 1 Aug 2023 19:48:26 +0000 (15:48 -0400)
commit87702e38a4b4fe990b06f39b5cf267fb564c367e
treeef44831315ff919fa7645f590c61ab8919d67033
parent3d3a1cbfd7a2081efc0be43ce4be0212e5f6a368
bhyve: Fully reset the fwctl state machine if the guest requests a reset.

If a guest tries to reset the fwctl device while a pending request was
in flight, the fwctl state machine can be left in an incomplete state.
Specifically, rinfo is not cleared.

Normally the state machine for fwctl alternates between REQ (receiving
request) and RESP (sending response) and ignores port writes while in
RESP or port reads while in REQ.  Once a guest completes the writes to
the port to send a request, the state machine transitions to RESP and
ignores future writes.

However, if a guest writes a full request and then resets the fwctl
device, the state would transition to REQ without draining the pending
response or discarding the received request.  Instead, additional
port writes after the reset were treated as new payload bytes, but
were appended to the previously-received request and could overflow
the fget_str buffer.

To fix, fully reset the fwctl state machine if the guest requests a
reset.

admbugs: 998
Approved by: so
Reviewed by: markj
Reported by: Omri Ben Bassat <t-benbassato@microsoft.com>
Security: FreeBSD-SA-23:07.bhyve
Security: CVE-2023-3494

(cherry picked from commit bed3ae1d7863ac1e0b1e82ae7bf952937e921efe)
(cherry picked from commit 9fe302d78109b12867bd933bb68cd900c9940b7d)
usr.sbin/bhyve/fwctl.c