Re: [PATCH v2 3/3] dm zoned: handle labels that are not NUL-terminated

From: Damien Le Moal

Date: Sat Dec 05 2026 - 18:35:44 EST


On 12/5/26 15:21, Yingjie Wang wrote:
> Hi Damien,
>
> On 12/4/26 16:42, Damien Le Moal wrote:
>>> if (strlen(zmd->label) &&
>>> memcmp(zmd->label, sb->dmz_label, BDEVNAME_SIZE)) {
>>> - dmz_dev_err(dev, "mismatching DM-Zoned label, is %s expected %s",
>>> + dmz_dev_err(dev, "mismatching DM-Zoned label, is %.32s expected %s",
>>
>> The copy of the label is at most BDEVNAME_SIZE, so the +1 char is always NUL and
>> this change is not needed.
>>
>>> sb->dmz_label, zmd->label);
>
> The %.32s is for sb->dmz_label, the label in the superblock being
> checked, not for the copy in zmd->label. sb->dmz_label is the 32-byte
> field in the metadata block, so if the label on disk uses all 32 bytes,
> %s reads on into the UUIDs and reserved bytes after it, and past the end
> of the block if none of them is zero. That is the second report in the
> commit message.
>
> zmd->label is NUL-terminated thanks to the extra byte, so it is still
> printed with %s.

Doh! I missed that. So this is good as is.

Reviewed-by: Damien Le Moal <dlemoal@xxxxxxxxxx>


--
Damien Le Moal
Western Digital Research