Page MenuHomeFreeBSD

aesni: Fix yet another out-of-bounds read
ClosedPublic

Authored by markj on Dec 15 2021, 5:20 PM.
Tags
None
Referenced Files
F160185589: D33474.id.diff
Mon, Jun 22, 12:10 AM
F160174083: D33474.diff
Sun, Jun 21, 9:58 PM
Unknown Object (File)
Fri, Jun 19, 3:48 PM
Unknown Object (File)
Tue, Jun 16, 7:41 AM
Unknown Object (File)
Tue, Jun 16, 3:19 AM
Unknown Object (File)
Mon, Jun 15, 1:05 PM
Unknown Object (File)
Thu, Jun 11, 4:35 AM
Unknown Object (File)
Wed, Jun 3, 8:32 PM
Subscribers

Details

Summary

This is the same as 4285655adb74 ("aesni: Avoid a potential
out-of-bounds load in AES_GCM_encrypt()") except for the decryption
path. I failed to notice this last time since I assumed that encryption
and decryption use the same routine, like the CTR mode implementation
does.

Reported by: Jenkins (KASAN job)

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj requested review of this revision.Dec 15 2021, 5:20 PM

LGTM modulo overflow concern and what looks like a typo.

sys/crypto/aesni/aesni_ghash.c
793

Is this correct if nbytes was > 2GB? nbytes is a uint32 but resid is (signed) integer.

806

typo

sys/crypto/aesni/aesni_ghash.c
793

I think it still happens to work. Note that OCF itself can only describe buffers up to 2GB anyway (crp_payload_length is an int I think?)

markj marked 3 inline comments as done.

Drop the use of resid entirely, this is consistent with AES_GCM_encrypt() anyway.

This revision is now accepted and ready to land.Dec 15 2021, 8:03 PM