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

=============================================================================
FreeBSD-EN-23:17.ossl                                           Errata Notice
                                                          The FreeBSD Project

Topic:          ossl(4)'s AES-GCM implementation may give incorrect results

Category:       core
Module:         ossl
Announced:      2023-12-05
Affects:        FreeBSD 14.0
Corrected:      2023-12-03 17:48:09 UTC (stable/14, 14.0-STABLE)
                2023-12-05 18:27:34 UTC (releng/14.0, 14.0-RELEASE-p2)

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

ossl(4) is a kernel module which implements some cryptographic operations
using implementations derived from OpenSSL.  It integrated into the FreeBSD
kernel's OpenCrypto Framework (OCF).

II.  Problem Description

ossl(4) contains an implementation of AES-GCM for amd64.  This implementation
did not properly implement some aspects of the OCF interface.  In particular,
ossl(4) AES-GCM sessions were not thread-safe, and did not handle an AAD
buffer outside of the main plaintext/ciphertext buffer.  The former bug
affects consumers which dispatch multiple requests in parallel on a single
session, such as ZFS when encrypted datasets are configured.  External AAD
buffers are used by some network features such as ktls(4).

III. Impact

On amd64 systems, ossl(4) could give incorrect output for AES-GCM operations
if consumers trigger either of the bugs described above.  This could, for
example, result in packet loss, if ossl is used to encrypt/decrypt tunnelled
traffic, or data corruption if ossl is used to encrypt/decrypt filesystem
data.

Users are not affected by default, as ossl.ko is not loaded by default.  To
be affected, a system must either be running a custom kernel which contains
ossl(4), or be configured to load ossl.ko via loader.conf(5). 

IV.  Workaround

Disable the use of ossl(4), either by removing it from loader.conf or the
kernel configuration, and reboot the system.  The built-in aesni(4) module
currently implements all of the same operations as ossl, so consumers will
not notice any functional difference.

V.   Solution

Upgrade your system to a supported FreeBSD stable or release / security
branch (releng) dated after the correction date.  A reboot is required
following the upgrade.

Perform one of the following:

1) To update your system via a binary patch:

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

# freebsd-update fetch
# freebsd-update install
# shutdown -r now

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-23:17/ossl.patch
# fetch https://security.FreeBSD.org/patches/EN-23:17/ossl.patch.asc
# gpg --verify ossl.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 as of the corresponding Git commit hash or Subversion
revision number in the following stable and release branches:

Branch/path                             Hash                     Revision
- -------------------------------------------------------------------------
stable/14/                              118b866d9c39    stable/14-n265898
releng/14.0/                            433fe061fc59  releng/14.0-n265388
- -------------------------------------------------------------------------

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://bugs.freebsd.org/bugzilla/show_bug.cgi?id=275306>

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

iQIzBAEBCgAdFiEEthUnfoEIffdcgYM7bljekB8AGu8FAmVvmVoACgkQbljekB8A
Gu/dvQ/+KCck7lbRZYax4QZ7JxLpbutOWDITGFVMtELT7njcMMpIH6TIKLwTDpcR
XPz/znROLquDkTpke6uf0IZyC1nMHxaYwgiTImpA0ecd3Z5n6hNj2EEhOhlitDfc
N+UNhpQa8689CYkcm4ofgb2MQdzc/0HDTX+6tUpLuwuLhqGxyJK5bgQo63MK2osb
qlj5TntXjVIbd33dN97JZfV9JDSapS2xLBFShe0R9+do0ucvDVOiPErHvKsLSm9P
iYxrezxw3X6fi1BbLVe7u3B3ELeNgKnreh7CakDn/UF3hhn138d4XQ2+3ppRaadG
81kbzMtHQHOKTRzVBrdi2sd7wDOgTapGmeeSr/87GYCOU2ZfXpZjr5k4tuD/RUOB
44ZxeWnaNKWa4C8xr1ESr3pebTF1la2tqNQwiG/9euUn3Kl/NZFRCzaruiEmaLaG
DeOAu3VZCucHPowA3rr80J6XPx/295Bq/bN6J5/Qd+TzKjzbqzvelXXHsn5AMjur
tPUtG5iCLQZvivM5Wd4jaOVrZvp0ps7qlugNnOZPr/qBcW04YdwCamzwUipIDNnP
XrxmxJdhFJhy//hnTNgJiKS6LJP5lh2ogAN6tRnvKKZrb11OAcHPIUqIyI51Bieh
w4Yqrq2cOxMDgi7jKlSi2DLWs56WWEDob8cHhRhKhI6Fre2Yizs=
=Vn8m
-----END PGP SIGNATURE-----