Skip to contentSkip to conversation

udf: NULL dereference at udf_symlink() on error

PATCH In review Changwoo Min 2 participants 2 messages Mar 23, 2015 – Apr 1, 2015 UDF filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 udf: NULL dereference at udf_symlink() on error

There is no check for udf_tgetblk(), which could return NULL, in udf_symlink(). So there is a possibility of returning NULL under heavy memory pressure and possibility of NULL dereference.

---
 fs/udf/namei.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/udf/namei.c +4 -0
index 33b246b..ed2f221 100644
@@ -902,6 +902,10 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
 				iinfo->i_location.partitionReferenceNum,
 				0);
 		epos.bh = udf_tgetblk(sb, block);
+		if (!epos.bh) {
+			err = -ENOMEM;
+			goto out_no_entry;
+		}
 		lock_buffer(epos.bh);
 		memset(epos.bh->b_data, 0x00, bsize);
 		set_buffer_uptodate(epos.bh);
Signature · 1 line
1.9.1
#1 lore raw
Quoted 14 lines · Changwoo Min

There is no check for udf_tgetblk(), which could return NULL, in udf_symlink(). So there is a possibility of returning NULL under heavy memory pressure and possibility of NULL dereference.

---
 fs/udf/namei.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/udf/namei.c +0 -0
index 33b246b..ed2f221 100644

fs/udf/namei.c static int udf_symlink(struct inode *dir, struct dentry *dentry, · line 906

Quoted 5 lines
fs/udf/namei.c +2 -0
@@ -902,6 +902,10 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
 				iinfo->i_location.partitionReferenceNum,
 				0);
 		epos.bh = udf_tgetblk(sb, block);
+		if (!epos.bh) {
+			err = -ENOMEM;

This should be -EIO as per our discussion at the previous patch.
Otherwise I agree.

Honza

Quoted 8 lines
fs/udf/namei.c +2 -0
+			goto out_no_entry;
+		}
 		lock_buffer(epos.bh);
 		memset(epos.bh->b_data, 0x00, bsize);
 		set_buffer_uptodate(epos.bh);
Signature · 1 line
1.9.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR