Skip to contentSkip to conversation

isofs: memory leaks when reading corrupted filesystems.

PATCH In review Quentin Casasnovas 2 participants 3 messages Dec 5, 2015 – Dec 9, 2015 Isofs filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 isofs: memory leaks when reading corrupted filesystems.

Vegard and I found that when a directory on isofs is corrupted, we are not releasing the associated buffer_head, leading to a memory leak. This was introduced by:

2deb1acc653c ("isofs: fix access to unallocated memory when reading corrupted filesystem")

This was found by fuzzing.

Cc Jan Kara <[email protected]>
Fixes 2deb1acc653c ("isofs: fix access to unallocated memory when reading...")
---
 fs/isofs/dir.c   | 1 +
 fs/isofs/namei.c | 1 +
 2 files changed, 2 insertions(+)
fs/isofs/dir.c +1 -0
index b943cbd..2e7d74c 100644
@@ -151,6 +151,7 @@ static int do_isofs_readdir(struct inode *inode, struct file *file,
 			printk(KERN_NOTICE "iso9660: Corrupted directory entry"
 			       " in block %lu of inode %lu\n", block,
 			       inode->i_ino);
+			brelse(bh);
 			return -EIO;
 		}
 
fs/isofs/namei.c +1 -0
index 7b543e6..696f255 100644
@@ -101,6 +101,7 @@ isofs_find_entry(struct inode *dir, struct dentry *dentry,
 			printk(KERN_NOTICE "iso9660: Corrupted directory entry"
 			       " in block %lu of inode %lu\n", block,
 			       dir->i_ino);
+			brelse(bh);
 			return 0;
 		}
 
Signature · 1 line
2.4.9
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Quentin Casasnovas

Vegard and I found that when a directory on isofs is corrupted, we are not releasing the associated buffer_head, leading to a memory leak. This was introduced by:

2deb1acc653c ("isofs: fix access to unallocated memory when reading corrupted filesystem")

This was found by fuzzing.

Good catch. Thanks! You can add:

Honza

Quoted 38 lines
Cc Jan Kara <[email protected]>
Fixes 2deb1acc653c ("isofs: fix access to unallocated memory when reading...")
---
 fs/isofs/dir.c   | 1 +
 fs/isofs/namei.c | 1 +
 2 files changed, 2 insertions(+)
fs/isofs/dir.c +1 -0
index b943cbd..2e7d74c 100644
@@ -151,6 +151,7 @@ static int do_isofs_readdir(struct inode *inode, struct file *file,
 			printk(KERN_NOTICE "iso9660: Corrupted directory entry"
 			       " in block %lu of inode %lu\n", block,
 			       inode->i_ino);
+			brelse(bh);
 			return -EIO;
 		}
 
fs/isofs/namei.c +1 -0
index 7b543e6..696f255 100644
@@ -101,6 +101,7 @@ isofs_find_entry(struct inode *dir, struct dentry *dentry,
 			printk(KERN_NOTICE "iso9660: Corrupted directory entry"
 			       " in block %lu of inode %lu\n", block,
 			       dir->i_ino);
+			brelse(bh);
 			return 0;
 		}
 
Signature · 1 line
2.4.9
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
maintainer
#2 lore raw
In reply to Quentin Casasnovas
Quoted 6 lines · Quentin Casasnovas

Vegard and I found that when a directory on isofs is corrupted, we are not releasing the associated buffer_head, leading to a memory leak. This was introduced by:

2deb1acc653c ("isofs: fix access to unallocated memory when reading corrupted filesystem")

Quoted 8 lines

This was found by fuzzing.

Cc Jan Kara <[email protected]>
Fixes 2deb1acc653c ("isofs: fix access to unallocated memory when reading...")

BTW, please CC Andrew Morton since he usually merges isofs patches. Thanks!

Honza

Quoted 32 lines
---
 fs/isofs/dir.c   | 1 +
 fs/isofs/namei.c | 1 +
 2 files changed, 2 insertions(+)
fs/isofs/dir.c +1 -0
index b943cbd..2e7d74c 100644
@@ -151,6 +151,7 @@ static int do_isofs_readdir(struct inode *inode, struct file *file,
 			printk(KERN_NOTICE "iso9660: Corrupted directory entry"
 			       " in block %lu of inode %lu\n", block,
 			       inode->i_ino);
+			brelse(bh);
 			return -EIO;
 		}
 
fs/isofs/namei.c +1 -0
index 7b543e6..696f255 100644
@@ -101,6 +101,7 @@ isofs_find_entry(struct inode *dir, struct dentry *dentry,
 			printk(KERN_NOTICE "iso9660: Corrupted directory entry"
 			       " in block %lu of inode %lu\n", block,
 			       dir->i_ino);
+			brelse(bh);
 			return 0;
 		}
 
Signature · 1 line
2.4.9
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR