From: Darrick J. Wong Date: Sun, 12 Apr 2020 20:11:11 +0000 (-0700) Subject: xfs: fix partially uninitialized structure in xfs_reflink_remap_extent X-Git-Tag: Ubuntu-5.4.0-38.42~706 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=048c07c6b7fe757a6ec0ed5cde4bec0798ad7f53;p=mirror_ubuntu-focal-kernel.git xfs: fix partially uninitialized structure in xfs_reflink_remap_extent BugLink: https://bugs.launchpad.net/bugs/1876765 [ Upstream commit c142932c29e533ee892f87b44d8abc5719edceec ] In the reflink extent remap function, it turns out that uirec (the block mapping corresponding only to the part of the passed-in mapping that got unmapped) was not fully initialized. Specifically, br_state was not being copied from the passed-in struct to the uirec. This could lead to unpredictable results such as the reflinked mapping being marked unwritten in the destination file. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Signed-off-by: Sasha Levin Signed-off-by: Kamal Mostafa Signed-off-by: Stefan Bader --- diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 0f08153b4994..6a4fd1738b08 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1053,6 +1053,7 @@ xfs_reflink_remap_extent( uirec.br_startblock = irec->br_startblock + rlen; uirec.br_startoff = irec->br_startoff + rlen; uirec.br_blockcount = unmap_len - rlen; + uirec.br_state = irec->br_state; unmap_len = rlen; /* If this isn't a real mapping, we're done. */