# git rev-parse -q --verify 21d4120ec6f5b5992b01b96ac484701163917b63^{commit} 21d4120ec6f5b5992b01b96ac484701163917b63 already have revision, skipping fetch # git checkout -q -f -B kisskb 21d4120ec6f5b5992b01b96ac484701163917b63 # git clean -qxdf # < git log -1 # commit 21d4120ec6f5b5992b01b96ac484701163917b63 # Author: Eric Biggers # Date: Tue Jul 2 14:17:00 2019 -0700 # # crypto: user - prevent operating on larval algorithms # # Michal Suchanek reported [1] that running the pcrypt_aead01 test from # LTP [2] in a loop and holding Ctrl-C causes a NULL dereference of # alg->cra_users.next in crypto_remove_spawns(), via crypto_del_alg(). # The test repeatedly uses CRYPTO_MSG_NEWALG and CRYPTO_MSG_DELALG. # # The crash occurs when the instance that CRYPTO_MSG_DELALG is trying to # unregister isn't a real registered algorithm, but rather is a "test # larval", which is a special "algorithm" added to the algorithms list # while the real algorithm is still being tested. Larvals don't have # initialized cra_users, so that causes the crash. Normally pcrypt_aead01 # doesn't trigger this because CRYPTO_MSG_NEWALG waits for the algorithm # to be tested; however, CRYPTO_MSG_NEWALG returns early when interrupted. # # Everything else in the "crypto user configuration" API has this same bug # too, i.e. it inappropriately allows operating on larval algorithms # (though it doesn't look like the other cases can cause a crash). # # Fix this by making crypto_alg_match() exclude larval algorithms. # # [1] https://lkml.kernel.org/r/20190625071624.27039-1-msuchanek@suse.de # [2] https://github.com/linux-test-project/ltp/blob/20190517/testcases/kernel/crypto/pcrypt_aead01.c # # Reported-by: Michal Suchanek # Fixes: a38f7907b926 ("crypto: Add userspace configuration API") # Cc: # v3.2+ # Cc: Steffen Klassert # Signed-off-by: Eric Biggers # Signed-off-by: Herbert Xu # < /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/x86_64-linux/bin/x86_64-linux-gcc --version # < /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/x86_64-linux/bin/x86_64-linux-ld --version # < git log --format=%s --max-count=1 21d4120ec6f5b5992b01b96ac484701163917b63 # < make -s -j 120 ARCH=x86_64 O=/kisskb/build/crypto_x86_64-allnoconfig_x86_64-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.1.0-nolibc/x86_64-linux/bin/x86_64-linux- allnoconfig # make -s -j 120 ARCH=x86_64 O=/kisskb/build/crypto_x86_64-allnoconfig_x86_64-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.1.0-nolibc/x86_64-linux/bin/x86_64-linux- Completed OK # rm -rf /kisskb/build/crypto_x86_64-allnoconfig_x86_64-gcc8 # Build took: 0:00:11.907341