Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1227862ybz; Thu, 16 Apr 2020 05:27:03 -0700 (PDT) X-Google-Smtp-Source: APiQypJZaD959CDm1EECNzY/1/ZlAPiJqz5QZ6yeBgcG5KSaFljr3iK9RSCuCgMFfeVt2EEt5c4H X-Received: by 2002:aa7:c251:: with SMTP id y17mr29503790edo.117.1587040023654; Thu, 16 Apr 2020 05:27:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587040023; cv=none; d=google.com; s=arc-20160816; b=EgWmh6EYSXP0q2ppJqiRI91e79fpvWUfSEU/XWt4fwEosnwuy8ajFwxza8QuHx0WWI AjBiCxLdZz7GEAxEoyfhU2bzpo4PHjFdLZgFKCYRZYnzxeSxrepwvDZJ0M1/5GS34z8P 8AitxP8mp3nASG15+uwXqEutUgyJNVlfz7HAiMnR098doX/CJ6qixkaNXisuNrFzFmkF W64z0A6bg/rHVSoTHfhKnTeV1mBscvq0oSyQN4iDHrvv23nDxOMg8UeCGGfuTB7p30qP HrhSI8BNrEb13YguxKvE6DvBdhOgKRZYcQ63sKqJkohSKsGc5xYFrGD+fH4usQh9crFL /znw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ZmgSf0DaKnqt+g5YYFttHhnOP83Ik+RXIbY0uwVaCCs=; b=ANEXpxXL6s74Ie4qMhsvIH7PmljanP1/myDX0bLGPsytW3x5zB0aZvp3d7mzYZISr0 54GgoIJpcPTA96thR39bMvmQI/DefBDRpTi69V53toYn+Ia2TgAXqRH17DBQcKeuTmqJ 2Go7KtusIlI+0byYV6UyuPm0EGpNqNxFL5ZVWyXYGMiNHLh6k4bJ8SO1p5/8NGEKsdfY SRVosURfxIvjkVuDJhJXi0m6JBFcRI5M4Ecpo6jIly7emW1fI89Jjop73hYeZBNqFsJr rvehqMsiajsFqMwSELeq4clLXy1mK7+dCi1Rp2hYj+KJZS+kLCdLUSrkA2xkTkL/u3xE Htbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d4si11616427edz.591.2020.04.16.05.26.39; Thu, 16 Apr 2020 05:27:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2635550AbgDPMWr (ORCPT + 99 others); Thu, 16 Apr 2020 08:22:47 -0400 Received: from verein.lst.de ([213.95.11.211]:51261 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2635305AbgDPMWn (ORCPT ); Thu, 16 Apr 2020 08:22:43 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 2883668BEB; Thu, 16 Apr 2020 14:22:36 +0200 (CEST) Date: Thu, 16 Apr 2020 14:22:35 +0200 From: Christoph Hellwig To: Jan Kara Cc: Yufen Yu , Christoph Hellwig , axboe@kernel.dk, tj@kernel.org, bvanassche@acm.org, tytso@mit.edu, gregkh@linuxfoundation.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/8] bdi: add a ->dev_name field to struct backing_dev_info Message-ID: <20200416122235.GA26982@lst.de> References: <20200416071519.807660-1-hch@lst.de> <20200416071519.807660-4-hch@lst.de> <5bfcd35a-2463-3769-be93-911c4e3c38bb@huawei.com> <20200416120223.GI23739@quack2.suse.cz> <20200416121901.GA26483@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200416121901.GA26483@lst.de> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 16, 2020 at 02:19:01PM +0200, Christoph Hellwig wrote: > On Thu, Apr 16, 2020 at 02:02:23PM +0200, Jan Kara wrote: > > Yes, that can indeed happen. E.g. I remember that drivers/scsi/sd.c calls > > device_add_disk() + del_gendisk() repeatedly for one request_queue and that > > would result in leaking the name (and possibly cause use-after-free > > issues). > > Sd calls device_add_disk once in ->probe, and del_gendisk once in > sd_remove. Note that sd_probe allocates a new scsi_disk structure and > a new gendisk everytime, but it does indeed reuse the request_queue > and thus bdi. > > > I think dev_name has to be just a static array inside > > backing_dev_info which gets overwritten on reregistration. The question is > > how big should be this array... Some grepping shows that 40 bytes should be > > enough for everybody except fs/vboxsf/super.c which puts 'fc->source' into > > the name which can be presumably rather large. Anyway, I'd make it 40 and > > just truncate it case in case it does not fit. bdi_dev_name() is used for > > informational purposes anyway... > > We could just make it a variable sized array at the end of the structure > and size it based on the len. Which doesn't always work as the size might not always be the same. But I think the fundamental problem is that we are trying to re-register previous unregistered bdis. We really should not have bdi_alloc separate from bdi_register and solve this properly.