linux-stable/arch
Eric Biggers e87485a554 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 20:59:29 +02:00
..
alpha locking/xchg/alpha: Fix xchg() and cmpxchg() memory ordering bugs 2018-05-30 07:50:30 +02:00
arc ARC: configs: Remove CONFIG_INITRAMFS_SOURCE from defconfigs 2018-07-25 11:23:59 +02:00
arm ARM: dts: imx6sx: fix irq for pcie bridge 2018-08-15 18:14:43 +02:00
arm64 arm64: defconfig: Enable Rockchip io-domain driver 2018-08-03 07:55:24 +02:00
avr32
blackfin pinctrl: adi2: Fix Kconfig build problem 2017-12-20 10:07:32 +01:00
c6x
cris
frv futex: Remove duplicated code and fix undefined behaviour 2018-05-19 10:27:00 +02:00
h8300
hexagon futex: Remove duplicated code and fix undefined behaviour 2018-05-19 10:27:00 +02:00
ia64 ia64/err-inject: Use get_user_pages_fast() 2018-05-30 07:50:34 +02:00
m32r
m68k m68k/mm: Adjust VM area to be unmapped by gap size for __iounmap() 2018-07-03 11:23:05 +02:00
metag metag/uaccess: Check access_ok in strncpy_from_user 2017-05-25 15:44:46 +02:00
microblaze microblaze: Fix simpleImage format generation 2018-08-03 07:55:25 +02:00
mips MIPS: Fix off-by-one in pci_resource_to_user() 2018-07-28 07:49:11 +02:00
mn10300 mn10300/misalignment: Use SIGSEGV SEGV_MAPERR to report a failed user copy 2018-02-17 13:21:20 +01:00
nios2
openrisc signal/openrisc: Fix do_unaligned_access to send the proper signal 2018-02-17 13:21:19 +01:00
parisc parisc: Define mb() and add memory barriers to assembler unlock sequences 2018-08-15 18:14:41 +02:00
powerpc powerpc/embedded6xx/hlwd-pic: Prevent interrupts from being handled by Starlet 2018-08-03 07:55:21 +02:00
s390 perf: fix invalid bit in diagnostic entry 2018-08-03 07:55:23 +02:00
score
sh sh: fix debug trap failure to process signals before return to user 2018-05-30 07:50:39 +02:00
sparc sparc64: Don't clibber fixed registers in __multi4. 2018-06-06 16:44:39 +02:00
tile futex: Remove duplicated code and fix undefined behaviour 2018-05-19 10:27:00 +02:00
um um: Use POSIX ucontext_t instead of struct ucontext 2018-04-24 09:34:13 +02:00
unicore32
x86 crypto: x86/sha256-mb - fix digest copy in sha256_mb_mgr_get_comp_job_avx2() 2018-08-17 20:59:29 +02:00
xtensa signal/xtensa: Consistenly use SIGBUS in do_unaligned_user 2018-07-03 11:23:06 +02:00
.gitignore
Kconfig cpu/hotplug: Provide knobs to control SMT 2018-08-15 18:14:46 +02:00