Skip to contentSkip to conversation

ecryptfs: Fix memory leakage in keystore.c

PATCH In review Geyslan G. Bem 2 participants 3 messages Oct 11, 2013 – Oct 17, 2013 Ecrypt file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ecryptfs: Fix memory leakage in keystore.c

In 'decrypt_pki_encrypted_session_key' function:

Initializes 'payload' pointer and releases it on exit.

---
 fs/ecryptfs/keystore.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ecryptfs/keystore.c +2 -1
index 7d52806..4725a07 100644
@@ -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;
 }
 
Signature · 1 line
1.8.4
#1 lore raw
Quoted 6 lines · Geyslan G. Bem

In 'decrypt_pki_encrypted_session_key' function:

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

Quoted 27 lines
 fs/ecryptfs/keystore.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ecryptfs/keystore.c +2 -1
index 7d52806..4725a07 100644
@@ -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;
 }
 
Signature · 1 line
1.8.4
#2 lore raw

2013/10/16 Tyler Hicks <[email protected]>:

Quoted 10 lines · Geyslan G. Bem
Quoted 6 lines

In 'decrypt_pki_encrypted_session_key' function:

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.

Quoted 3 lines

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

Thank you.

Quoted 29 lines

Tyler

Quoted 27 lines
 fs/ecryptfs/keystore.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ecryptfs/keystore.c +2 -2
index 7d52806..4725a07 100644
@@ -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