Skip to content

Commit f151cd2

Browse files
rcvalletorvalds
authored andcommitted
eCryptfs: parse_tag_3_packet check tag 3 packet encrypted key size
The parse_tag_3_packet function does not check if the tag 3 packet contains a encrypted key size larger than ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES. Signed-off-by: Ramon de Carvalho Valle <ramon@risesecurity.org> [tyhicks@linux.vnet.ibm.com: Added printk newline and changed goto to out_free] Signed-off-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com> Cc: stable@kernel.org (2.6.27 and 30) Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 6352a29 commit f151cd2

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎fs/ecryptfs/keystore.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,13 @@ parse_tag_3_packet(struct ecryptfs_crypt_stat *crypt_stat,
13031303
}
13041304
(*new_auth_tok)->session_key.encrypted_key_size =
13051305
(body_size - (ECRYPTFS_SALT_SIZE + 5));
1306+
if ((*new_auth_tok)->session_key.encrypted_key_size
1307+
> ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES) {
1308+
printk(KERN_WARNING "Tag 3 packet contains key larger "
1309+
"than ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES\n");
1310+
rc = -EINVAL;
1311+
goto out_free;
1312+
}
13061313
if (unlikely(data[(*packet_size)++] != 0x04)) {
13071314
printk(KERN_WARNING "Unknown version number [%d]\n",
13081315
data[(*packet_size) - 1]);

0 commit comments

Comments
 (0)