All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ecryptfs: replace BUG_ON with error handling code
@ 2019-12-15 17:24 Aditya Pakki
  2019-12-15 21:20 ` Markus Elfring
  2020-02-14 17:38 ` Tyler Hicks
  0 siblings, 2 replies; 4+ messages in thread
From: Aditya Pakki @ 2019-12-15 17:24 UTC (permalink / raw)
  To: pakki001; +Cc: kjlu, Tyler Hicks, ecryptfs, linux-kernel

In crypt_scatterlist, if the crypt_stat argument is not set up
correctly, we avoid crashing, by returning the error upstream.
This patch performs the fix.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
 fs/ecryptfs/crypto.c | 6 ++++--
 1 file 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);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-02-14 18:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-15 17:24 [PATCH] ecryptfs: replace BUG_ON with error handling code Aditya Pakki
2019-12-15 21:20 ` Markus Elfring
2020-02-14 17:38 ` Tyler Hicks
2020-02-14 18:01   ` Aditya Pakki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.