Commit e19f1734 authored by Aditya Pakki's avatar Aditya Pakki Committed by Kelsey Skunberg

ecryptfs: replace BUG_ON with error handling code

BugLink: https://bugs.launchpad.net/bugs/1868627

commit 2c2a7552 upstream.

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: 237fead6 (ecryptfs: fs/Makefile and fs/Kconfig)
Signed-off-by: default avatarAditya Pakki <pakki001@umn.edu>
Signed-off-by: default avatarTyler Hicks <code@tyhicks.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: default avatarKelsey Skunberg <kelsey.skunberg@canonical.com>
parent c1aaf6c2
...@@ -346,8 +346,10 @@ static int crypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat, ...@@ -346,8 +346,10 @@ static int crypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
struct extent_crypt_result ecr; struct extent_crypt_result ecr;
int rc = 0; int rc = 0;
BUG_ON(!crypt_stat || !crypt_stat->tfm if (!crypt_stat || !crypt_stat->tfm
|| !(crypt_stat->flags & ECRYPTFS_STRUCT_INITIALIZED)); || !(crypt_stat->flags & ECRYPTFS_STRUCT_INITIALIZED))
return -EINVAL;
if (unlikely(ecryptfs_verbosity > 0)) { if (unlikely(ecryptfs_verbosity > 0)) {
ecryptfs_printk(KERN_DEBUG, "Key size [%zd]; key:\n", ecryptfs_printk(KERN_DEBUG, "Key size [%zd]; key:\n",
crypt_stat->key_size); crypt_stat->key_size);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment