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=1796190913; b=I8XSbgguXRjGxVefXxprOHiexhPqFCsZaH/PuYMUvE0/iZJedD2pqFHamOKUpUxUSLrt qTLhWJvWGorHMEOOuiSNrUdXRUt/HxxJtRVjprtPJtrGM1UW2U9fZcNVoAOWX3A5gsB54 CELpEPcskFXxxQfLphvmpeQX8Au92yJhUHXKeA3Bej+Xo4BG7EghGW3XFoXoL/6OB2SS0 altjoKQxqAWnXqMKR0RLaAGeF3P0+aT+KIjb1xjVmPwdSmPXFIqjENCb9sFXuUkMoYRhC yDbdUhF22k62fCsypSaSspv3oqPcGmMUYyrk4cuuCxjT6ETKl8CAl9AtzsA0yBlL0WQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796190913; 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=30PODtjxShXAaB81nfXEtnAeEKz5ibr72T85RQcOjuY=; b=3yiA///CCqgYJDxyTLpaWL1MKskqmYAl875PnuUW3VP/dySYNfJGs37c47IslfSF8379 Axtjo3/860mzHgnfkkR3tslZYt00m9TaRJMtU0+wMwE05/YJHw1e7xsSXo0k1bUHKMsN3 cGkwWOFcXTPIaLIVCrx9yrpbDT0e0AEyXX2zvG3LiHA2aEqc8+mefksuZtYXgwQtozZU5 LObEefulzbk0Bq8OzQG2zyZ+ll5w+dxnfxdFQTRm7CUkUg4EsA2/K/vJnAdG8mk62Jf+8 b70HKg5wmeqBTXcMaCHfgQ2W+nvp6i4p/PYz4iBLwBb6jWq3d/HO8rbqzD1ZH3VRjSw== 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=A3m7QzAg; 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 95C07606A332; Wed, 2 Dec 2026 05:55: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=A3m7QzAg Received: by smtp.kernel.org (Postfix) with ESMTPSA id D197C1F0089A; Wed, 2 Dec 2026 05:55:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796190913; bh=30PODtjxShXAaB81nfXEtnAeEKz5ibr72T85RQcOjuY=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=A3m7QzAgsO9znllC8nmoPXg57GgXsjcPjoOSzscAFRRFbTtmI5vF9O2uLMyPTzZHk 0GHCOuek4Ym34LPxeYQVCpj3VPYCYvFAGd6NCv/OaC0gWUP56qadisGJgEERA2FvjA PYKmGCXU/gzQquBXH9capxtjaiCo0E9KogdBqUFrwqCAVFx1yq5CTX6IKyOIiaCPEc 8uodo2tdwz8zapjnGarQ5nB7hN6EzaCd4ucxXQuanWxsE94o7jNxsLr3YC69MKvoTH U0BWVgYQ9ElcZbnxHkrOqW2EDKpQEnwvgZWcgEVr3hLLM3eJXToAalgeTZ9g2spoxm rw/1oYaAGRUow== Message-ID: <0a6a5a92-fe48-40d6-9ce5-7cb4c43757a3@kernel.org> Date: Wed, 2 Dec 2026 14:55: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 1/3] dm zoned: fix invalid free when reading a tertiary superblock fails To: Yingjie Wang , Alasdair Kergon , Mike Snitzer , Mikulas Patocka , Benjamin Marzinski Cc: "dm-devel@lists.linux.dev" , "linux-kernel@vger.kernel.org" , Hannes Reinecke , Dan Carpenter , "stable@vger.kernel.org" References: <20261130161425.3535695-1-x-professor@outlook.com> <20261130161700.3536656-1-x-professor@outlook.com> Content-Language: en-US From: Damien Le Moal Organization: Western Digital Research In-Reply-To: <20261130161700.3536656-1-x-professor@outlook.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/1/26 01:17, Yingjie Wang wrote: > dmz_get_sb() does not leave a block to free when it fails. If the read > fails, it frees the block and sets sb->mblk to NULL. If the allocation > fails, it does not touch sb->mblk, which is either NULL or, after the > first iteration of the loop, points to the block that was freed by the > previous one. > > dmz_load_sb() nevertheless calls dmz_free_mblock() in this case. A > read error on the first block of a zoned device therefore results in a > NULL pointer dereference: > > (zoned1): Read tertiary super block failed > KASAN: null-ptr-deref in range [0x0000000000000040-0x0000000000000047] > > An allocation failure can result in a double free, as reported by > Smatch. > > Remove the bogus dmz_free_mblock() call. > > Fixes: 5d2c74f3ddc0 ("dm zoned: allocate temporary superblock for tertiary devices") > Reported-by: Dan Carpenter > Closes: https://lore.kernel.org/dm-devel/ahrruAVoUpDmh6Cf@stanley.mountain/ > Suggested-by: Dan Carpenter > Cc: stable@vger.kernel.org > Signed-off-by: Yingjie Wang Reviewed-by: Damien Le Moal -- Damien Le Moal Western Digital Research