Skip to content

Commit

Permalink
Merge tag 'iomap-5.7-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/…
Browse files Browse the repository at this point in the history
…xfs-linux

Pull iomap fix from Darrick Wong:
 "Hoist the check for an unrepresentable FIBMAP return value into
  ioctl_fibmap.

  The internal kernel function can handle 64-bit values (and is needed
  to fix a regression on ext4 + jbd2). It is only the userspace ioctl
  that is so old that it cannot deal"

* tag 'iomap-5.7-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
  fibmap: Warn and return an error in case of block > INT_MAX
  • Loading branch information
Linus Torvalds committed May 2, 2020
2 parents 29a47f4 + b75dfde commit f66ed1e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 8 additions & 0 deletions fs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ EXPORT_SYMBOL(vfs_ioctl);
static int ioctl_fibmap(struct file *filp, int __user *p)
{
struct inode *inode = file_inode(filp);
struct super_block *sb = inode->i_sb;
int error, ur_block;
sector_t block;

Expand All @@ -71,6 +72,13 @@ static int ioctl_fibmap(struct file *filp, int __user *p)
block = ur_block;
error = bmap(inode, &block);

if (block > INT_MAX) {
error = -ERANGE;
pr_warn_ratelimited("[%s/%d] FS: %s File: %pD4 would truncate fibmap result\n",
current->comm, task_pid_nr(current),
sb->s_id, filp);
}

if (error)
ur_block = 0;
else
Expand Down
5 changes: 1 addition & 4 deletions fs/iomap/fiemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@ iomap_bmap_actor(struct inode *inode, loff_t pos, loff_t length,

if (iomap->type == IOMAP_MAPPED) {
addr = (pos - iomap->offset + iomap->addr) >> inode->i_blkbits;
if (addr > INT_MAX)
WARN(1, "would truncate bmap result\n");
else
*bno = addr;
*bno = addr;
}
return 0;
}
Expand Down

0 comments on commit f66ed1e

Please sign in to comment.