FreeBSD Errata Notice FreeBSD-EN-21:11.aesni
27 May, 2021 by errata-notices@freebsd.org | freebsd
FreeBSD-EN-21:11.aesni Errata Notice
The FreeBSD Project
Topic: Race condition in aesni(4) encrypt-then-auth operations
Category: core
Module: aesni
Announced: 2021-05-26
Affects: FreeBSD 12.2
Corrected: 2021-04-27 19:16:35 UTC (stable/12, 12.2-STABLE)
2021-05-26 20:40:11 UTC (releng/12.2, 12.2-RELEASE-p7)
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
The aesni(4) driver provides implementations of various cryptographic
operations using specialized CPU instructions available on contemporary Intel
and AMD CPUs. This provides improved throughput relative to pure software
implementations of the same operations.
II. Problem Description
aesni(4) implements SHA-1 and SHA-2 and can compute HMACs using these
functions. One step of the HMAC computation involves the computation of a
derived key. This step was implemented such that if multiple threads were
concurrently computing an HMAC using the same crypto(9) session, the kernel's
copy of the session key could be corrupted.
III. Impact
This bug could cause aesni(4) to return incorrect digests of input data,
or incorrect report a digest verification failure.
Since the bug is only triggered when multiple threads are sharing a crypto(9)
session, some consumers are unaffected. For example, geli(8) will not trigger
the bug. It is possible to trigger the bug with IPSec or KGSSAPI, or via
crypto(4) if the underlying application is multithreaded and shares sessions
among multiple threads.
IV. Workaround
The aesni(4) kernel module may be unloaded to work around the problem. Note
that this may incur a substantial hit to performance.
Workloads not making use of HMAC-based authentication using aesni(4) are
unaffected. For example, aesni(4) implements AES-GCM, and that implementation
is not susceptible to this problem.
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 erratum 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-21:11/aesni.patch
# fetch https://security.FreeBSD.org/patches/EN-21:11/aesni.patch.asc
# gpg --verify aesni.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/ r369665
releng/12.2/ r369860
- -------------------------------------------------------------------------
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://bugs.freebsd.org/bugzilla/show_bug.cgi?id%1462>
The latest revision of this advisory is available at
<URL:https://security.FreeBSD.org/advisories/FreeBSD-EN-21:11.aesni.asc>