Skip to contentSkip to conversation

xfs: initialize the shortform attr header padding entry

PATCH In review Darrick J. Wong 3 participants 3 messages Aug 26, 2020 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH v2 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.

---
v2: memset instead of setting padding by hand

---
 fs/xfs/libxfs/xfs_attr_leaf.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/xfs/libxfs/xfs_attr_leaf.c +2 -2
index 8623c815164a..e730586bff85 100644
@@ -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);
 }
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Darrick J. Wong

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

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

---
v2: memset instead of setting padding by hand

yeah I think that's good.

Quoted 20 lines
---
 fs/xfs/libxfs/xfs_attr_leaf.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/xfs/libxfs/xfs_attr_leaf.c +2 -2
index 8623c815164a..e730586bff85 100644
@@ -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);
 }
Reviewed-by on v2 1/1
#2 lore raw
In reply to Darrick J. Wong
Quoted 16 lines · Darrick J. Wong

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

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

---
v2: memset instead of setting padding by hand

---
 fs/xfs/libxfs/xfs_attr_leaf.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/xfs/libxfs/xfs_attr_leaf.c +0 -0
index 8623c815164a..e730586bff85 100644

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

Quoted 10 lines
fs/xfs/libxfs/xfs_attr_leaf.c +2 -2
@@ -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.

Signature · 2 lines
Dave Chinner
[email protected]