]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/suse-2.6.27.39/patches.fixes/xfs-fix-overflow-in-xfs_growfs_data_private
Imported linux-2.6.27.39 suse/xen patches.
[ipfire-2.x.git] / src / patches / suse-2.6.27.39 / patches.fixes / xfs-fix-overflow-in-xfs_growfs_data_private
CommitLineData
2cb7cef9
BS
1From: Eric Sandeen <sandeen@sandeen.net>
2Date: Sat, 23 May 2009 19:30:12 +0000 (-0500)
3Subject: xfs: fix overflow in xfs_growfs_data_private
4Patch-mainline: 2.6.30-rc8
5Git-commit: e6da7c9fed111ba1243297ee6eda8e24ae11c384
6References: bnc#506361
7
8xfs: fix overflow in xfs_growfs_data_private
9
10In the case where growing a filesystem would leave the last AG
11too small, the fixup code has an overflow in the calculation
12of the new size with one fewer ag, because "nagcount" is a 32
13bit number. If the new filesystem has > 2^32 blocks in it
14this causes a problem resulting in an EINVAL return from growfs:
15
16 # xfs_io -f -c "truncate 19998630180864" fsfile
17 # mkfs.xfs -f -bsize=4096 -dagsize=76288719b,size=3905982455b fsfile
18 # mount -o loop fsfile /mnt
19 # xfs_growfs /mnt
20
21meta-data=/dev/loop0 isize=256 agcount=52,
22agsize=76288719 blks
23 = sectsz=512 attr=2
24data = bsize=4096 blocks=3905982455, imaxpct=5
25 = sunit=0 swidth=0 blks
26naming =version 2 bsize=4096 ascii-ci=0
27log =internal bsize=4096 blocks=32768, version=2
28 = sectsz=512 sunit=0 blks, lazy-count=0
29realtime =none extsz=4096 blocks=0, rtextents=0
30xfs_growfs: XFS_IOC_FSGROWFSDATA xfsctl failed: Invalid argument
31
32Reported-by: richard.ems@cape-horn-eng.com
33Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
34Reviewed-by: Christoph Hellwig <hch@lst.de>
35Reviewed-by: Felix Blyakher <felixb@sgi.com>
36Signed-off-by: Felix Blyakher <felixb@sgi.com>
37Acked-by: Jeff Mahoney <jeffm@suse.com>
38---
39
40 fs/xfs/xfs_fsops.c | 2 +-
41 1 file changed, 1 insertion(+), 1 deletion(-)
42
43diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
44index 8379e3b..cbd451b 100644
45--- a/fs/xfs/xfs_fsops.c
46+++ b/fs/xfs/xfs_fsops.c
47@@ -160,7 +160,7 @@ xfs_growfs_data_private(
48 nagcount = new + (nb_mod != 0);
49 if (nb_mod && nb_mod < XFS_MIN_AG_BLOCKS) {
50 nagcount--;
51- nb = nagcount * mp->m_sb.sb_agblocks;
52+ nb = (xfs_rfsblock_t)nagcount * mp->m_sb.sb_agblocks;
53 if (nb < mp->m_sb.sb_dblocks)
54 return XFS_ERROR(EINVAL);
55 }