summaryrefslogtreecommitdiff
path: root/crypto/rsa_helper.c
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2018-07-23 10:54:57 -0700
committerHerbert Xu <herbert@gondor.apana.org.au>2018-08-03 18:06:04 +0800
commit8e5dea859c5db92df36d78165c9ead4acd09ba58 (patch)
treef1b6c29a3f8158768c50f60a01508cf1b756ec36 /crypto/rsa_helper.c
parent559ed5ac09f32db52562c1d1f525cc471cdde441 (diff)
downloadlinux-crypto-8e5dea859c5db92df36d78165c9ead4acd09ba58.tar.gz
linux-crypto-8e5dea859c5db92df36d78165c9ead4acd09ba58.zip
crypto: blkcipher - fix crash flushing dcache in error path
Like the skcipher_walk case: scatterwalk_done() is only meant to be called after a nonzero number of bytes have been processed, since scatterwalk_pagedone() will flush the dcache of the *previous* page. But in the error case of blkcipher_walk_done(), e.g. if the input wasn't an integer number of blocks, scatterwalk_done() was actually called after advancing 0 bytes. This caused a crash ("BUG: unable to handle kernel paging request") during '!PageSlab(page)' on architectures like arm and arm64 that define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE, provided that the input was page-aligned as in that case walk->offset == 0. Fix it by reorganizing blkcipher_walk_done() to skip the scatterwalk_advance() and scatterwalk_done() if an error has occurred. This bug was found by syzkaller fuzzing. Reproducer, assuming ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE: #include <linux/if_alg.h> #include <sys/socket.h> #include <unistd.h> int main() { struct sockaddr_alg addr = { .salg_type = "skcipher", .salg_name = "ecb(aes-generic)", }; char buffer[4096] __attribute__((aligned(4096))) = { 0 }; int fd; fd = socket(AF_ALG, SOCK_SEQPACKET, 0); bind(fd, (void *)&addr, sizeof(addr)); setsockopt(fd, SOL_ALG, ALG_SET_KEY, buffer, 16); fd = accept(fd, NULL, NULL); write(fd, buffer, 15); read(fd, buffer, 15); } Reported-by: Liu Chao <liuchao741@huawei.com> Fixes: 61cea2599a20 ("[CRYPTO] cipher: Added block cipher type") Cc: <stable@vger.kernel.org> # v2.6.19+ Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/rsa_helper.c')
0 files changed, 0 insertions, 0 deletions