[PATCH v3 2/2] ecryptfs: bound session_key_encryption_key_bytes in auth tok
From: Adriano Cordova
Date: Fri Oct 16 2026 - 13:08:06 EST
Let ecryptfs_verify_auth_tok_from_key() validate the password's
session_key_encryption_key_bytes length. When it is larger than
ECRYPTFS_MAX_KEY_BYTES, md5() reads past session_key_encryption_key[].
Reject such auth toks.
Fixes: 9c79f34f7ee7 ("eCryptfs: Filename Encryption: Tag 70 packets")
Cc: <stable@xxxxxxxxxxxxxxx>
Reported-by: syzbot+03c68e42ce4b33f7ce9b@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=03c68e42ce4b33f7ce9b
Tested-by: syzbot+03c68e42ce4b33f7ce9b@xxxxxxxxxxxxxxxxxxxxxxxxx
Signed-off-by: Adriano Cordova <adrianox@xxxxxxxxx>
---
Changes in v3:
- Split the v2 patch.
- Change the Link: tag to Closes:.
- Remove Nguyen Duy Nhat Anh change and its Reported-by tag.
fs/ecryptfs/keystore.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index 51651314b7a6..c2ba230c71fd 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -477,6 +477,13 @@ ecryptfs_verify_auth_tok_from_key(struct key *auth_tok_key,
rc = -EINVAL;
goto out;
}
+ if ((*auth_tok)->token_type == ECRYPTFS_PASSWORD &&
+ (*auth_tok)->token.password.session_key_encryption_key_bytes >
+ ECRYPTFS_MAX_KEY_BYTES) {
+ printk(KERN_ERR "Invalid password auth_tok session key size\n");
+ rc = -EINVAL;
+ goto out;
+ }
out:
return rc;
}
--
2.51.0