From nobody Thu Dec 16 14:20:47 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3BBB818F83BF; Thu, 16 Dec 2021 14:20:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JFDmb4cCJz55J5; Thu, 16 Dec 2021 14:20:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7BCDE174A; Thu, 16 Dec 2021 14:20:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BGEKlFM073067; Thu, 16 Dec 2021 14:20:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BGEKlXx073066; Thu, 16 Dec 2021 14:20:47 GMT (envelope-from git) Date: Thu, 16 Dec 2021 14:20:47 GMT Message-Id: <202112161420.1BGEKlXx073066@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 4a61d8ef42cb - main - aesni: Fix an out-of-bounds read in AES_GCM_decrypt() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4a61d8ef42cb44c337dfdc17424cc2e2f1d67fd5 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639664447; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EYiE/NaQ2srxXPXRExEnBK/Iw9VaKBbtbsb0PJy8NwU=; b=dOdArF3yWAMrlfw9EgquPhsphFWCZ1LZTJgiD8pJoEkj8rPG2ujvMSXXVV2mSbJSSn7VMf FemhJpTmQR4PP4TlLNX8U6+pVWRMhNifP4hrjwn5qxt/8Y5K/TnNO6TvSuBlomDfi9RVyo kBVuO/Rmk+8up/IycAj8/UOgyzgR/2HP9xtG4tJmfNKcJUGbvLDUrQDLoL25XTryQkohhg zaKPVKx6rz6HMchxfVdkYgAGlhwwcGgE7gqUUG1RWonL9UGiy73Xh04mZ0QqQVDKO8VgFN CunxowYfSS9iMo7V/kM8cCWS07TVo8H2g8UOAr5kP0gpADiJRVULXf3Mkpveew== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639664447; a=rsa-sha256; cv=none; b=SKkZDTNp2ORqKPGScJBf2aLfWZr/m0Tyonkf+1/20aziROCD4hsKYdjPaGoOJPQ2Fqzn86 drbSSbVcKk0FCkajdgB3tGl07DnENBJNIY25yR+Q5nE9V2U/z5HtCMv935VDWAidIHgPwC 4s8eowdq9FZ5YGHqDfZzk5wUpqTMXczYNO6aofyCVcC4U09c/DWzCwayYSPH6ij7Sn4BDQ 0+gt9lTl+I6CfWLoszszTfGIUpdUW5WX3syEQ6Gs2ZgzNuKm3T8Vi1JqcfjhIsHl1twDt/ Sa+B/t19bj5WGDzGek/s0A49I+AqmHtjyHpUKsIzB+3zwgR+IY1pI7XMkvBTlw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4a61d8ef42cb44c337dfdc17424cc2e2f1d67fd5 commit 4a61d8ef42cb44c337dfdc17424cc2e2f1d67fd5 Author: Mark Johnston AuthorDate: 2021-12-16 14:08:16 +0000 Commit: Mark Johnston CommitDate: 2021-12-16 14:17:06 +0000 aesni: Fix an out-of-bounds read in AES_GCM_decrypt() This is the same as 4285655adb74 ("aesni: Avoid a potential out-of-bounds load in AES_GCM_encrypt()") except for the decryption path. Reported by: Jenkins (KASAN job) Reviewed by: cem MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33474 --- sys/crypto/aesni/aesni_ghash.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/crypto/aesni/aesni_ghash.c b/sys/crypto/aesni/aesni_ghash.c index a1295b6ccbda..a95723f13d85 100644 --- a/sys/crypto/aesni/aesni_ghash.c +++ b/sys/crypto/aesni/aesni_ghash.c @@ -799,8 +799,9 @@ AES_GCM_decrypt(const unsigned char *in, unsigned char *out, } tmp1 = _mm_aesenc_si128(tmp1, KEY[nr-1]); tmp1 = _mm_aesenclast_si128(tmp1, KEY[nr]); - tmp1 = _mm_xor_si128(tmp1, - _mm_loadu_si128(&((const __m128i *)in)[k])); + last_block = _mm_setzero_si128(); + memcpy(&last_block, &((const __m128i *)in)[k], nbytes%16); + tmp1 = _mm_xor_si128(tmp1, last_block); last_block = tmp1; for (j=0; j