• Z
    xfs: avoid f_bfree overflow · 79d1a532
    Zheng Bin 提交于
    hulk inclusion
    category: bugfix
    bugzilla: 31088
    CVE: NA
    
    ---------------------------
    
    If fdblocks < mp->m_alloc_set_aside, statp->f_bfree will overflow.
    When we df -h /mnt(xfs mount point), will show this:
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/loop0       17M  -64Z  -32K 100% /mnt
    
    We can construct an img like this:
    
    dd if=/dev/zero of=xfs.img bs=1M count=20
    mkfs.xfs -d agcount=1 xfs.img
    xfs_db -x xfs.img
    sb 0
    write fdblocks 0
    agf 0
    write freeblks 0
    write longest 0
    quit
    
    Make sure statp->f_bfree does not underflow.
    Signed-off-by: NZheng Bin <zhengbin13@huawei.com>
    Reviewed-by: NHou Tao <houtao1@huawei.com>
    Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
    79d1a532
xfs_super.c 55.1 KB