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 X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB6ECC433ED for ; Thu, 29 Apr 2021 14:42:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A449661447 for ; Thu, 29 Apr 2021 14:42:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240303AbhD2Omy (ORCPT ); Thu, 29 Apr 2021 10:42:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53603 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234862AbhD2Omx (ORCPT ); Thu, 29 Apr 2021 10:42:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619707327; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=5j+rL0qw44y0T4crpkr6NmrX5ib7bkJ4lhhHCiai/js=; b=iMfvgzpNeftDYm8auyrjNWT6w67bykFmjlAt/bSJqzHOOZ0Nm7FM3wORk5Ifta9y20CW7g wr/BY/Kyx/YYqke3UigyQEWUJy8dBD24vkFI/WG4LTlJzGn0EgcC+G8fSZuCvU4949F3hL EXsUcgN4GHv2JUZEtaSq95QR9v5vFz8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-37-MXezInh7OiyCWToQuYkGYw-1; Thu, 29 Apr 2021 10:42:03 -0400 X-MC-Unique: MXezInh7OiyCWToQuYkGYw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7D21D8CCFEC; Thu, 29 Apr 2021 14:42:01 +0000 (UTC) Received: from T590 (ovpn-12-74.pek2.redhat.com [10.72.12.74]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F0DF679F3; Thu, 29 Apr 2021 14:41:53 +0000 (UTC) Date: Thu, 29 Apr 2021 22:42:03 +0800 From: Ming Lei To: Christoph Hellwig Cc: Jens Axboe , Jeffle Xu , Damien Le Moal , Keith Busch , Sagi Grimberg , "Wunderlich, Mark" , "Vasudevan, Anil" , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 12/15] block: switch polling to be bio based Message-ID: References: <20210427161619.1294399-1-hch@lst.de> <20210427161619.1294399-13-hch@lst.de> <20210429072028.GA3682@lst.de> <20210429095036.GA15615@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210429095036.GA15615@lst.de> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On Thu, Apr 29, 2021 at 11:50:36AM +0200, Christoph Hellwig wrote: > On Thu, Apr 29, 2021 at 03:36:14PM +0800, Ming Lei wrote: > > > > ->bi_bdev and associated disk/request_queue/hctx/... refrerred in bio_poll() > > > > may have being freed now, so there is UAF risk. > > > > > > the block device is RCU freed, so we are fine there. There rest OTOH > > > is more interesting. Let me think of a good defense using some kind > > > of liveness check. > > > > Or hold gendisk reference in bdev lifetime, then everything referred > > won't be released until bdev is freed. > > The whole device bdev controls the gendisk liftetime, so that one is > easy. But for partitions it is probably a good idea to ensure that > the gendisk is kept allocated as long as the block devices are around > as well. Looks we needn't to care if the bdev is disk or partition: bdev is always associated with gendisk via ->bd_disk, the gendisk instance has to be kept alive since bio->bi_bdev->bd_disk is used everywhere almost. Thanks, Ming