linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfs: initialize the shortform attr header padding entry
@ 2020-08-25 20:28 Darrick J. Wong
  2020-08-25 20:48 ` Eric Sandeen
  2020-08-25 22:42 ` Dave Chinner
  0 siblings, 2 replies; 4+ messages in thread
From: Darrick J. Wong @ 2020-08-25 20:28 UTC (permalink / raw)
  To: linux-xfs; +Cc: 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>
---
 fs/xfs/libxfs/xfs_attr_leaf.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index 8623c815164a..e1a3d225a77d 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -656,6 +656,7 @@ xfs_attr_shortform_create(
 	hdr = (xfs_attr_sf_hdr_t *)ifp->if_u1.if_data;
 	hdr->count = 0;
 	hdr->totsize = cpu_to_be16(sizeof(*hdr));
+	hdr->padding = 0;
 	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA);
 }
 

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

* Re: [PATCH] xfs: initialize the shortform attr header padding entry
  2020-08-25 20:28 [PATCH] xfs: initialize the shortform attr header padding entry Darrick J. Wong
@ 2020-08-25 20:48 ` Eric Sandeen
  2020-08-27  8:14   ` Christoph Hellwig
  2020-08-25 22:42 ` Dave Chinner
  1 sibling, 1 reply; 4+ messages in thread
From: Eric Sandeen @ 2020-08-25 20:48 UTC (permalink / raw)
  To: Darrick J. Wong, linux-xfs; +Cc: Eric Sandeen

On 8/25/20 3:28 PM, 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>

I noticed this too, thanks.

thought I wonder if 

a) others lurk and
b) if we should just be memsetting if_data to zero to avoid the need
   to carefully initialize all of everything always?

Anyway it fixes the problem we noticed so

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

> ---
>  fs/xfs/libxfs/xfs_attr_leaf.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
> index 8623c815164a..e1a3d225a77d 100644
> --- a/fs/xfs/libxfs/xfs_attr_leaf.c
> +++ b/fs/xfs/libxfs/xfs_attr_leaf.c
> @@ -656,6 +656,7 @@ xfs_attr_shortform_create(
>  	hdr = (xfs_attr_sf_hdr_t *)ifp->if_u1.if_data;
>  	hdr->count = 0;
>  	hdr->totsize = cpu_to_be16(sizeof(*hdr));
> +	hdr->padding = 0;
>  	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA);
>  }
>  
> 

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

* Re: [PATCH] xfs: initialize the shortform attr header padding entry
  2020-08-25 20:28 [PATCH] xfs: initialize the shortform attr header padding entry Darrick J. Wong
  2020-08-25 20:48 ` Eric Sandeen
@ 2020-08-25 22:42 ` Dave Chinner
  1 sibling, 0 replies; 4+ messages in thread
From: Dave Chinner @ 2020-08-25 22:42 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs, Eric Sandeen

On Tue, Aug 25, 2020 at 01:28:53PM -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>
> ---
>  fs/xfs/libxfs/xfs_attr_leaf.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
> index 8623c815164a..e1a3d225a77d 100644
> --- a/fs/xfs/libxfs/xfs_attr_leaf.c
> +++ b/fs/xfs/libxfs/xfs_attr_leaf.c
> @@ -656,6 +656,7 @@ xfs_attr_shortform_create(
>  	hdr = (xfs_attr_sf_hdr_t *)ifp->if_u1.if_data;
>  	hdr->count = 0;
>  	hdr->totsize = cpu_to_be16(sizeof(*hdr));
> +	hdr->padding = 0;

memset(hdr, 0, sizeof(*hdr)), please.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

* Re: [PATCH] xfs: initialize the shortform attr header padding entry
  2020-08-25 20:48 ` Eric Sandeen
@ 2020-08-27  8:14   ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2020-08-27  8:14 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Darrick J. Wong, linux-xfs, Eric Sandeen

On Tue, Aug 25, 2020 at 03:48:13PM -0500, Eric Sandeen wrote:
> On 8/25/20 3:28 PM, 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>
> 
> I noticed this too, thanks.
> 
> thought I wonder if 
> 
> a) others lurk and
> b) if we should just be memsetting if_data to zero to avoid the need
>    to carefully initialize all of everything always?
> 
> Anyway it fixes the problem we noticed so

Yes, I think fully clearing the thing would be better.  We can do
a memset for now, but splitting the non-existent data case out of
xfs_idata_realloc into a new helper that does kzmalloc sounds best
long term.

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

end of thread, other threads:[~2020-08-27  8:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-25 20:28 [PATCH] xfs: initialize the shortform attr header padding entry Darrick J. Wong
2020-08-25 20:48 ` Eric Sandeen
2020-08-27  8:14   ` Christoph Hellwig
2020-08-25 22:42 ` Dave Chinner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).