Skip to content

Commit aac4e41

Browse files
naotaChristoph Hellwig
authored andcommitted
hfsplus: Add additional range check to handle on-disk corruptions
'recoff' is read from disk and used for an argument to memcpy, so if the value read from disk is larger than the page size, it result to "general protection fault". This patch add additional range check for the value, so that disk fuzz won't cause such fault. Signed-off-by: Naohiro Aota <naota@elisp.net> Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent dd7f3d5 commit aac4e41

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎fs/hfsplus/brec.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ u16 hfs_brec_keylen(struct hfs_bnode *node, u16 rec)
4343
node->tree->node_size - (rec + 1) * 2);
4444
if (!recoff)
4545
return 0;
46+
if (recoff > node->tree->node_size - 2) {
47+
printk(KERN_ERR "hfs: recoff %d too large\n", recoff);
48+
return 0;
49+
}
4650

4751
retval = hfs_bnode_read_u16(node, recoff) + 2;
4852
if (retval > node->tree->max_key_len + 2) {

0 commit comments

Comments
 (0)