diff mbox series

[2/2] xfs: fix partially uninitialized structure in xfs_reflink_remap_extent

Message ID 158674022396.3253017.2093178484820838524.stgit@magnolia (mailing list archive)
State Accepted
Headers show
Series xfs: random fixes for 5.7 | expand

Commit Message

Darrick J. Wong April 13, 2020, 1:10 a.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

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.

Fixes: 862bb360ef569 ("xfs: reflink extents from one file to another")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/xfs_reflink.c |    1 +
 1 file changed, 1 insertion(+)

Comments

Brian Foster April 13, 2020, 12:31 p.m. UTC | #1
On Sun, Apr 12, 2020 at 06:10:24PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> 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.
> 
> Fixes: 862bb360ef569 ("xfs: reflink extents from one file to another")
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/xfs_reflink.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> 
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index b0ce04ffd3cd..107bf2a2f344 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -1051,6 +1051,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. */
>
diff mbox series

Patch

diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index b0ce04ffd3cd..107bf2a2f344 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -1051,6 +1051,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. */