Skip to content

Commit f66ed1e

Browse files
committed
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
2 parents 29a47f4 + b75dfde commit f66ed1e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

fs/ioctl.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ EXPORT_SYMBOL(vfs_ioctl);
5555
static int ioctl_fibmap(struct file *filp, int __user *p)
5656
{
5757
struct inode *inode = file_inode(filp);
58+
struct super_block *sb = inode->i_sb;
5859
int error, ur_block;
5960
sector_t block;
6061

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

75+
if (block > INT_MAX) {
76+
error = -ERANGE;
77+
pr_warn_ratelimited("[%s/%d] FS: %s File: %pD4 would truncate fibmap result\n",
78+
current->comm, task_pid_nr(current),
79+
sb->s_id, filp);
80+
}
81+
7482
if (error)
7583
ur_block = 0;
7684
else

fs/iomap/fiemap.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,7 @@ iomap_bmap_actor(struct inode *inode, loff_t pos, loff_t length,
117117

118118
if (iomap->type == IOMAP_MAPPED) {
119119
addr = (pos - iomap->offset + iomap->addr) >> inode->i_blkbits;
120-
if (addr > INT_MAX)
121-
WARN(1, "would truncate bmap result\n");
122-
else
123-
*bno = addr;
120+
*bno = addr;
124121
}
125122
return 0;
126123
}

0 commit comments

Comments
 (0)