* [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
* Re: [PATCH] ecryptfs: replace BUG_ON with error handling code
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
1 sibling, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2019-12-15 21:20 UTC (permalink / raw)
To: Aditya Pakki, ecryptfs; +Cc: linux-kernel, Kangjie Lu, Tyler Hicks
> In crypt_scatterlist, if the crypt_stat argument is not set up
> correctly, we avoid crashing, by returning the error upstream.
Can an other change description be more helpful here?
> This patch performs the fix.
Please replace this sentence by the tag “Fixes”.
Regards,
Markus
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ecryptfs: replace BUG_ON with error handling code
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
1 sibling, 1 reply; 4+ messages in thread
From: Tyler Hicks @ 2020-02-14 17:38 UTC (permalink / raw)
To: Aditya Pakki; +Cc: kjlu, ecryptfs, linux-kernel
On 2019-12-15 11:24:04, Aditya Pakki wrote:
> 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>
Hi Aditya - I wanted to check in to see if you are able to submit a new
revision taking into account the feedback from Markus.
Also, I'm curious if you've been able to hit this BUG_ON() or if you are
just being proactive in cleaning up this function?
Let me know if I can help you prepare a v2 of this patch. Thanks!
Tyler
> ---
> 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 [flat|nested] 4+ messages in thread
* Re: [PATCH] ecryptfs: replace BUG_ON with error handling code
2020-02-14 17:38 ` Tyler Hicks
@ 2020-02-14 18:01 ` Aditya Pakki
0 siblings, 0 replies; 4+ messages in thread
From: Aditya Pakki @ 2020-02-14 18:01 UTC (permalink / raw)
To: Tyler Hicks; +Cc: kjlu, ecryptfs, linux-kernel
On 2/14/20 11:38 AM, Tyler Hicks wrote:
> On 2019-12-15 11:24:04, Aditya Pakki wrote:
>> 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>
>
> Hi Aditya - I wanted to check in to see if you are able to submit a new
> revision taking into account the feedback from Markus.
>
> Also, I'm curious if you've been able to hit this BUG_ON() or if you are
> just being proactive in cleaning up this function?
>
> Let me know if I can help you prepare a v2 of this patch. Thanks!
>
> Tyler
>
>> ---
>> 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
>>
The bug was detected by a static analysis tool and have not encountered it. I can send a v2 right away.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-02-14 18:02 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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).