Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1605181ybz; Thu, 16 Apr 2020 12:07:47 -0700 (PDT) X-Google-Smtp-Source: APiQypIo73y8AU3y1J78I0W6izCZL4DdFzBdLGx8TV4YG7P9kYW2Zn/CscbqVyvxZmdnV5yE29mZ X-Received: by 2002:a17:906:3709:: with SMTP id d9mr11514094ejc.94.1587064067732; Thu, 16 Apr 2020 12:07:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587064067; cv=none; d=google.com; s=arc-20160816; b=n44Y1E4As4LHBIzg87UJEHSjZ9hREglYUtVxmPzBuTTBFPHlfnfVh2Z7Lip7QPCIB3 lSgALysEgkYssaIb2KH1iWgzNgcGKEGWjVcwtR0kw09u/c73+RXJk/mkq1mQ+7aSC2wp gIe13J5TdJHCN1zJTwAtcVG4n25eus0HAoNnHzjs1YG1XHLGOLggSqOjZslMiHBJ1upc IeWj9akvYGcWOHLSAFyzDU6gLRqtdM9Qh2osybvbPTg+8/Q9YlYWLG2BUY9p+E9scV8q Bih/AASGXZdN2lxhdqrJnCJzXCSg1iY4wMymyej2zbwAzDNbn139eeO32Mua9No8B9Yr iaoQ== 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=lXw/WEN+sl/WlrVx//TpiKXbN6I53bFkRYYy7ToAipo=; b=S9hBqCYRTOoR9KyZK37RPyKXGbvgActqVIgG7ZfLA0cOjfj+rWWTTTfohg/J+I/6VX YxvddhKHuIXartKpNmbL1YvO3UWSc/BFEa1hWiE9H2WA1vPZKaKeUqJjKv12gLS2woox EkjO2v2yqLc1OC5Iigy8oPnAyQaJbnTNP/VOi5op5ihxbfqpbpn3F4GpEiIU2Ix3vWjy savPfvHzqth8qFXvbWjuYAUnCXDOHidQCjY36sXRbTqaeTnnak/UljKc4TGS5aVcMRON SxDSCP1DRM7q5jMiQVP+rZKZAk7vwQyyYBuOujfFMBL+dUZ1GPMhc63f4byFwRnlilv9 6I3Q== 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 gx5si8934582ejb.74.2020.04.16.12.07.24; Thu, 16 Apr 2020 12:07:47 -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 S2635227AbgDPMTI (ORCPT + 99 others); Thu, 16 Apr 2020 08:19:08 -0400 Received: from verein.lst.de ([213.95.11.211]:51210 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2635208AbgDPMTF (ORCPT ); Thu, 16 Apr 2020 08:19:05 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id A893A68BEB; Thu, 16 Apr 2020 14:19:01 +0200 (CEST) Date: Thu, 16 Apr 2020 14:19:01 +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: <20200416121901.GA26483@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200416120223.GI23739@quack2.suse.cz> 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: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.