From patchwork Mon Jul 25 07:33:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utako Kusaka X-Patchwork-Id: 106615 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 363B2B6F83 for ; Mon, 25 Jul 2011 17:34:22 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751145Ab1GYHeU (ORCPT ); Mon, 25 Jul 2011 03:34:20 -0400 Received: from TYO201.gate.nec.co.jp ([202.32.8.193]:55675 "EHLO tyo201.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750864Ab1GYHeU (ORCPT ); Mon, 25 Jul 2011 03:34:20 -0400 Received: from mailgate3.nec.co.jp ([10.7.69.197]) by tyo201.gate.nec.co.jp (8.13.8/8.13.4) with ESMTP id p6P7YFB2012388; Mon, 25 Jul 2011 16:34:15 +0900 (JST) Received: (from root@localhost) by mailgate3.nec.co.jp (8.11.7/3.7W-MAILGATE-NEC) id p6P7YEm05212; Mon, 25 Jul 2011 16:34:14 +0900 (JST) Received: from mail03.kamome.nec.co.jp (mail03.kamome.nec.co.jp [10.25.43.7]) by mailsv3.nec.co.jp (8.13.8/8.13.4) with ESMTP id p6P7YEGK026799; Mon, 25 Jul 2011 16:34:14 +0900 (JST) Received: from yonosuke.jp.nec.com ([10.26.220.15] [10.26.220.15]) by mail03.kamome.nec.co.jp with ESMTP id BT-MMP-19804; Mon, 25 Jul 2011 16:33:49 +0900 Received: from [10.64.168.199] ([10.64.168.199] [10.64.168.199]) by mail.jp.nec.com with ESMTP; Mon, 25 Jul 2011 16:33:49 +0900 Message-ID: <4E2D1C5D.6070103@wm.jp.nec.com> Date: Mon, 25 Jul 2011 16:33:49 +0900 From: Utako Kusaka User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; ja; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: linux-ext4@vger.kernel.org, tytso@mit.edu Subject: [PATCH] ext4: Add missing cast in ext4_fallocate Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 --- 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 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));