Propagate an error (EFBIG) to userspace if the physical block is too large to return in a 32bit int instead of truncating it. Signed-off-by: Mike Waychison <mikew@xxxxxxxxxx> fs/ioctl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) Index: linux-2.6.23/fs/ioctl.c =================================================================== --- linux-2.6.23.orig/fs/ioctl.c 2007-10-26 15:26:10.000000000 -0700 +++ linux-2.6.23/fs/ioctl.c 2007-10-26 16:16:28.000000000 -0700 @@ -52,6 +52,7 @@ static int file_ioctl(struct file *filp, case FIBMAP: { struct address_space *mapping = filp->f_mapping; + sector_t phys_block; int res; /* do we support this mess? */ if (!mapping->a_ops->bmap) @@ -64,8 +65,15 @@ static int file_ioctl(struct file *filp, return -EINVAL; lock_kernel(); - res = mapping->a_ops->bmap(mapping, block); + phys_block = mapping->a_ops->bmap(mapping, block); unlock_kernel(); + + /* Make sure that the return value fits in the + * user's buffer. */ + if ((u32)phys_block < phys_block) + return -EFBIG; + + res = phys_block; return put_user(res, p); } case FIGETBSZ: -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html