Patchwork ext4: Add missing cast in ext4_fallocate

login
register
mail settings
Submitter Utako Kusaka
Date July 25, 2011, 7:33 a.m.
Message ID <4E2D1C5D.6070103@wm.jp.nec.com>
Download mbox | patch
Permalink /patch/106615/
State Accepted
Headers show

Comments

Utako Kusaka - July 25, 2011, 7:33 a.m.
Cast map.m_lblk to loff_t.

File size is corrupt when we get an ENOSPC.
Logical block number is __u32, so new_size will be set to overflowed value.

# df -T /mnt/mp1
Filesystem    Type   1K-blocks      Used Available Use% Mounted on
/dev/sda6     ext4     9843276    153056   9190200   2% /mnt/mp1
# fallocate -o 0 -l 2199023251456 /mnt/mp1/testfile
fallocate: /mnt/mp1/testfile: fallocate failed: No space left on device
# stat /mnt/mp1/testfile
  File: `/mnt/mp1/testfile'
  Size: 4293656576	Blocks: 19380440   IO Block: 4096   regular file
Device: 806h/2054d	Inode: 12          Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2011-07-25 13:01:31.414490496 +0900
Modify: 2011-07-25 13:01:31.414490496 +0900
Change: 2011-07-25 13:01:31.454490495 +0900

Signed-off-by: Utako Kusaka <u-kusaka@wm.jp.nec.com>
--
 fs/ext4/extents.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Theodore Ts'o - July 28, 2011, 2:12 a.m.
On Mon, Jul 25, 2011 at 04:33:49PM +0900, Utako Kusaka wrote:
> Cast map.m_lblk to loff_t.
> 
> File size is corrupt when we get an ENOSPC.
> Logical block number is __u32, so new_size will be set to overflowed value.
> 
> # df -T /mnt/mp1
> Filesystem    Type   1K-blocks      Used Available Use% Mounted on
> /dev/sda6     ext4     9843276    153056   9190200   2% /mnt/mp1
> # fallocate -o 0 -l 2199023251456 /mnt/mp1/testfile
> fallocate: /mnt/mp1/testfile: fallocate failed: No space left on device
> # stat /mnt/mp1/testfile
>   File: `/mnt/mp1/testfile'
>   Size: 4293656576	Blocks: 19380440   IO Block: 4096   regular file
> Device: 806h/2054d	Inode: 12          Links: 1
> Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
> Access: 2011-07-25 13:01:31.414490496 +0900
> Modify: 2011-07-25 13:01:31.414490496 +0900
> Change: 2011-07-25 13:01:31.454490495 +0900
> 
> Signed-off-by: Utako Kusaka <u-kusaka@wm.jp.nec.com>

Thanks, added to the ext4 tree.

						- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index f815cc8..a082f43 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3835,7 +3835,7 @@  retry:
 						blkbits) >> blkbits))
 			new_size = offset + len;
 		else
-			new_size = (map.m_lblk + ret) << blkbits;
+			new_size = ((loff_t)map.m_lblk + ret) << blkbits;

 		ext4_falloc_update_inode(inode, mode, new_size,
 					 (map.m_flags & EXT4_MAP_NEW));