Skip to contentSkip to conversation

fs/ntfs3: delete duplicate condition in ntfs_read_mft()

PATCH In review Dan Carpenter 2 participants 2 messages Oct 15, 2022 – Nov 12, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/ntfs3: delete duplicate condition in ntfs_read_mft()

There were two patches which addressed the same bug and added the same condition:

commit 6db620863f85 ("fs/ntfs3: Validate data run offset") commit 887bfc546097 ("fs/ntfs3: Fix slab-out-of-bounds read in run_unpack")

Delete one condition.

---
I deleted this one because it was further away from the "roff = " assignement.

 fs/ntfs3/inode.c | 6 ------
 1 file changed, 6 deletions(-)
fs/ntfs3/inode.c +0 -6
index a31474d697e0..e6143da5b4d6 100644
@@ -374,12 +374,6 @@ static struct inode *ntfs_read_mft(struct inode *inode,
 
 	t64 = le64_to_cpu(attr->nres.svcn);
 
-	/* offset to packed runs is out-of-bounds */
-	if (roff > asize) {
-		err = -EINVAL;
-		goto out;
-	}
-
 	err = run_unpack_ex(run, sbi, ino, t64, le64_to_cpu(attr->nres.evcn),
 			    t64, Add2Ptr(attr, roff), asize - roff);
 	if (err < 0)
Signature · 1 line
2.35.1
#1 lore raw
Quoted 23 lines · Dan Carpenter

There were two patches which addressed the same bug and added the same condition:

commit 6db620863f85 ("fs/ntfs3: Validate data run offset") commit 887bfc546097 ("fs/ntfs3: Fix slab-out-of-bounds read in run_unpack")

Delete one condition.

---
I deleted this one because it was further away from the "roff = " assignement.

  fs/ntfs3/inode.c | 6 ------
  1 file changed, 6 deletions(-)
fs/ntfs3/inode.c +0 -0
index a31474d697e0..e6143da5b4d6 100644
@@ -374,12 +374,6 @@ static struct inode *ntfs_read_mft(struct inode *inode,
 
  	t64 = le64_to_cpu(attr->nres.svcn);

fs/ntfs3/inode.c static struct inode *ntfs_read_mft(struct inode *inode, · line 379

Quoted 10 lines
fs/ntfs3/inode.c +0 -6
 
-	/* offset to packed runs is out-of-bounds */
-	if (roff > asize) {
-		err = -EINVAL;
-		goto out;
-	}
-
  	err = run_unpack_ex(run, sbi, ino, t64, le64_to_cpu(attr->nres.evcn),
  			    t64, Add2Ptr(attr, roff), asize - roff);
  	if (err < 0)

I missed this situation when applying patches.
Thanks for catching this.