public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] xfs: initialize the shortform attr header padding entry
@ 2020-08-26 15:39 Darrick J. Wong
  2020-08-26 17:49 ` Eric Sandeen
  2020-08-26 21:59 ` Dave Chinner
  0 siblings, 2 replies; 3+ messages in thread
From: Darrick J. Wong @ 2020-08-26 15:39 UTC (permalink / raw)
  To: linux-xfs; +Cc: Dave Chinner, Eric Sandeen

From: Darrick J. Wong <darrick.wong@oracle.com>

Don't leak kernel memory contents into the shortform attr fork.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
v2: memset instead of setting padding by hand
---
 fs/xfs/libxfs/xfs_attr_leaf.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index 8623c815164a..e730586bff85 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -653,8 +653,8 @@ xfs_attr_shortform_create(
 		ASSERT(ifp->if_flags & XFS_IFINLINE);
 	}
 	xfs_idata_realloc(dp, sizeof(*hdr), XFS_ATTR_FORK);
-	hdr = (xfs_attr_sf_hdr_t *)ifp->if_u1.if_data;
-	hdr->count = 0;
+	hdr = (struct xfs_attr_sf_hdr *)ifp->if_u1.if_data;
+	memset(hdr, 0, sizeof(*hdr));
 	hdr->totsize = cpu_to_be16(sizeof(*hdr));
 	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA);
 }

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] xfs: initialize the shortform attr header padding entry
  2020-08-26 15:39 [PATCH v2] xfs: initialize the shortform attr header padding entry Darrick J. Wong
@ 2020-08-26 17:49 ` Eric Sandeen
  2020-08-26 21:59 ` Dave Chinner
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Sandeen @ 2020-08-26 17:49 UTC (permalink / raw)
  To: Darrick J. Wong, linux-xfs; +Cc: Dave Chinner, Eric Sandeen

On 8/26/20 10:39 AM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Don't leak kernel memory contents into the shortform attr fork.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> v2: memset instead of setting padding by hand

yeah I think that's good.

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
>  fs/xfs/libxfs/xfs_attr_leaf.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
> index 8623c815164a..e730586bff85 100644
> --- a/fs/xfs/libxfs/xfs_attr_leaf.c
> +++ b/fs/xfs/libxfs/xfs_attr_leaf.c
> @@ -653,8 +653,8 @@ xfs_attr_shortform_create(
>  		ASSERT(ifp->if_flags & XFS_IFINLINE);
>  	}
>  	xfs_idata_realloc(dp, sizeof(*hdr), XFS_ATTR_FORK);
> -	hdr = (xfs_attr_sf_hdr_t *)ifp->if_u1.if_data;
> -	hdr->count = 0;
> +	hdr = (struct xfs_attr_sf_hdr *)ifp->if_u1.if_data;
> +	memset(hdr, 0, sizeof(*hdr));
>  	hdr->totsize = cpu_to_be16(sizeof(*hdr));
>  	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA);
>  }
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] xfs: initialize the shortform attr header padding entry
  2020-08-26 15:39 [PATCH v2] xfs: initialize the shortform attr header padding entry Darrick J. Wong
  2020-08-26 17:49 ` Eric Sandeen
@ 2020-08-26 21:59 ` Dave Chinner
  1 sibling, 0 replies; 3+ messages in thread
From: Dave Chinner @ 2020-08-26 21:59 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs, Eric Sandeen

On Wed, Aug 26, 2020 at 08:39:22AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Don't leak kernel memory contents into the shortform attr fork.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> v2: memset instead of setting padding by hand
> ---
>  fs/xfs/libxfs/xfs_attr_leaf.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
> index 8623c815164a..e730586bff85 100644
> --- a/fs/xfs/libxfs/xfs_attr_leaf.c
> +++ b/fs/xfs/libxfs/xfs_attr_leaf.c
> @@ -653,8 +653,8 @@ xfs_attr_shortform_create(
>  		ASSERT(ifp->if_flags & XFS_IFINLINE);
>  	}
>  	xfs_idata_realloc(dp, sizeof(*hdr), XFS_ATTR_FORK);
> -	hdr = (xfs_attr_sf_hdr_t *)ifp->if_u1.if_data;
> -	hdr->count = 0;
> +	hdr = (struct xfs_attr_sf_hdr *)ifp->if_u1.if_data;
> +	memset(hdr, 0, sizeof(*hdr));
>  	hdr->totsize = cpu_to_be16(sizeof(*hdr));
>  	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA);
>  }

Looks good.

Reviewed-by: Dave Chinner <dchinner@redhat.com>

-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-26 22:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-26 15:39 [PATCH v2] xfs: initialize the shortform attr header padding entry Darrick J. Wong
2020-08-26 17:49 ` Eric Sandeen
2020-08-26 21:59 ` Dave Chinner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox