Eric Biggers
e73828389b
crypto: x86/sha256-mb - fix digest copy in sha256_mb_mgr_get_comp_job_avx2()
commit af839b4e54 upstream.
There is a copy-paste error where sha256_mb_mgr_get_comp_job_avx2()
copies the SHA-256 digest state from sha256_mb_mgr::args::digest to
job_sha256::result_digest. Consequently, the sha256_mb algorithm
sometimes calculates the wrong digest. Fix it.
Reproducer using AF_ALG:
#include <assert.h>
#include <linux/if_alg.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
static const __u8 expected[32] =
"\xad\x7f\xac\xb2\x58\x6f\xc6\xe9\x66\xc0\x04\xd7\xd1\xd1\x6b\x02"
"\x4f\x58\x05\xff\x7c\xb4\x7c\x7a\x85\xda\xbd\x8b\x48\x89\x2c\xa7";
int main()
{
int fd;
struct sockaddr_alg addr = {
.salg_type = "hash",
.salg_name = "sha256_mb",
};
__u8 data[4096] = { 0 };
__u8 digest[32];
int ret;
int i;
fd = socket(AF_ALG, SOCK_SEQPACKET, 0);
bind(fd, (void *)&addr, sizeof(addr));
fork();
fd = accept(fd, 0, 0);
do {
ret = write(fd, data, 4096);
assert(ret == 4096);
ret = read(fd, digest, 32);
assert(ret == 32);
} while (memcmp(digest, expected, 32) == 0);
printf("wrong digest: ");
for (i = 0; i < 32; i++)
printf("%02x", digest[i]);
printf("\n");
}
Output was:
wrong digest: ad7facb2000000000000000000000000ffffffef7cb47c7a85dabd8b48892ca7
Fixes: 172b1d6b5a ("crypto: sha256-mb - fix ctx pointer and digest copy")
Cc: <stable@vger.kernel.org> # v4.8+
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-08-17 21:01:10 +02:00
..
2017-11-06 09:05:03 -08:00
2018-08-17 21:01:10 +02:00
2018-02-16 20:23:02 +01:00
2017-03-24 22:02:55 +08:00
2014-11-24 22:43:57 +08:00
2013-01-20 10:16:47 +11:00
2017-05-23 12:52:05 +08:00
2018-02-03 17:38:50 +01:00
2017-05-18 13:19:55 +08:00
2018-02-03 17:38:49 +01:00
2017-08-04 09:27:15 +08:00
2017-09-20 17:42:31 +08:00
2016-04-13 11:37:40 +02:00
2016-04-13 11:37:40 +02:00
2017-04-05 21:58:37 +08:00
2018-01-17 09:45:29 +01:00
2018-01-17 09:45:29 +01:00
2017-09-20 17:42:31 +08:00
2018-04-08 14:26:32 +02:00
2017-09-20 17:42:32 +08:00
2016-02-17 04:07:51 +08:00
2017-09-20 17:42:33 +08:00
2017-01-13 00:26:46 +08:00
2017-10-12 22:51:16 +08:00
2017-10-12 22:51:16 +08:00
2013-05-30 16:36:23 -07:00
2018-02-16 20:23:00 +01:00
2018-02-16 20:23:00 +01:00
2018-01-17 09:45:29 +01:00
2017-01-23 22:50:29 +08:00
2016-01-30 11:22:17 +01:00
2017-08-04 09:27:15 +08:00
2017-09-20 17:42:34 +08:00
2016-11-28 21:23:20 +08:00
2017-01-23 22:50:29 +08:00
2016-06-23 18:29:53 +08:00
2013-04-25 21:09:05 +08:00
2013-04-25 21:01:51 +08:00
2017-06-19 14:11:54 +08:00
2018-07-17 11:39:31 +02:00
2018-02-16 20:23:00 +01:00
2017-01-23 22:50:29 +08:00
2017-01-23 22:50:29 +08:00
2016-04-13 11:37:39 +02:00
2016-02-17 04:07:51 +08:00
2017-04-05 21:58:37 +08:00
2017-01-23 22:50:29 +08:00
2017-01-23 22:50:29 +08:00
2013-01-20 10:16:50 +11:00
2013-01-20 10:16:50 +11:00
2017-09-20 17:42:34 +08:00
2017-01-23 22:50:29 +08:00
2017-09-20 17:42:35 +08:00
2017-08-09 20:01:37 +08:00
2017-01-23 22:50:29 +08:00
2016-05-31 16:41:46 +08:00
2017-09-20 17:42:36 +08:00
2017-09-20 17:42:36 +08:00
2017-09-20 17:42:37 +08:00
2016-05-31 16:41:46 +08:00
2017-09-20 17:42:37 +08:00
2017-01-23 22:50:29 +08:00
2017-01-23 22:50:29 +08:00
2015-09-24 09:21:20 +02:00
2017-04-05 21:58:37 +08:00
2014-11-24 22:43:57 +08:00
2017-09-20 17:42:38 +08:00
2013-01-20 10:16:51 +11:00
2018-02-25 11:07:49 +01:00
2015-04-01 13:17:39 +02:00