• Dave Chinner's avatar
    xfs: fix data corruption w/ unaligned reflink ranges · b3998900
    Dave Chinner authored
    When reflinking sub-file ranges, a data corruption can occur when
    the source file range includes a partial EOF block. This shares the
    unknown data beyond EOF into the second file at a position inside
    EOF, exposing stale data in the second file.
    
    XFS only supports whole block sharing, but we still need to
    support whole file reflink correctly.  Hence if the reflink
    request includes the last block of the souce file, only proceed with
    the reflink operation if it lands at or past the destination file's
    current EOF. If it lands within the destination file EOF, reject the
    entire request with -EINVAL and make the caller go the hard way.
    
    This avoids the data corruption vector, but also avoids disruption
    of returning EINVAL to userspace for the common case of whole file
    cloning.
    Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
    Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
    Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
    b3998900
xfs_reflink.c 46.8 KB