Skip to contentSkip to conversation

fs/ecryptfs: fix slab-out-of-bounds read in ecryptfs_verify_auth_tok_from_key

PATCH In review Nguyen Duy Nhat Anh 2 participants 2 messages Sep 17 – Oct 13 Ecrypt file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/ecryptfs: fix slab-out-of-bounds read in ecryptfs_verify_auth_tok_from_key

Add a bounds check in ecryptfs_get_key_payload_data() to ensure the key payload datalen is at least sizeof(struct ecryptfs_auth_tok) before returning the pointer. This prevents out-of-bounds reads when userspace supplies a short payload via add_key().

---
 fs/ecryptfs/ecryptfs_kernel.h | 3 +++
 1 file changed, 3 insertions(+)
fs/ecryptfs/ecryptfs_kernel.h +3 -0
index 58165928ed1e..3baccd4143e8 100644
@@ -124,6 +124,9 @@ ecryptfs_get_key_payload_data(struct key *key)
 	if (!ukp)
 		return ERR_PTR(-EKEYREVOKED);
 
+	if (ukp->datalen < sizeof(struct ecryptfs_auth_tok))
+		return ERR_PTR(-EINVAL);
+
 	return (struct ecryptfs_auth_tok *)ukp->data;
 }
 
Signature · 1 line
2.55.0
maintainer
#1 lore raw
Quoted 4 lines · Nguyen Duy Nhat Anh

Add a bounds check in ecryptfs_get_key_payload_data() to ensure the key payload datalen is at least sizeof(struct ecryptfs_auth_tok) before returning the pointer. This prevents out-of-bounds reads when userspace supplies a short payload via add_key().

Thank you! This has been applied to the next branch of the tyhicks/ecryptfs.git tree.

I added a handful of additional git commit tags, such as:

Fixes 237fead61998 ("[PATCH] ecryptfs: fs/Makefile and fs/Kconfig")

...

You can find a direct link below but please be aware that the commit hash is unstable and, therefore, the URL may not be valid in the future.

[1/1] fs/ecryptfs: fix slab-out-of-bounds read in ecryptfs_verify_auth_tok_from_key

      https://git.kernel.org/tyhicks/ecryptfs/c/5b00bf0f3b7ad05eff79b84e3bacf3f98ac67dc6

Tyler