From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796190800; b=MZqQfFKqVwckU7jmunXcxaFr4xfBcXVLh7w1WizocLZG1z8tzouUJAnwi0XW5jJIz6QC ECG9SG9r/ChG5UVCeNcslXG9rt5jR36bvMaH9vtw7aTvOPwYLjMZK/bUFpvvqe1ff6i7g xKpaQOqrX+t3iwiVz/t955dMZJVFMn4/PbWKeyHgLHl5igndVUUlOTEirta+xJr6PBfvS C3mgUbseyb7pwtcAufjqjGIOV6jFfR/d3qlOK49TrOrwz4Yg1rMvxXl/9Gv1FWmBP+SCm odCajDzDFcZTNk0XJwDY1IqeY8tVWWZClCZMrAw0y6MoxC4F5QcaoMqjER5aJIsa12g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796190800; h=Received:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:Organization: In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=lgiZdruqtJ2VwNtKu/6p5/3+JzhDu7kiqBTQXmXzW40=; b=pBXJK6C8oe1DwJbqY3bkticEie+YCz2qQJKZS6ASIlAsw9v3szrbFISkR0vtpkTPTPa2 6y3nkNAZYp9BqvD39SV2wiMW0/Ey2E+Hi0XCiB7N1OWUtOVol2e0A3Ncj/VEZT7xAIM8b 0LDrYqTbM/9Ezj4+pVNIvFaG8cSQ0qqMJmq8M5uIPuadme43UFJkDquecvhgKRJbonPMg kUPLkweW5a2ab0L16GDapON53bR8Lf+dWb4QPIBNTf89IFk6RE8iNh7aik9kHGNjIfTdI qv29Q8uF5EkEZz27GRD6y8AKdx2qGB7O3XCIIiHNnkW2wjYbXxdOLrTMyE1duU5IBHw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BASPJArB; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8ED3606A32C; Wed, 2 Dec 2026 05:53:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BASPJArB Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18D3A1F000C1; Wed, 2 Dec 2026 05:53:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796190800; bh=lgiZdruqtJ2VwNtKu/6p5/3+JzhDu7kiqBTQXmXzW40=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=BASPJArBuYbsaciQeadczdiYNTU5EmiBGXeM3LF0K81qU9n9Zk/JHpVW1yuHG1+4h Pj26mUkzJdY9TOyIOMbYSOjKnGmMKw7chB+3c79gsnI6lcyZHlUrDUF9ZEWCIy2plJ RzWv/IP/rvDHHJJZiC4zq+78F3oL6/2RXjzhblIRHQDf3l7rYdI950Vf2WZPYlZgbJ 5reYdfILI6EZbpU6X5KE5XoWljOMa3LNqX2r0nzVv2SyphpX4YEfh4PE6L2t5KGE72 0sivgBdAsrGe3F5kRS5i1v0VLgjEKIvRzUPfHwf0CsItC/w6BOQL7qVggP/EmL8aSB zzHSXPxt9yJug== Message-ID: Date: Wed, 2 Dec 2026 14:53:17 +0900 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/3] dm zoned: handle labels that are not NUL-terminated To: Yingjie Wang , Alasdair Kergon , Mike Snitzer , Mikulas Patocka , Benjamin Marzinski Cc: "dm-devel@lists.linux.dev" , "linux-kernel@vger.kernel.org" , Hannes Reinecke , "stable@vger.kernel.org" References: <20261201105558.117053-1-x-professor@outlook.com> <20261201105625.117301-1-x-professor@outlook.com> <3f39a119-bbb2-40ed-8107-a20f8ea87fd9@kernel.org> <20261201121502.229596-1-x-professor@outlook.com> Content-Language: en-US From: Damien Le Moal Organization: Western Digital Research In-Reply-To: <20261201121502.229596-1-x-professor@outlook.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/1/26 21:15, Yingjie Wang wrote: > 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. No, I think the extra byte is still needed to be able to honor a device name up to BDEVNAME_SIZE with a NUL terminating character. That needs to stay. -- Damien Le Moal Western Digital Research