From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E370AC4321E for ; Mon, 5 Dec 2022 16:38:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232383AbiLEQiy (ORCPT ); Mon, 5 Dec 2022 11:38:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232676AbiLEQi0 (ORCPT ); Mon, 5 Dec 2022 11:38:26 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D78B20F54; Mon, 5 Dec 2022 08:36:52 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 9BF54CE0EDA; Mon, 5 Dec 2022 16:36:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89511C433D6; Mon, 5 Dec 2022 16:36:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1670258206; bh=fbpcwdKaJc7AJTNyA9TDEKsFnJyGmmESF0Wd/ZFzdbI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Kh583MNyjgC8duE4cNwoW6/cRGCCa4/0sjHjB9ls5BYonNjN0x1V20qj3usHKybqK O7iHhhkkqNdd5sgIbS06TLzofkIX+yW9e24EjFGdfbAjrQl1+JT0KQb9VXNjlQGG1S mc4pUBDKzu6gSU+rgriGXEwraHrc7CzK+wjxj3rA= Date: Mon, 5 Dec 2022 17:36:44 +0100 From: Greg Kroah-Hartman To: Jens Axboe Cc: Ming Lei , stable@vger.kernel.org, linux-block@vger.kernel.org, Shiwei Cui , Christoph Hellwig , Jan Kara Subject: Re: [PATCH 5.10.y stable v2] block: unhash blkdev part inode when the part is deleted Message-ID: References: <20221205132739.844399-1-ming.lei@redhat.com> <50de97fe-43f1-188f-511a-f29611944ce7@kernel.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <50de97fe-43f1-188f-511a-f29611944ce7@kernel.dk> Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Mon, Dec 05, 2022 at 08:19:23AM -0700, Jens Axboe wrote: > On 12/5/22 8:08 AM, Greg Kroah-Hartman wrote: > > On Mon, Dec 05, 2022 at 09:27:39PM +0800, Ming Lei wrote: > >> v5.11 changes the blkdev lookup mechanism completely since commit > >> 22ae8ce8b892 ("block: simplify bdev/disk lookup in blkdev_get"), > >> and small part of the change is to unhash part bdev inode when > >> deleting partition. Turns out this kind of change does fix one > >> nasty issue in case of BLOCK_EXT_MAJOR: > >> > >> 1) when one partition is deleted & closed, disk_put_part() is always > >> called before bdput(bdev), see blkdev_put(); so the part's devt can > >> be freed & re-used before the inode is dropped > >> > >> 2) then new partition with same devt can be created just before the > >> inode in 1) is dropped, then the old inode/bdev structurein 1) is > >> re-used for this new partition, this way causes use-after-free and > >> kernel panic. > >> > >> It isn't possible to backport the whole big patchset of "merge struct > >> block_device and struct hd_struct v4" for addressing this issue. > >> > >> https://lore.kernel.org/linux-block/20201128161510.347752-1-hch@lst.de/ > >> > >> So fixes it by unhashing part bdev in delete_partition(), and this way > >> is actually aligned with v5.11+'s behavior. > >> > >> Reported-by: Shiwei Cui > >> Tested-by: Shiwei Cui > >> Cc: Christoph Hellwig > >> Cc: Jan Kara > >> Signed-off-by: Ming Lei > >> --- > >> V2: > >> - fix one typo and Shiwei's email format > >> > >> block/partitions/core.c | 7 +++++++ > > > > I need an ack from the block maintainers/developers to be able to take > > this. > > Acked-by: Jens Axboe Thanks, now queued up for 5.10.y greg k-h