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@google.com>
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:
--
-
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| Andy Whitcroft | clam |
| Tarkan Erimer | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Trent Piepho | [PATCH] [POWERPC] Improve (in|out)_beXX() asm code |
git: | |
| David Miller | Re: iptables very slow after commit 784544739a25c30637397ace5489eeb6e15d7d49 |
| David Miller | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| David Miller | [GIT]: Networking |
