]> git.ipfire.org Git - thirdparty/util-linux.git/commit - libblkid/src/superblocks/xfs.c
libblkid: Compute CRC with sb_crc zeroed
authorJeremy Linton <jeremy.linton@arm.com>
Fri, 14 Apr 2023 21:25:28 +0000 (16:25 -0500)
committerJeremy Linton <jeremy.linton@arm.com>
Fri, 14 Apr 2023 23:49:27 +0000 (18:49 -0500)
commitf8017377281659c0d4ad405b75baf1cd7788515b
tree62871e1aa2f892a17b8fe5d71f47c73d20c02884
parent2598e25fb68ff37182fdb026b52055f177ceb24d
libblkid: Compute CRC with sb_crc zeroed

The Linux kernel computes the sb_crc by crcing the
superblock with the CRC field set to 0. The code is
trying to avoid doing this in three separate CRC calls
like the kernel performs by simply zeroing the field
and making a single call.

Except that the passed copy "ondisk" isn't the same
as the returned copy "csummed" so the zeroing goes into
the wrong buffer. Meaning that the CRC is computed
incorrectly. This results in blkid returning:

/dev/sda4: PARTUUID="2f162043-63c2-d145-869b-e53f9db57476"

rather than:

/dev/sda4: UUID="45b931b7-592a-46dc-9c33-d38d5901ec29" BLOCK_SIZE="4096" TYPE="xfs" PARTUUID="2f162043-63c2-d145-869b-e53f9db57476"

Which can result in lots of failures including boot
failures if XFS modules aren't placed into the initrd,
or scripts/etc cannot determine the fs UUID.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
libblkid/src/superblocks/xfs.c