]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfs: make struct xfs_buf_log_format have a consistent size libxfs-5.6-sync_2020-03-03
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 20 Feb 2020 00:36:09 +0000 (16:36 -0800)
committerDarrick J. Wong <darrick.wong@oracle.com>
Tue, 3 Mar 2020 05:05:26 +0000 (21:05 -0800)
commit3e599594fe03159bf54c448ea7f6b4acb3288231
tree3db92396f3e8b134c089cfe2fc4b8c2c91e8ddbf
parente0a6fca99938de962e3428699c8bf3ba44682a0c
xfs: make struct xfs_buf_log_format have a consistent size

Source kernel commit: b7df5e92055c69666e3c82f31f193120d98f04e3

Increase XFS_BLF_DATAMAP_SIZE by 1 to fill in the implied padding at the
end of struct xfs_buf_log_format.  This makes the size consistent so
that we can check it in xfs_ondisk.h, and will be needed once we start
logging attribute values.

On amd64 we get the following pahole:

struct xfs_buf_log_format {
short unsigned int         blf_type;       /*     0     2 */
short unsigned int         blf_size;       /*     2     2 */
short unsigned int         blf_flags;      /*     4     2 */
short unsigned int         blf_len;        /*     6     2 */
long long int              blf_blkno;      /*     8     8 */
unsigned int               blf_map_size;   /*    16     4 */
unsigned int               blf_data_map[16]; /*    20    64 */
/* --- cacheline 1 boundary (64 bytes) was 20 bytes ago --- */

/* size: 88, cachelines: 2, members: 7 */
/* padding: 4 */
/* last cacheline: 24 bytes */
};

But on i386 we get the following:

struct xfs_buf_log_format {
short unsigned int         blf_type;       /*     0     2 */
short unsigned int         blf_size;       /*     2     2 */
short unsigned int         blf_flags;      /*     4     2 */
short unsigned int         blf_len;        /*     6     2 */
long long int              blf_blkno;      /*     8     8 */
unsigned int               blf_map_size;   /*    16     4 */
unsigned int               blf_data_map[16]; /*    20    64 */
/* --- cacheline 1 boundary (64 bytes) was 20 bytes ago --- */

/* size: 84, cachelines: 2, members: 7 */
/* last cacheline: 20 bytes */
};

Notice how the amd64 compiler inserts 4 bytes of padding to the end of
the structure to ensure 8-byte alignment.  Prior to "xfs: fix memory
corruption during remote attr value buffer invalidation" we would try to
write to blf_data_map[17], which is harmless on amd64 but really bad on
i386.

This shouldn't cause any changes in the ondisk logging formats because
the log code writes out the log vectors with the appropriate size for
the log item's map_size, and log recovery treats the data_map array as a
VLA.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
libxfs/xfs_log_format.h