• Andreas Gruenbacher's avatar
    gfs2: Check for the end of metadata in punch_hole · bb491ce6
    Andreas Gruenbacher authored
    When punching a hole or truncating an inode down to a given size, also
    check if the truncate point / start of the hole is within the range we
    have metadata for.  Otherwise, we can end up freeing blocks that
    shouldn't be freed, corrupting the inode, or crashing the machine when
    trying to punch a hole into the void.
    
    When growing an inode via truncate, we set the new size but we don't
    allocate additional levels of indirect blocks and grow the inode height.
    When shrinking that inode again, the new size may still point beyond the
    end of the inode's metadata.
    
    Fixes xfstest generic/476.
    Debugged-by: default avatarBob Peterson <rpeterso@redhat.com>
    Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
    Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
    bb491ce6
bmap.c 54.9 KB