summaryrefslogtreecommitdiffstats
path: root/fs/ecryptfs
diff options
context:
space:
mode:
authorAditya Pakki <pakki001@umn.edu>2020-02-14 12:21:01 -0600
committerTyler Hicks <code@tyhicks.com>2020-02-14 20:07:46 +0000
commit2c2a7552dd6465e8fde6bc9cccf8d66ed1c1eb72 (patch)
tree5ce545b447440ebe23331c9abd06c304631a4a4e /fs/ecryptfs
parentf8e48a8408f5e23dd514916fda128a87e34f8ffd (diff)
downloadlinux-2c2a7552dd6465e8fde6bc9cccf8d66ed1c1eb72.tar.gz
linux-2c2a7552dd6465e8fde6bc9cccf8d66ed1c1eb72.tar.bz2
linux-2c2a7552dd6465e8fde6bc9cccf8d66ed1c1eb72.zip
ecryptfs: replace BUG_ON with error handling code
In crypt_scatterlist, if the crypt_stat argument is not set up correctly, the kernel crashes. Instead, by returning an error code upstream, the error is handled safely. The issue is detected via a static analysis tool written by us. Fixes: 237fead619984 (ecryptfs: fs/Makefile and fs/Kconfig) Signed-off-by: Aditya Pakki <pakki001@umn.edu> Signed-off-by: Tyler Hicks <code@tyhicks.com>
Diffstat (limited to 'fs/ecryptfs')
-rw-r--r--fs/ecryptfs/crypto.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index f91db24bbf3b..a064b408d841 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -311,8 +311,10 @@ static int crypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
struct extent_crypt_result ecr;
int rc = 0;
- BUG_ON(!crypt_stat || !crypt_stat->tfm
- || !(crypt_stat->flags & ECRYPTFS_STRUCT_INITIALIZED));
+ if (!crypt_stat || !crypt_stat->tfm
+ || !(crypt_stat->flags & ECRYPTFS_STRUCT_INITIALIZED))
+ return -EINVAL;
+
if (unlikely(ecryptfs_verbosity > 0)) {
ecryptfs_printk(KERN_DEBUG, "Key size [%zd]; key:\n",
crypt_stat->key_size);