• Iustin Pop's avatar
    xfs: fix behaviour of XFS_IOC_FSSETXATTR on directories · 9b94fcc3
    Iustin Pop authored
    Currently, the ioctl handling code for XFS_IOC_FSSETXATTR treats all
    targets as regular files: it refuses to change the extent size if
    extents are allocated. This is wrong for directories, as there the
    extent size is only used as a default for children.
    
    The patch fixes this issue and improves validation of flag
    combinations:
    
    - only disallow extent size changes after extents have been allocated
      for regular files
    - only allow XFS_XFLAG_EXTSIZE for regular files
    - only allow XFS_XFLAG_EXTSZINHERIT for directories
    - automatically clear the flags if the extent size is zero
    
    Thanks to Dave Chinner for guidance on the proper fix for this issue.
    
    [dchinner: ported changes onto cleanup series. Makes changes clear
    	   and obvious.]
    [dchinner: added comments documenting validity checking rules.]
    Signed-off-by: default avatarIustin Pop <iustin@k1024.org>
    Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
    Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
    Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
    9b94fcc3
xfs_ioctl.c 39.8 KB