From nobody Thu Jul 27 20:12:56 2023 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 4RBhll0tPVz4pdly; Thu, 27 Jul 2023 20:12:57 +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 4RBhlX6g8nz3N98; Thu, 27 Jul 2023 20:12:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690488777; 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=mYSgoRqsRVHZm7SmFtXeV+Ywx5HSwSTr7nAPkH0nCiE=; b=VSkBl/UFsRv+hz+jdH7PdTZLX+MC5/yE5AwM2FUSdKCv1E3n3Xs1dnMaL7Z13OT8js1OUA bZcQyPfM5MjF3krSGCf9EfCAtbGTMdzq11XpmHKnE65R8nzWdIMBPBtg07eNM7gZQQaiCZ EWz0mAghuRBN7t9eO1vHL/tlJbXFgzqrP+/1scr/PmjKKAoh8+AnB+73zU9G/Xwl/3BOLA wTpZhmE2CdaXMtNQ7NRYOw+lccmu2jRFJFcamfAOKycBUlv0GXyq3WTkJdzTodc9dS3/T/ u7Ucqk63uxn9Iw74YJK+GYuH/UlYE6susbQCA0pxdIpxADdVNeeZ7j8yzVx+Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690488777; 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=mYSgoRqsRVHZm7SmFtXeV+Ywx5HSwSTr7nAPkH0nCiE=; b=R6jUIzLp+FewX3eCcH/IKBlZjTk0ZLLFa74/GHharE2XE9zoCCO66sb4U6dAQpN0tsJtKr HwNrrUQhuvNy4q68TC3RKIMuIg9yRjJ2F+PpP+5DHlWJwRGBe3FKKiJ1fvnPWDpSItwDld UCMYDgsw+fPpdAiaBeUptKpzOMUigjVovGT4Z/6afW2ljjfou64iY7QZ8ZBs9S9VB6xxiV HoNQ8/2S8h1iWkmbeSw5pC41Fov3ZhDY4rr367UnXU5Ej5wDe2LJdO+NkmY8XWvWiiNN+W LCWYxJsGBe5GcyTYD6eIOHI+1smZWsegNI+RC0GJ9akGcCDUgo8qnIr+FmrinA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1690488777; a=rsa-sha256; cv=none; b=ybEzr1HZdhq8PdATzzFNv/0KXgse49DnWNonR2Zd8JxFBNwlrKTg5YGxjC38ZFjCrDZBGA uoBPQ3Bgx7L2Ix0nF+X4tIFiYyFQio/nen/gZlhZdmhcakMe77mie4XMlXbEk+E5WSsPSa DUSPwADLrVj0HGt55HlmFpmSRBISdT8M4PSBPG4safZhYXAFGsg9m7EA5gbIbNRwrrJ0W/ SYa4woSPhg14M3nUKb3ToYW1xDU0IdZx1ZvriHRRxIyr88ANyW/4leYVYOLe4IUC3u0I4W MxUM0jvIdTKG1cMg+t7Wi/eCuapbk7eYqh3CQOq+rFHhtvGAT1SAznjkMokJGQ== 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 4RBhlX5T96zNty; Thu, 27 Jul 2023 20:12:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 36RKCuod087654; Thu, 27 Jul 2023 20:12:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36RKCu8Z087653; Thu, 27 Jul 2023 20:12:56 GMT (envelope-from git) Date: Thu, 27 Jul 2023 20:12:56 GMT Message-Id: <202307272012.36RKCu8Z087653@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: 96c253812139 - main - opencrypto: Respect alignment constraints in xor_and_encrypt() 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: 96c2538121390c872f68ac48f97b35fb973c11dc Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=96c2538121390c872f68ac48f97b35fb973c11dc commit 96c2538121390c872f68ac48f97b35fb973c11dc Author: Mark Johnston AuthorDate: 2023-07-27 19:44:52 +0000 Commit: Mark Johnston CommitDate: 2023-07-27 19:44:52 +0000 opencrypto: Respect alignment constraints in xor_and_encrypt() Copy operands to an aligned buffer before performing operations which require alignment. Otherwise it's possible for this code to trigger an alignment fault on armv7. Reviewed by: jhb MFC after: 2 weeks Sponsored by: Klara, Inc. Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D41211 --- sys/opencrypto/cbc_mac.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/sys/opencrypto/cbc_mac.c b/sys/opencrypto/cbc_mac.c index 9a030cd54173..cfba24eeab31 100644 --- a/sys/opencrypto/cbc_mac.c +++ b/sys/opencrypto/cbc_mac.c @@ -40,19 +40,16 @@ static void xor_and_encrypt(struct aes_cbc_mac_ctx *ctx, const uint8_t *src, uint8_t *dst) { - const uint64_t *b1; - uint64_t *b2; - uint64_t temp_block[CCM_CBC_BLOCK_LEN/sizeof(uint64_t)]; +#define NWORDS (CCM_CBC_BLOCK_LEN / sizeof(uint64_t)) + uint64_t b1[NWORDS], b2[NWORDS], temp[NWORDS]; - b1 = (const uint64_t*)src; - b2 = (uint64_t*)dst; + memcpy(b1, src, CCM_CBC_BLOCK_LEN); + memcpy(b2, dst, CCM_CBC_BLOCK_LEN); - for (size_t count = 0; - count < CCM_CBC_BLOCK_LEN/sizeof(uint64_t); - count++) { - temp_block[count] = b1[count] ^ b2[count]; - } - rijndaelEncrypt(ctx->keysched, ctx->rounds, (void*)temp_block, dst); + for (size_t count = 0; count < NWORDS; count++) + temp[count] = b1[count] ^ b2[count]; + rijndaelEncrypt(ctx->keysched, ctx->rounds, (void *)temp, dst); +#undef NWORDS } void