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

=============================================================================
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=251462>

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

iQIzBAEBCgAdFiEE/A6HiuWv54gCjWNV05eS9J6n5cIFAmCu6t4ACgkQ05eS9J6n
5cJdUBAAor2SfwygnujBNtepn8miqhACwa2P/8HZo1G68JTrHzRp8U8l/iLhTIwn
FF/aylaIg3uiFkb5V68yi9YKo4a8kIK0U/J805n8WUFFTS5OiwLkI3mLKC3vHMUD
d2gvBaAjPeBNjlNanFp8WpdNsCXvJq9CBXECQnwsnNJ1zpSSsTwm/T48pIeRpk/T
sYpyaLgEjsXl0tx0VkW2wwk7tNSQx0K7BouzqrwbQku18GW9ybETfQh5NE+Mz2+S
T1e3A4y2VNWXpDqCgHwl7+X7NX3FH2wGI56G3Xv781zJY5jq+UjxoXyLGVY56y3P
KvCgqnPavLZgER3ui/bqro3DR3uN6P3hb/Jg/3ChrNVuf9U0hElblWzQ3KQ/y2J8
21YSuVvclMu4cfWfGcOYA8uXBQCUUYHAMKzenzmj9kZYMWaSZHpn/aibaYWZEO/U
hsDfeJRbR1hIVOdKGUmGrcWc2BVAQw/xHyAIn1IEBvCO9JRl09VPLNU6q19mrquH
GoQ0NRaWg6v+spHJeuiv3wreLjr/mfznk+I4Cz/CT3cVbm7b4gJXerObIWKnEyFI
Cj8ySvkhFAVdWcLIOJPrlIgxY5IoVr/raRuKhJ7kmFkELfUd1HK81e9QdpdzKYOH
hKWROGEBMr6bG17rqMY+tZmlx6wKVtf8mJCQHomQSi3Q7J2DRO0=
=KdoV
-----END PGP SIGNATURE-----