From nobody Mon Dec 27 15:45:49 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 24646191C3E1; Mon, 27 Dec 2021 15:45:50 +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 4JN27d5w1nz4lyM; Mon, 27 Dec 2021 15:45:49 +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 A845120775; Mon, 27 Dec 2021 15:45:49 +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 1BRFjn4N058067; Mon, 27 Dec 2021 15:45:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BRFjn4Y058066; Mon, 27 Dec 2021 15:45:49 GMT (envelope-from git) Date: Mon, 27 Dec 2021 15:45:49 GMT Message-Id: <202112271545.1BRFjn4Y058066@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 05bf7d68c568 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 05bf7d68c56830e52dee14dc87c07d6716e8195e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640619949; 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=VDGmc3Cfh9UW27pTVOeCtI5ODF6p4mS5LKTCFM3dopE=; b=ZdXvOjV0uMN/OLXGXoCv6epOD/Ox+b5VRgz/Jh5O+Dn7V6pINAuc6BxSEJLDzU5pY/3eEJ p2ZTsrlOXw3Ho/J7weeUE+hCUVGzqfgZi59k40hh1L4vtNFBlBzvS84a0v/f9MugzNitgr E6dsTyce4XnrEWF9fEYPYXwXxqU6O1xoz5w5zw32KViQkcmwNh9Va3JwHG03JF8HYXi+wt /wtsByj+L0CMMRMckfCf8bxbRz54tzbPkc5i6f2dhGjYNUB22j1JfjsnIHv4lKLc7XTghp R9O2VjkUuMCviDx0upSjOaf8e1wGAjLAkEuuapMSd8b+NnaVndKkHoUIHx2flg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640619949; a=rsa-sha256; cv=none; b=SfnOo7RYNMo6mND8n7r/e8ZQX/ncEUwigZfB3aaUFquH/QhNPXUYiigJuglbjXbWVDh7bJ G+urohWNCgF63OIHd2QN0zQg/yASPO6WO+8IeNIu6qiGfRd8Qywk03bUl5UcgkdRTmv5Yb cso4EEj2geB10DzgFbXXi0Ti9Sv7hT12RZSBn+jC3aRL7WWCYU6aixUV/cicv2UbqLTWST Qxd9/H9uEShlc2vTNH5iL+zv8/bTYa+5rcIB/N6zm/A6+rF7a+DkCAx00LFvg6HVdc+S50 eNeUSCLI486ob7yxRCOX2LfLtrTsc1sneyir+dGRK1OD6E+KglcWxgFAj9dZxQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=05bf7d68c56830e52dee14dc87c07d6716e8195e commit 05bf7d68c56830e52dee14dc87c07d6716e8195e Author: Mark Johnston AuthorDate: 2021-12-16 14:08:16 +0000 Commit: Mark Johnston CommitDate: 2021-12-27 15:45:36 +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 Sponsored by: The FreeBSD Foundation (cherry picked from commit 4a61d8ef42cb44c337dfdc17424cc2e2f1d67fd5) --- 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