Commit f66ed1eb authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'iomap-5.7-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/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
parents 29a47f45 b75dfde1
...@@ -55,6 +55,7 @@ EXPORT_SYMBOL(vfs_ioctl); ...@@ -55,6 +55,7 @@ EXPORT_SYMBOL(vfs_ioctl);
static int ioctl_fibmap(struct file *filp, int __user *p) static int ioctl_fibmap(struct file *filp, int __user *p)
{ {
struct inode *inode = file_inode(filp); struct inode *inode = file_inode(filp);
struct super_block *sb = inode->i_sb;
int error, ur_block; int error, ur_block;
sector_t block; sector_t block;
...@@ -71,6 +72,13 @@ static int ioctl_fibmap(struct file *filp, int __user *p) ...@@ -71,6 +72,13 @@ static int ioctl_fibmap(struct file *filp, int __user *p)
block = ur_block; block = ur_block;
error = bmap(inode, &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) if (error)
ur_block = 0; ur_block = 0;
else else
......
...@@ -117,9 +117,6 @@ iomap_bmap_actor(struct inode *inode, loff_t pos, loff_t length, ...@@ -117,9 +117,6 @@ iomap_bmap_actor(struct inode *inode, loff_t pos, loff_t length,
if (iomap->type == IOMAP_MAPPED) { if (iomap->type == IOMAP_MAPPED) {
addr = (pos - iomap->offset + iomap->addr) >> inode->i_blkbits; 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; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment