mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yingjie Wang <x-professor@outlook.com>
To: Damien Le Moal <dlemoal@kernel.org>,
	Alasdair Kergon <agk@redhat.com>,
	Mike Snitzer <snitzer@kernel.org>,
	Mikulas Patocka <mpatocka@redhat.com>,
	Benjamin Marzinski <bmarzins@redhat.com>
Cc: "dm-devel@lists.linux.dev" <dm-devel@lists.linux.dev>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Hannes Reinecke <hare@suse.de>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH 3/3] dm zoned: handle labels that are not NUL-terminated
Date: Tue, 1 Dec 2026 12:15:05 +0000	[thread overview]
Message-ID: <20261201121502.229596-1-x-professor@outlook.com> (raw)
In-Reply-To: <3f39a119-bbb2-40ed-8107-a20f8ea87fd9@kernel.org>

Hi Damien,

On 12/1/26 20:06, Damien Le Moal wrote:
>> -	char			label[BDEVNAME_SIZE];
>> +	char			label[BDEVNAME_SIZE + 1];
>
> This alone does not guarantee that the label is NUL terminated either. Who says
> that this was written with dmzadm or that a chnage in dmzadm introduces a bug?
> So the strlen() call below can still crash.

zmd is kzalloc'ed and only 32 bytes are copied into the label, so the
last byte stays 0 and strlen() is fine.

But you're right about dmzadm, what I wrote in the commit message is
wrong. For the default label, 2.0.0 to 2.1.3 do

	sprintf(dev->label, "dmz-%s", dev->bdev[0].name);

so if the device name has 28 or more characters, there is no NUL in the
32 bytes on disk, and loading the volume hits this crash. (If dmzadm is
built with _FORTIFY_SOURCE, it aborts instead.)

> So in addition to this change, we should check that the label has a terminating
> NUL character and reject the device as broken otherwise.

Agreed. That also rejects the volumes above, but they should be rare
and dmzadm 2.2.0 or later can relabel them. I'll add the check in v2,
fix the commit message and drop the extra byte, which isn't needed then.

Thanks,
Yingjie

      reply	other threads:[~2026-12-01 12:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 10:56 [PATCH 0/3] dm zoned: fix the validation of the superblocks Yingjie Wang
2026-12-01 10:56 ` [PATCH 1/3] dm zoned: do not update metadata state from an invalid superblock Yingjie Wang
2026-12-01 10:56 ` [PATCH 2/3] dm zoned: validate the metadata layout in the superblock Yingjie Wang
2026-12-01 10:56 ` [PATCH 3/3] dm zoned: handle labels that are not NUL-terminated Yingjie Wang
2026-12-01 11:06   ` Damien Le Moal
2026-12-01 12:15     ` Yingjie Wang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201121502.229596-1-x-professor@outlook.com \
    --to=x-professor@outlook.com \
    --cc=agk@redhat.com \
    --cc=bmarzins@redhat.com \
    --cc=dlemoal@kernel.org \
    --cc=dm-devel@lists.linux.dev \
    --cc=hare@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=snitzer@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®