Discussion:
[PATCH] ecryptfs: Fix memory leakage in keystore.c
Geyslan G. Bem
2013-10-11 19:49:16 UTC
Permalink
In 'decrypt_pki_encrypted_session_key' function:

Initializes 'payload' pointer and releases it on exit.

Signed-off-by: Geyslan G. Bem <***@gmail.com>
---
fs/ecryptfs/keystore.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index 7d52806..4725a07 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -1149,7 +1149,7 @@ decrypt_pki_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
struct ecryptfs_msg_ctx *msg_ctx;
struct ecryptfs_message *msg = NULL;
char *auth_tok_sig;
- char *payload;
+ char *payload = NULL;
size_t payload_len = 0;
int rc;

@@ -1203,6 +1203,7 @@ decrypt_pki_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
}
out:
kfree(msg);
+ kfree(payload);
return rc;
}
--
1.8.4
Tyler Hicks
2013-10-17 01:11:02 UTC
Permalink
Post by Geyslan G. Bem
Initializes 'payload' pointer and releases it on exit.
---
Thanks! This one was easy to verify by auditing the code, but I was also
able to verify the leak with kmemleak.

I've targeted it for stable and pushed it to the eCryptfs next branch.

Tyler
Post by Geyslan G. Bem
fs/ecryptfs/keystore.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index 7d52806..4725a07 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -1149,7 +1149,7 @@ decrypt_pki_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
struct ecryptfs_msg_ctx *msg_ctx;
struct ecryptfs_message *msg = NULL;
char *auth_tok_sig;
- char *payload;
+ char *payload = NULL;
size_t payload_len = 0;
int rc;
@@ -1203,6 +1203,7 @@ decrypt_pki_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
}
kfree(msg);
+ kfree(payload);
return rc;
}
--
1.8.4
Geyslan Gregório Bem
2013-10-17 01:21:46 UTC
Permalink
Post by Tyler Hicks
Post by Geyslan G. Bem
Initializes 'payload' pointer and releases it on exit.
---
Thanks! This one was easy to verify by auditing the code, but I was also
able to verify the leak with kmemleak.
It's a pleasure.
Post by Tyler Hicks
I've targeted it for stable and pushed it to the eCryptfs next branch.
Thank you.
Post by Tyler Hicks
Tyler
Post by Geyslan G. Bem
fs/ecryptfs/keystore.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index 7d52806..4725a07 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -1149,7 +1149,7 @@ decrypt_pki_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
struct ecryptfs_msg_ctx *msg_ctx;
struct ecryptfs_message *msg = NULL;
char *auth_tok_sig;
- char *payload;
+ char *payload = NULL;
size_t payload_len = 0;
int rc;
@@ -1203,6 +1203,7 @@ decrypt_pki_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
}
kfree(msg);
+ kfree(payload);
return rc;
}
--
1.8.4
Loading...