Skip to content

Commit 324282c

Browse files
cmaiolinoAl Viro
authored andcommitted
fibmap: Reject negative block numbers
FIBMAP receives an integer from userspace which is then implicitly converted into sector_t to be passed to bmap(). No check is made to ensure userspace didn't send a negative block number, which can end up in an underflow, and returning to userspace a corrupted block address. As a side-effect, the underflow caused by a negative block here, will trigger the WARN() in iomap_bmap_actor(), which is how this issue was first discovered. Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 0d89fda commit 324282c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/ioctl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ static int ioctl_fibmap(struct file *filp, int __user *p)
6565
if (error)
6666
return error;
6767

68+
if (ur_block < 0)
69+
return -EINVAL;
70+
6871
block = ur_block;
6972
error = bmap(inode, &block);
7073

0 commit comments

Comments
 (0)