-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

=============================================================================
FreeBSD-SA-22:12.lib9p                                      Security Advisory
                                                          The FreeBSD Project

Topic:          Missing bounds check in 9p message handling

Category:       contrib
Module:         lib9p
Announced:      2022-08-09
Credits:        Robert Morris
Affects:        FreeBSD 13.0 and 13.1
Corrected:      2022-08-09 13:33:14 UTC (stable/13, 13.1-STABLE)
                2022-08-09 20:01:13 UTC (releng/13.1, 13.1-RELEASE-p1)
                2022-08-09 20:00:03 UTC (releng/13.0, 13.0-RELEASE-p12)
CVE Name:       CVE-2022-23092

For general information regarding FreeBSD Security Advisories,
including descriptions of the fields above, security branches, and the
following sections, please visit <URL:https://security.FreeBSD.org/>.

I.   Background

lib9p provides an implementation of the 9p file system protocol.  It is
used by bhyve(8) to provide guest access to a host file system tree via
the virtio-9p device model.  The FreeBSD base system does not contain
any other users of lib9p.

II.  Problem Description

The implementation of lib9p's handling of RWALK messages was missing a
bounds check needed when unpacking the message contents.  The missing
check means that the receipt of a specially crafted message will cause
lib9p to overwrite unrelated memory.

III. Impact

The bug can be triggered by a malicious bhyve guest kernel to overwrite
memory in the bhyve(8) process.  This could potentially lead to
user-mode code execution on the host, subject to bhyve's Capsicum
sandbox.

IV.  Workaround

No workaround is available.  Systems not using bhyve's virtio-9p device
model are not affected.

V.   Solution

Upgrade your vulnerable system to a supported FreeBSD stable or
release / security branch (releng) dated after the correction date,
and restart any VMs utilizing virtio-9p devices.

Perform one of the following:

1) To update your vulnerable system via a binary patch:

Systems running a RELEASE version of FreeBSD on the amd64, i386, or
(on FreeBSD 13 and later) arm64 platforms can be updated via the
freebsd-update(8) utility:

# freebsd-update fetch
# freebsd-update install

2) To update your vulnerable system via a source code patch:

The following patches have been verified to apply to the applicable
FreeBSD release branches.

a) Download the relevant patch from the location below, and verify the
detached PGP signature using your PGP utility.

# fetch https://security.FreeBSD.org/patches/SA-22:12/lib9p.patch
# fetch https://security.FreeBSD.org/patches/SA-22:12/lib9p.patch.asc
# gpg --verify lib9p.patch.asc

b) Apply the patch.  Execute the following commands as root:

# cd /usr/src
# patch < /path/to/patch

c) Recompile the operating system using buildworld and installworld as
described in <URL:https://www.FreeBSD.org/handbook/makeworld.html>.

Restart restart any VMs utilizing virtio-9p devices, or reboot the system.

VI.  Correction details

This issue is corrected by the corresponding Git commit hash or Subversion
revision number in the following stable and release branches:

Branch/path                             Hash                     Revision
- -------------------------------------------------------------------------
stable/13/                              c536045c51da    stable/13-n252071
releng/13.1/                            7dfe949791e7  releng/13.1-n250154
releng/13.0/                            70a2cf7bb2e0  releng/13.0-n244806
- -------------------------------------------------------------------------

Run the following command to see which files were modified by a
particular commit:

# git show --stat <commit hash>

Or visit the following URL, replacing NNNNNN with the hash:

<URL:https://cgit.freebsd.org/src/commit/?id=NNNNNN>

To determine the commit count in a working tree (for comparison against
nNNNNNN in the table above), run:

# git rev-list --count --first-parent HEAD

VII. References

<URL:https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-23092>

The latest revision of this advisory is available at
<URL:https://security.FreeBSD.org/advisories/FreeBSD-SA-22:12.lib9p.asc>
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEE/A6HiuWv54gCjWNV05eS9J6n5cIFAmLyz1IACgkQ05eS9J6n
5cI0vxAAoIkoKbB7T2cGS3k4sNM0SCB8/akhccPCVLgDc5aNnCJSD21gSWVY//Qc
IoxNgYBiP5Y0t2f8y6pzE4f9IuNRwhiLMAVgNHJgf7oRvsQyUAAqv+kXiXuutYQm
qYZOYM6vYk7bw6yLPwyS1S0QPWFZraBA3wRxAXLn3NcU3blKc6psPPqLuqfdR+0a
13s305/lw1uoaMYHtlS5S4rcnZm9uLPVMQZL6NMVtkLjRbuN2vUrZy81zSHVGQUN
RAN8qAPXjeD22a5gy7ZIqgt07OjYn331rAPPIpNtADU0vaYzVUkwrilY8ogIIJH2
Be2NPmqbZEWTHFYcOQHWW/16rDXYXx7ZfvHHYzsrId+9G97I/nTMmN8dPeUJTtgh
syG6DSsbrYmssfGDXFX/nTdKDcT5UkNE3W3er7+RwQ54d9SlUwuY5SyycPJNBDim
018+Gb3GobScJGwSID+DyYEHxaj9e0WmLC6tpm8ZBlZnUTrdBqxEX+xhfxsm0Yds
dPVXHICXebgXzHs9RO5s4eNa+miu3W8QRkbyLmL8ReUHwsWSLS5p91hgOheHji4e
0vO5T99f11+lp1FFw9iLlpo09klsN26nGTJ4/XXtlCjD85GIJINR7JI/Fg1NRF4N
S5CmUPVutyvzGPkrNVUI9QwL/O0CEg55KTiqtQKjgjCCHhChZ+0=
=ILeT
-----END PGP SIGNATURE-----