All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ecryptfs: fix a memory leak bug
@ 2019-08-20  5:16 ` Wenwen Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Wenwen Wang @ 2019-08-20  5:16 UTC (permalink / raw)
  To: Wenwen Wang; +Cc: Tyler Hicks, open list:ECRYPT FILE SYSTEM, open list

In parse_tag_1_packet(), if tag 1 packet contains a key larger than
ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES, no cleanup is executed, leading to a
memory leak on the allocated 'auth_tok_list_item'. To fix this issue, go to
the label 'out_free' to perform the cleanup work.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
---
 fs/ecryptfs/keystore.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index 216fbe6..4dc0963 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -1304,7 +1304,7 @@ parse_tag_1_packet(struct ecryptfs_crypt_stat *crypt_stat,
 		printk(KERN_WARNING "Tag 1 packet contains key larger "
 		       "than ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES\n");
 		rc = -EINVAL;
-		goto out;
+		goto out_free;
 	}
 	memcpy((*new_auth_tok)->session_key.encrypted_key,
 	       &data[(*packet_size)], (body_size - (ECRYPTFS_SIG_SIZE + 2)));
-- 
2.7.4


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

* [PATCH] ecryptfs: fix a memory leak bug
@ 2019-08-20  5:16 ` Wenwen Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Wenwen Wang @ 2019-08-20  5:16 UTC (permalink / raw)
  To: Wenwen Wang; +Cc: Tyler Hicks, open list:ECRYPT FILE SYSTEM, open list

In parse_tag_1_packet(), if tag 1 packet contains a key larger than
ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES, no cleanup is executed, leading to a
memory leak on the allocated 'auth_tok_list_item'. To fix this issue, go to
the label 'out_free' to perform the cleanup work.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
---
 fs/ecryptfs/keystore.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index 216fbe6..4dc0963 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -1304,7 +1304,7 @@ parse_tag_1_packet(struct ecryptfs_crypt_stat *crypt_stat,
 		printk(KERN_WARNING "Tag 1 packet contains key larger "
 		       "than ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES\n");
 		rc = -EINVAL;
-		goto out;
+		goto out_free;
 	}
 	memcpy((*new_auth_tok)->session_key.encrypted_key,
 	       &data[(*packet_size)], (body_size - (ECRYPTFS_SIG_SIZE + 2)));
-- 
2.7.4


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

* Re: [PATCH] ecryptfs: fix a memory leak bug
  2019-08-20  5:16 ` Wenwen Wang
  (?)
@ 2019-08-20  7:10 ` Tyler Hicks
  -1 siblings, 0 replies; 6+ messages in thread
From: Tyler Hicks @ 2019-08-20  7:10 UTC (permalink / raw)
  To: Wenwen Wang; +Cc: open list:ECRYPT FILE SYSTEM, open list

On 2019-08-20 00:16:40, Wenwen Wang wrote:
> In parse_tag_1_packet(), if tag 1 packet contains a key larger than
> ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES, no cleanup is executed, leading to a
> memory leak on the allocated 'auth_tok_list_item'. To fix this issue, go to
> the label 'out_free' to perform the cleanup work.
> 
> Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>

Thanks for the patch!

I added the following tags to the commit message:

 Cc: stable@vger.kernel.org
 Fixes: dddfa461fc89 ("[PATCH] eCryptfs: Public key; packet management")

I also added the function name to the commit subject so that it was
unique from your other fix.

I've pushed the fix to the eCryptfs next branch and I'll submit a pull
request for inclusion soon.

Tyler

> ---
>  fs/ecryptfs/keystore.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
> index 216fbe6..4dc0963 100644
> --- a/fs/ecryptfs/keystore.c
> +++ b/fs/ecryptfs/keystore.c
> @@ -1304,7 +1304,7 @@ parse_tag_1_packet(struct ecryptfs_crypt_stat *crypt_stat,
>  		printk(KERN_WARNING "Tag 1 packet contains key larger "
>  		       "than ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES\n");
>  		rc = -EINVAL;
> -		goto out;
> +		goto out_free;
>  	}
>  	memcpy((*new_auth_tok)->session_key.encrypted_key,
>  	       &data[(*packet_size)], (body_size - (ECRYPTFS_SIG_SIZE + 2)));
> -- 
> 2.7.4
> 

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

* Re: [PATCH] ecryptfs: fix a memory leak bug
  2019-08-20  5:33 ` Wenwen Wang
  (?)
@ 2019-08-20  7:11 ` Tyler Hicks
  -1 siblings, 0 replies; 6+ messages in thread
From: Tyler Hicks @ 2019-08-20  7:11 UTC (permalink / raw)
  To: Wenwen Wang; +Cc: open list:ECRYPT FILE SYSTEM, open list

On 2019-08-20 00:33:54, Wenwen Wang wrote:
> In ecryptfs_init_messaging(), if the allocation for 'ecryptfs_msg_ctx_arr'
> fails, the previously allocated 'ecryptfs_daemon_hash' is not deallocated,
> leading to a memory leak bug. To fix this issue, free
> 'ecryptfs_daemon_hash' before returning the error.
> 
> Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>

Thanks for the patch!

I added the following tags to the commit message:

 Cc: stable@vger.kernel.org
 Fixes: 88b4a07e6610 ("[PATCH] eCryptfs: Public key transport mechanism")

I also added the function name to the commit subject so that it was
unique from your other fix.

I've pushed the fix to the eCryptfs next branch and I'll submit a pull
request for inclusion soon.

Tyler

> ---
>  fs/ecryptfs/messaging.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/ecryptfs/messaging.c b/fs/ecryptfs/messaging.c
> index d668e60..c05ca39 100644
> --- a/fs/ecryptfs/messaging.c
> +++ b/fs/ecryptfs/messaging.c
> @@ -379,6 +379,7 @@ int __init ecryptfs_init_messaging(void)
>  					* ecryptfs_message_buf_len),
>  				       GFP_KERNEL);
>  	if (!ecryptfs_msg_ctx_arr) {
> +		kfree(ecryptfs_daemon_hash);
>  		rc = -ENOMEM;
>  		goto out;
>  	}
> -- 
> 2.7.4
> 

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

* [PATCH] ecryptfs: fix a memory leak bug
@ 2019-08-20  5:33 ` Wenwen Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Wenwen Wang @ 2019-08-20  5:33 UTC (permalink / raw)
  To: Wenwen Wang; +Cc: Tyler Hicks, open list:ECRYPT FILE SYSTEM, open list

In ecryptfs_init_messaging(), if the allocation for 'ecryptfs_msg_ctx_arr'
fails, the previously allocated 'ecryptfs_daemon_hash' is not deallocated,
leading to a memory leak bug. To fix this issue, free
'ecryptfs_daemon_hash' before returning the error.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
---
 fs/ecryptfs/messaging.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/ecryptfs/messaging.c b/fs/ecryptfs/messaging.c
index d668e60..c05ca39 100644
--- a/fs/ecryptfs/messaging.c
+++ b/fs/ecryptfs/messaging.c
@@ -379,6 +379,7 @@ int __init ecryptfs_init_messaging(void)
 					* ecryptfs_message_buf_len),
 				       GFP_KERNEL);
 	if (!ecryptfs_msg_ctx_arr) {
+		kfree(ecryptfs_daemon_hash);
 		rc = -ENOMEM;
 		goto out;
 	}
-- 
2.7.4


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

* [PATCH] ecryptfs: fix a memory leak bug
@ 2019-08-20  5:33 ` Wenwen Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Wenwen Wang @ 2019-08-20  5:33 UTC (permalink / raw)
  To: Wenwen Wang; +Cc: Tyler Hicks, open list:ECRYPT FILE SYSTEM, open list

In ecryptfs_init_messaging(), if the allocation for 'ecryptfs_msg_ctx_arr'
fails, the previously allocated 'ecryptfs_daemon_hash' is not deallocated,
leading to a memory leak bug. To fix this issue, free
'ecryptfs_daemon_hash' before returning the error.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
---
 fs/ecryptfs/messaging.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/ecryptfs/messaging.c b/fs/ecryptfs/messaging.c
index d668e60..c05ca39 100644
--- a/fs/ecryptfs/messaging.c
+++ b/fs/ecryptfs/messaging.c
@@ -379,6 +379,7 @@ int __init ecryptfs_init_messaging(void)
 					* ecryptfs_message_buf_len),
 				       GFP_KERNEL);
 	if (!ecryptfs_msg_ctx_arr) {
+		kfree(ecryptfs_daemon_hash);
 		rc = -ENOMEM;
 		goto out;
 	}
-- 
2.7.4


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

end of thread, other threads:[~2019-08-20  7:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-20  5:16 [PATCH] ecryptfs: fix a memory leak bug Wenwen Wang
2019-08-20  5:16 ` Wenwen Wang
2019-08-20  7:10 ` Tyler Hicks
2019-08-20  5:33 Wenwen Wang
2019-08-20  5:33 ` Wenwen Wang
2019-08-20  7:11 ` Tyler Hicks

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.