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

=============================================================================
FreeBSD-EN-22:04.pcid                                           Errata Notice
                                                          The FreeBSD Project

Topic:          Incorrect PCID mode invalidations

Category:       core
Module:         kernel
Announced:      2022-01-11
Affects:        FreeBSD 12.x
Corrected:      2021-12-14 14:46:07 UTC (stable/12, 12.3-STABLE)
                2022-01-11 18:19:29 UTC (releng/12.3, 12.3-RELEASE-p1)
                2022-01-11 18:33:17 UTC (releng/12.2, 12.2-RELEASE-p12)

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

I.   Background

When switching address spaces the kernel must flush stale Translation
Lookaside Buffer (TLB) entries to ensure that correct data is visible to the
CPU.  An Inter Processor Interrupt (IPI) is used to signal other CPUs of the
need to flush TLB entries.

PCID is an optimization that associates each page table with an identifier
(i.e., Process ID) to allow for efficient context switching.

II.  Problem Description

Operations specific to TLB invalidation in PCID mode were misordered with
respect to IPI transmission.

III. Impact

This issue may cause stale TLB translation entries (and hence invalid data)
in multithreaded applications, leading to application misbehaviour.

IV.  Workaround

PCID may be disabled by adding the following line to /boot/loader.conf:

  vm.pmap.pcid_enabled=0

V.   Solution

Upgrade your 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 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 an errata update"

2) To update your 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/EN-22:04/pcid.patch
# fetch https://security.FreeBSD.org/patches/EN-22:04/pcid.patch.asc
# gpg --verify pcid.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/12/                                                        r371237
releng/12.3/                                                      r371485
releng/12.2/                                                      r371490
- -------------------------------------------------------------------------

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://reviews.freebsd.org/D33413>

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

iQIzBAEBCgAdFiEE/A6HiuWv54gCjWNV05eS9J6n5cIFAmHd1f0ACgkQ05eS9J6n
5cKgjQ//QW16Hxk3gfCvYOKk1PAxDmov2RlSENPrIT/LaHq6UVjGOsB/xaRGFK7U
peWDMtyIQHboTG2RW819xAuB0ZRk7tLzZU9oOIQlQBWwV9qugre9pBLOHhbr98wX
D4tZ1nFN3Yz55I2RWPzyT+ncF2NdsXAJLuBtmb4Uj+MPqMl7dhj01X82vPaFvjJH
tJDMyWTgWHGJlGRk8ZcQ48gF3/G5p3xV6oD0axCQ+RXz9Sx8y4xX+uW2IUskTFkD
ukbRHiNG+Mh1Jt4R9TC92AIvIvFhODts8+R1/1BtARQ76exfYDw6mIf+JC2oCX5+
TrUmk7G8/cxCMyafVNU5+qqVx2qQBcJ8MG/4JwjlEl1kYy9w4ehhB1R7jJtJdfkr
CD92bhJcPnS4zB7M90qTanPA+B7QlBWsbxXEaYmy1jyPZFl7KWLNxME6Ywf9BTpW
oNE6Jnc77EkWWEMpYAk9i5udRCmxDDnYVFaMWuJR3GaSi4yKNxz4P1jsqOYWLR0v
M+fjV6/PJnzn1xZBAWyCHrNT2gUbHxSrjEuHA1r6BKXt59lRFw5VEjwE05T9R7nd
gSi12DEkzvz2ijq5iDFblKmW4B6f8jZsnLpaH/c+U5JfaiEotxb+fg2XCyBzxot5
teHqbyKYYKGWmwRl09HyVB9rSawKibmQqCvhGSpxqSjJTInHLpM=
=1FCm
-----END PGP SIGNATURE-----