diff mbox series

[2/4] xfs: check owner of dir3 free blocks

Message ID 158294092825.1729975.10937805307008830676.stgit@magnolia (mailing list archive)
State Superseded
Headers show
Series xfs: fix errors in directory verifiers | expand

Commit Message

Darrick J. Wong Feb. 29, 2020, 1:48 a.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Check the owner field of dir3 free block headers.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/libxfs/xfs_dir2_node.c |    2 ++
 1 file changed, 2 insertions(+)

Comments

Allison Henderson March 2, 2020, 6:11 p.m. UTC | #1
On 2/28/20 6:48 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Check the owner field of dir3 free block headers.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Ok, looks fine:
Reviewed-by: Allison Collins <allison.henderson@oracle.com>

> ---
>   fs/xfs/libxfs/xfs_dir2_node.c |    2 ++
>   1 file changed, 2 insertions(+)
> 
> 
> diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
> index f622ede7119e..79b917e62ac3 100644
> --- a/fs/xfs/libxfs/xfs_dir2_node.c
> +++ b/fs/xfs/libxfs/xfs_dir2_node.c
> @@ -194,6 +194,8 @@ xfs_dir3_free_header_check(
>   			return __this_address;
>   		if (be32_to_cpu(hdr3->nvalid) < be32_to_cpu(hdr3->nused))
>   			return __this_address;
> +		if (be64_to_cpu(hdr3->hdr.owner) != dp->i_ino)
> +			return __this_address;
>   	} else {
>   		struct xfs_dir2_free_hdr *hdr = bp->b_addr;
>   
>
Eric Sandeen March 3, 2020, 12:04 a.m. UTC | #2
On 2/28/20 5:48 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Check the owner field of dir3 free block headers.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Do we need a similar check in xfs_repair?

Should this also check

hdr.blkno == bp->b_bn? ?

> ---
>  fs/xfs/libxfs/xfs_dir2_node.c |    2 ++
>  1 file changed, 2 insertions(+)
> 
> 
> diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
> index f622ede7119e..79b917e62ac3 100644
> --- a/fs/xfs/libxfs/xfs_dir2_node.c
> +++ b/fs/xfs/libxfs/xfs_dir2_node.c
> @@ -194,6 +194,8 @@ xfs_dir3_free_header_check(
>  			return __this_address;
>  		if (be32_to_cpu(hdr3->nvalid) < be32_to_cpu(hdr3->nused))
>  			return __this_address;
> +		if (be64_to_cpu(hdr3->hdr.owner) != dp->i_ino)
> +			return __this_address;
>  	} else {
>  		struct xfs_dir2_free_hdr *hdr = bp->b_addr;
>  
>
Darrick J. Wong March 3, 2020, 4:08 p.m. UTC | #3
On Mon, Mar 02, 2020 at 06:04:07PM -0600, Eric Sandeen wrote:
> On 2/28/20 5:48 PM, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Check the owner field of dir3 free block headers.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Do we need a similar check in xfs_repair?

Yeah, working on that...

> Should this also check
> 
> hdr.blkno == bp->b_bn? ?

That's checked by xfs_dir3_free_verify.

--D

> > ---
> >  fs/xfs/libxfs/xfs_dir2_node.c |    2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > 
> > diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
> > index f622ede7119e..79b917e62ac3 100644
> > --- a/fs/xfs/libxfs/xfs_dir2_node.c
> > +++ b/fs/xfs/libxfs/xfs_dir2_node.c
> > @@ -194,6 +194,8 @@ xfs_dir3_free_header_check(
> >  			return __this_address;
> >  		if (be32_to_cpu(hdr3->nvalid) < be32_to_cpu(hdr3->nused))
> >  			return __this_address;
> > +		if (be64_to_cpu(hdr3->hdr.owner) != dp->i_ino)
> > +			return __this_address;
> >  	} else {
> >  		struct xfs_dir2_free_hdr *hdr = bp->b_addr;
> >  
> >
Eric Sandeen March 3, 2020, 4:10 p.m. UTC | #4
On 3/3/20 8:08 AM, Darrick J. Wong wrote:
> On Mon, Mar 02, 2020 at 06:04:07PM -0600, Eric Sandeen wrote:
>> On 2/28/20 5:48 PM, Darrick J. Wong wrote:
>>> From: Darrick J. Wong <darrick.wong@oracle.com>
>>>
>>> Check the owner field of dir3 free block headers.
>>>
>>> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
>>
>> Do we need a similar check in xfs_repair?
> 
> Yeah, working on that...


k

>> Should this also check
>>
>> hdr.blkno == bp->b_bn? ?
> 
> That's checked by xfs_dir3_free_verify.

Oh, right.  sorry.

-Eric
Christoph Hellwig March 5, 2020, 4:50 p.m. UTC | #5
On Fri, Feb 28, 2020 at 05:48:48PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Check the owner field of dir3 free block headers.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
index f622ede7119e..79b917e62ac3 100644
--- a/fs/xfs/libxfs/xfs_dir2_node.c
+++ b/fs/xfs/libxfs/xfs_dir2_node.c
@@ -194,6 +194,8 @@  xfs_dir3_free_header_check(
 			return __this_address;
 		if (be32_to_cpu(hdr3->nvalid) < be32_to_cpu(hdr3->nused))
 			return __this_address;
+		if (be64_to_cpu(hdr3->hdr.owner) != dp->i_ino)
+			return __this_address;
 	} else {
 		struct xfs_dir2_free_hdr *hdr = bp->b_addr;