FreeBSD Security Advisory FreeBSD-SA-22:04.netmap

From: FreeBSD Security Advisories <security-advisories_at_freebsd.org>
Date: Wed, 06 Apr 2022 04:07:59 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

=============================================================================
FreeBSD-SA-22:04.netmap                                     Security Advisory
                                                          The FreeBSD Project

Topic:		Potential jail escape vulnerabilities in netmap

Category:       core
Module:         netmap
Announced:      2022-04-06
Credits:	Reno Robert and Lucas Leong (@_wmliang_)
                Trend Micro Zero Day Initiative
Affects:        All supported versions of FreeBSD.
Corrected:      2022-03-19 17:53:35 UTC (stable/13, 13.1-STABLE)
                2022-04-06 03:26:07 UTC (releng/13.1, 13.1-RC1-p1)
                2022-04-06 03:04:13 UTC (releng/13.0, 13.0-RELEASE-p11)
                2022-03-20 09:08:23 UTC (stable/12, 12.3-STABLE)
                2022-04-06 03:06:25 UTC (releng/12.3, 12.3-RELEASE-p5)
CVE Name:       CVE-2022-23084, CVE-2022-23085

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

netmap is a framework for extremely fast and efficient packet I/O for
userspace and kernel clients, and for Virtual Machines.

II.  Problem Description

The total size of the user-provided nmreq to nmreq_copyin() was first
computed and then trusted during the copyin.  This time-of-check to
time-of-use bug could lead to kernel memory corruption.  [CVE-2022-23084]

A user-provided integer option was passed to nmreq_copyin() without checking
if it would overflow.  This insufficient bounds checking could lead to kernel
memory corruption.  [CVE-2022-23085]

III. Impact

On systems configured to include netmap in their devfs_ruleset, a privileged
process running in a jail can affect the host environment.

IV.  Workaround

No workaround is available.  Systems that do not include netmap in their
devfs_ruleset are unaffected.  A default installation of FreeBSD does not
include netmap in its devfs_ruleset.

V.   Solution

Upgrade your vulnerable system to a supported FreeBSD stable or
release / security branch (releng) dated after the correction date,
and reboot.

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
# shutdown -r +10min "Rebooting for a security update"

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:04/netmap.patch
# fetch https://security.FreeBSD.org/patches/SA-22:04/netmap.patch.asc
# gpg --verify netmap.patch.asc

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

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

c) Recompile your kernel as described in
<URL:https://www.FreeBSD.org/handbook/kernelconfig.html> and 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/                              9f600a260a73    stable/13-n250049
releng/13.1/                            7c55c52696d2  releng/13.1-n250081
releng/13.0/                            4996f46e03a4  releng/13.0-n244794
stable/12/                                                        r371757
releng/12.3/                                                      r371870
- -------------------------------------------------------------------------

For FreeBSD 13 and later:

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

For FreeBSD 12 and earlier:

Run the following command to see which files were modified by a particular
revision, replacing NNNNNN with the revision number:

# svn diff -cNNNNNN --summarize svn://svn.freebsd.org/base

Or visit the following URL, replacing NNNNNN with the revision number:

<URL:https://svnweb.freebsd.org/base?view=revision&revision=NNNNNN>

VII. References

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

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

iQIzBAEBCgAdFiEE/A6HiuWv54gCjWNV05eS9J6n5cIFAmJNDgUACgkQ05eS9J6n
5cJ5oA/7BbWWbR3NEYYOSYBYDGtuRVUFFQYFLh35qcammhfATek0yMyqN47wHwq1
/Nh+91ZHJBV/wNkr5aFsMcNda9c/a9CVQLjWwiT5wtOGHt3tip0dy4Kalc1bwewI
tGhlCX5bROy0x7xP0+qNHmDRvEVDviash3Wp7Ysk2uzpZsXl0bew1dBwH/9dxnYv
XwfCHfU3fUdeyWtAvswwTlx5XXXBdgvGAShsdZTjYlowUioL6E+m3w0xFdyae7q+
MjaI9w06p+WJ89WTnwefLq5DwAi6eS+3qmZNJaU3Shq6tQo0TqrOfIuT3l8Id8tv
f6XJBjZHDFJBbEofUREHjl0q7qAbZ2tBzxvDJWzGmBp98lSg0diIzyMmgOeUBT/1
MG8LLK3e4Z+l5ZknDRJJ38yiUCR4ANaUEygYFVXAcb7QylMhmqcJ6hIAMpCiJ7NJ
S+ftBNjC1S6RccATBJUX3/IyTvwigvQIybNzKlqIMEjSPd8mVSTpbir43dK8Vr5v
kKmaqSsTN5Df3s+yPn8uBG9VXhO0cNtLBxFJ8eWsI5mLigpCFD2KkvO06oLE9ALa
fhEZxIy0bD4GbambenfZ2xxaSoZSIeAh1pM5aL4x/C4r7R0p8dH3ldkTDKWfqtfE
/gaVGCSle/K0I6y1LUhWLdD7FlOLScHRkVF2sIGSDP4KTbH7H18=
=EwyH
-----END PGP SIGNATURE-----