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=1796193793; b=zLCsZZn8YE2UDFjpmHQZHoW8KgQAUlzL2y8onT396M3sEoYIFQEOo4fg/HOQAkvZOEqA 8US11+ukugw70grlwLiVK5mnw6LMZtt0MCgBxFUoIXdZOD4wNaONqjduwueTIAucfydPF wPbWvgXVxp/1xIEhaWN8AQt7l6iv02wlFlUYGlay7NDlZGc4VhZQOHfcAig1olgZmHc7r 088jtYuJKvlCqEHBPfW8tWj5W8YL4YmpY3ylGmoUjyva42+pTpL3VX4tu6U/m2rIocry7 LQXm/ZzkypcVeeTFja8F2+zfxfbToXiY5ERW9PclyhOiIEvX5lEsrvcmh369BZpEOhg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796193793; 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=oqW3FL6jNCzSRgN22eXeAmXfaZAC6bcng3TTABa+GRU=; b=QheaIP72Q418ERR3OhccRKRMJLewNrYFPaMnZeJ5WwqzHFEdxRyJULOnLwokF/+GBpgs KxGmB86jXhxuV84KoQq8DKpvtAthNxWDtBxw5IETRxNNmiiEjSCGuI7Y4NKVezm7G0UU/ 8zYdiWEWGIVP3xzoukCTWq3SsRfFD/x8KmGkg8i05MF+n9bODzkXD+tEI4Fhoe8ggvn1C PAKE3mbHm3Yz8Zc/lZhWcwP2xu2nMu2MmcFQoPmkbhvTLwV9quUuFpH8XR7GcIu9KCoQi XUTZpxYRlituC978ShP34BPt9XHJq/V0ZWW8W6HnteTrfmqVklyBBsqO3idNJX0NtXg== 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=Au5dznJ5; 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 8E396606A338; Wed, 2 Dec 2026 06:43:13 +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=Au5dznJ5 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9E951F0089B; Wed, 2 Dec 2026 06:43:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796193793; bh=oqW3FL6jNCzSRgN22eXeAmXfaZAC6bcng3TTABa+GRU=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=Au5dznJ5sV6o7yU89tuNaa4M9OkH/vkatG+bXJibZpWYOi7xTWwq2kYhf3ODc4cql 1JWNe55mZObbsrWq/NZQZe9DQxMxAkGBM6zASXNJlXtb8S3ubZCsqN1eOZwZwyZ3Fq v++Nt26qow5jtgNyayFqT6qbNempxAZJe6AVgVHnABdVQuUjkAF++QununI4ema3BG nglFKico307Bt4wMfPaSBsyiyKX0vVHXuI88pTpQNIgKqfYP1Er83oMvDDXk0OAOje 0v0WS7L76zEnEaARf7Ec4jadEUn/ri4JbDO+DMdsrZgvcrcIdeBA9c2v23iW6sbaZE gIeom+FQGzT8Q== Message-ID: <89e33f59-1103-4cd5-8666-dce77102c472@kernel.org> Date: Wed, 2 Dec 2026 15:43:10 +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 2/3] dm zoned: validate the metadata layout in the superblock 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> <20261201105617.117226-1-x-professor@outlook.com> Content-Language: en-US From: Damien Le Moal Organization: Western Digital Research In-Reply-To: <20261201105617.117226-1-x-professor@outlook.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/1/26 19:56, Yingjie Wang wrote: > dmz_check_sb() does not check all the superblock fields that describe > the metadata layout: > > - nr_map_blocks is used to allocate zmd->map_mblk[], which > dmz_load_mapping() then fills according to nr_chunks. If there are > not enough mapping blocks for nr_chunks, it writes past the end of > the array: > > BUG: KASAN: slab-out-of-bounds in dmz_ctr_metadata > Write of size 8 > > - nr_bitmap_blocks is not used to locate the bitmap of a zone. > dmz_get_bitmap() assumes that there is a bitmap for every zone. > This is not the case if the device has grown since it was formatted. > The bitmaps of the new zones are not part of the metadata sets then, > and the data in these zones can be lost after a set was recovered. > > - The mapping and bitmap blocks may exceed nr_meta_blocks, so that > metadata accesses go past the end of the metadata set. This can > overwrite the data of other chunks. > > - nr_reserved_seq is checked against the number of zones that remain > after subtracting one metadata set, but nr_data_zones is calculated > by subtracting both sets. The result can underflow, which defeats > the check of nr_chunks. > > Add the missing checks. dmzadm creates one bitmap for every zone, > including metadata, read-only and offline zones, so that volumes it > formatted are not affected unless the device has grown. > > Fixes: 3b1a94c88b79 ("dm zoned: drive-managed zoned block device target") > Cc: stable@vger.kernel.org > Signed-off-by: Yingjie Wang Looks good. Reviewed-by: Damien Le Moal -- Damien Le Moal Western Digital Research