Skip to content

Commit

Permalink
fs/ntfs3: Fix integer overflow in ni_fiemap with fiemap_prep()
Browse files Browse the repository at this point in the history
Use fiemap_prep() to check valid flags. It also shrink request scope
(@len) to what the fs can actually handle.

This address following Smatch static checker warning:
	fs/ntfs3/frecord.c:1894 ni_fiemap()
	warn: potential integer overflow from user 'vbo + len'

Because fiemap_prep() shrinks @len this cannot happened anymore.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: lore.kernel.org/ntfs3/20210825080440.GA17407@kili/

Fixes: 4342306 ("fs/ntfs3: Add file operations and implementation")
Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
  • Loading branch information
teksturi authored and aalexandrovich committed Sep 2, 2021
1 parent d362446 commit d4e8e13
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/ntfs3/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1212,8 +1212,9 @@ int ntfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
int err;
struct ntfs_inode *ni = ntfs_i(inode);

if (fieinfo->fi_flags & FIEMAP_FLAG_XATTR)
return -EOPNOTSUPP;
err = fiemap_prep(inode, fieinfo, start, &len, ~FIEMAP_FLAG_XATTR);
if (err)
return err;

ni_lock(ni);

Expand Down

0 comments on commit d4e8e13

Please sign in to comment.