Skip to contentSkip to conversation

ecryptfs: keystore: Fix a buffer overrun in write_tag_66_packet()

PATCH New Yiyuan Guo 1 participant 1 message Jun 30, 2023 Ecrypt file system

lore
Share & tools
lore

Yiyuan Guo

author
#0 lore raw

PATCH 1/1 ecryptfs: keystore: Fix a buffer overrun in write_tag_66_packet()

The encrypted key of a TAG 66 Packet includes 1 byte cipher code and 2 byte checksum, but the allocation size data_len ignores the extra 3 bytes. Fix the allocation size to avoid buffer overrun.

---
 fs/ecryptfs/keystore.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ecryptfs/keystore.c +1 -1
index 2452d6fd7062..5cab0b800a03 100644
@@ -302,7 +302,7 @@ write_tag_66_packet(char *signature, u8 cipher_code,
 	 *         | File Encryption Key Size | 1 or 2 bytes |
 	 *         | File Encryption Key      | arbitrary    |
 	 */
-	data_len = (5 + ECRYPTFS_SIG_SIZE_HEX + crypt_stat->key_size);
+	data_len = (5 + ECRYPTFS_SIG_SIZE_HEX + crypt_stat->key_size + 3);
 	*packet = kmalloc(data_len, GFP_KERNEL);
 	message = *packet;
 	if (!message) {
Signature · 1 line
2.25.1