• Christoph Hellwig's avatar
    xfs: only remap the written blocks in xfs_reflink_end_cow_extent · 55f669f3
    Christoph Hellwig authored
    xfs_reflink_end_cow_extent looks up the COW extent and the data fork
    extent at offset_fsb, and then proceeds to remap the common subset
    between the two.
    
    It does however not limit the remapped extent to the passed in
    [*offset_fsbm end_fsb] range and thus potentially remaps more blocks than
    the one handled by the current I/O completion.  This means that with
    sufficiently large data and COW extents we could be remapping COW fork
    mappings that have not been written to, leading to a stale data exposure
    on a powerfail event.
    
    We use to have a xfs_trim_range to make the remap fit the I/O completion
    range, but that got (apparently accidentally) removed in commit
    df2fd88f ("xfs: rewrite xfs_reflink_end_cow to use intents").
    
    Note that I've only found this by code inspection, and a test case would
    probably require very specific delay and error injection.
    
    Fixes: df2fd88f ("xfs: rewrite xfs_reflink_end_cow to use intents")
    Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
    Reviewed-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
    Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>
    55f669f3
xfs_reflink.c 48.4 KB