Skip to contentSkip to conversation

xfs: initialize the shortform attr header padding entry

PATCH Superseded Darrick J. Wong 4 participants 4 messages Aug 25, 2020 – Aug 27, 2020 XFS filesystem

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: initialize the shortform attr header padding entry

From: Darrick J. Wong <[email protected]>

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

---
 fs/xfs/libxfs/xfs_attr_leaf.c |    1 +
 1 file changed, 1 insertion(+)
fs/xfs/libxfs/xfs_attr_leaf.c +1 -0
index 8623c815164a..e1a3d225a77d 100644
@@ -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);
 }
 
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

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

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

Quoted 17 lines
---
 fs/xfs/libxfs/xfs_attr_leaf.c |    1 +
 1 file changed, 1 insertion(+)
fs/xfs/libxfs/xfs_attr_leaf.c +1 -0
index 8623c815164a..e1a3d225a77d 100644
@@ -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);
 }
 
#2 lore raw
Quoted 9 lines · Eric Sandeen
Quoted 5 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

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

I noticed this too, thanks.

Quoted 7 lines

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.

#3 lore raw
In reply to Darrick J. Wong
Quoted 14 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

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

---
 fs/xfs/libxfs/xfs_attr_leaf.c |    1 +
 1 file changed, 1 insertion(+)
fs/xfs/libxfs/xfs_attr_leaf.c +0 -0
index 8623c815164a..e1a3d225a77d 100644

fs/xfs/libxfs/xfs_attr_leaf.c xfs_attr_shortform_create( · line 659

Quoted 4 lines
fs/xfs/libxfs/xfs_attr_leaf.c +1 -0
@@ -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.

Signature · 2 lines
Dave Chinner
[email protected]