From patchwork Wed Mar 26 05:20:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kazuya Mio X-Patchwork-Id: 333790 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 B55E0140086 for ; Wed, 26 Mar 2014 18:00:13 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751330AbaCZHAM (ORCPT ); Wed, 26 Mar 2014 03:00:12 -0400 Received: from TYO200.gate.nec.co.jp ([210.143.35.50]:63729 "EHLO tyo200.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751027AbaCZHAL convert rfc822-to-8bit (ORCPT ); Wed, 26 Mar 2014 03:00:11 -0400 X-Greylist: delayed 5873 seconds by postgrey-1.27 at vger.kernel.org; Wed, 26 Mar 2014 03:00:11 EDT Received: from tyo201.gate.nec.co.jp ([10.7.69.201]) by tyo200.gate.nec.co.jp (8.13.8/8.13.4) with ESMTP id s2Q5QIR2014393 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 26 Mar 2014 14:26:18 +0900 (JST) 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 s2Q5MBQj012365; Wed, 26 Mar 2014 14:22:11 +0900 (JST) Received: from mailsv4.nec.co.jp (imss62.nec.co.jp [10.7.69.157]) by mailgate3.nec.co.jp (8.11.7/3.7W-MAILGATE-NEC) with ESMTP id s2Q5MB320928; Wed, 26 Mar 2014 14:22:11 +0900 (JST) Received: from mail03.kamome.nec.co.jp (mail03.kamome.nec.co.jp [10.25.43.7]) by mailsv4.nec.co.jp (8.13.8/8.13.4) with ESMTP id s2Q5MBP0023694; Wed, 26 Mar 2014 14:22:11 +0900 (JST) Received: from bpxc99gp.gisp.nec.co.jp ([10.38.151.150] [10.38.151.150]) by mail01b.kamome.nec.co.jp with ESMTP id BT-MMP-429343; Wed, 26 Mar 2014 14:20:55 +0900 Received: from BPXM20GP.gisp.nec.co.jp ([169.254.1.151]) by BPXC22GP.gisp.nec.co.jp ([10.38.151.150]) with mapi id 14.02.0328.011; Wed, 26 Mar 2014 14:20:54 +0900 From: Kazuya Mio To: "tytso@mit.edu" , "adilger.kernel@dilger.ca" CC: "linux-ext4@vger.kernel.org" Subject: [PATCH] ext4: FIBMAP ioctl causes BUG_ON due to handle EXT_MAX_BLOCKS Thread-Topic: [PATCH] ext4: FIBMAP ioctl causes BUG_ON due to handle EXT_MAX_BLOCKS Thread-Index: Ac9IsvA/U6/xyBEES8y9+1qvo9a5pA== Date: Wed, 26 Mar 2014 05:20:54 +0000 Message-ID: Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.64.168.30] MIME-Version: 1.0 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org When we try to get 2^32-1 block of the file which has the extent (ee_block=2^32-2, ee_len=1) with FIBMAP ioctl, it causes BUG_ON in ext4_ext_put_gap_in_cache(). To avoid the problem, ext4_bmap() needs to check the file logical block number. ext4_ext_put_gap_in_cache() called via ext4_get_block() cannot handle 2^32-1 because the maximum file logical block number is 2^32-2. However, the block number in ext4_bmap() which is gotten from user space is passed to ext4_get_block() directly. Signed-off-by: Kazuya Mio --- fs/ext4/inode.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 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/inode.c b/fs/ext4/inode.c index 61d49ff..aef3501 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -2873,6 +2873,12 @@ static sector_t ext4_bmap(struct address_space *mapping, sector_t block) if (ext4_has_inline_data(inode)) return 0; + /* + * We cannot get physical block number over EXT_MAX_BLOCKS + */ + if ((ext4_lblk_t)block >= EXT_MAX_BLOCKS) + return 0; + if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY) && test_opt(inode->i_sb, DELALLOC)) { /*