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=-0.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,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 D0E47C433E2 for ; Tue, 19 May 2020 17:03:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8FD892075F for ; Tue, 19 May 2020 17:03:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="x4PuJalf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8FD892075F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3533B80009; Tue, 19 May 2020 13:03:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 301D2900002; Tue, 19 May 2020 13:03:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2194C80009; Tue, 19 May 2020 13:03:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0113.hostedemail.com [216.40.44.113]) by kanga.kvack.org (Postfix) with ESMTP id 06399900002 for ; Tue, 19 May 2020 13:03:50 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id AFC4E4427 for ; Tue, 19 May 2020 17:03:49 +0000 (UTC) X-FDA: 76834090578.28.news91_78ae4607d7e45 X-HE-Tag: news91_78ae4607d7e45 X-Filterd-Recvd-Size: 4562 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Tue, 19 May 2020 17:03:49 +0000 (UTC) Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F01F120708; Tue, 19 May 2020 17:03:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589907828; bh=xbj4MKDaCQ/uq8PfAJ4JLhs4zm+BOFwwLkxXtJGNpRE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=x4PuJalfL2SwbUTdnUodUzcp+f41a2ge99eJTrO6kfYTyLHJWF96dQSI/a8xRkwMs 1Q6o4brIC0ng5v2SQMyLhTNO/JSB63X6UOWT52Wl60j/hmtTpCts5SHLjID4FZF8gq qE4tcCxgB9RfvgwyMA8VtkKqCGOQSXBexbE9Ytw4= Date: Tue, 19 May 2020 19:03:46 +0200 From: Greg KH To: Luis Chamberlain Cc: axboe@kernel.dk, viro@zeniv.linux.org.uk, bvanassche@acm.org, rostedt@goodmis.org, mingo@redhat.com, jack@suse.cz, ming.lei@redhat.com, nstange@suse.de, akpm@linux-foundation.org, mhocko@suse.com, yukuai3@huawei.com, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Omar Sandoval , Hannes Reinecke , Michal Hocko , syzbot+603294af2d01acfdd6da@syzkaller.appspotmail.com Subject: Re: [PATCH v5 5/7] blktrace: fix debugfs use after free Message-ID: <20200519170346.GB1064707@kroah.com> References: <20200516031956.2605-1-mcgrof@kernel.org> <20200516031956.2605-6-mcgrof@kernel.org> <20200519144408.GA737365@kroah.com> <20200519155210.GU11244@42.do-not-panic.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200519155210.GU11244@42.do-not-panic.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, May 19, 2020 at 03:52:10PM +0000, Luis Chamberlain wrote: > On Tue, May 19, 2020 at 04:44:08PM +0200, Greg KH wrote: > > On Sat, May 16, 2020 at 03:19:54AM +0000, Luis Chamberlain wrote: > > > struct dentry *blk_debugfs_root; > > > +struct dentry *blk_debugfs_bsg = NULL; > > > > checkpatch didn't complain about "= NULL;"? > > Will remove. > > > > +static void queue_debugfs_register_type(struct request_queue *q, > > > + const char *name, > > > + enum blk_debugfs_dir_type type) > > > +{ > > > + struct dentry *base_dir = queue_get_base_dir(type); > > > > And it could be a simple if statement instead. > > > > Oh well, I don't have to maintain this :) > > I'll just use that, but yeah I think its a matter of preference. > > > > +/** > > > + * blk_queue_debugfs_register - register the debugfs_dir for the block device > > > + * @q: the associated request_queue of the block device > > > + * @name: the name of the block device exposed > > > + * > > > + * This is used to create the debugfs_dir used by the block layer and blktrace. > > > + * Drivers which use any of the *add_disk*() calls or variants have this called > > > + * automatically for them. This directory is removed automatically on > > > + * blk_release_queue() once the request_queue reference count reaches 0. > > > + */ > > > +void blk_queue_debugfs_register(struct request_queue *q, const char *name) > > > +{ > > > + queue_debugfs_register_type(q, name, BLK_DBG_DIR_BASE); > > > +} > > > +EXPORT_SYMBOL_GPL(blk_queue_debugfs_register); > > > + > > > +/** > > > + * blk_queue_debugfs_unregister - remove the debugfs_dir for the block device > > > + * @q: the associated request_queue of the block device > > > + * > > > + * Removes the debugfs_dir for the request_queue on the associated block device. > > > + * This is handled for you on blk_release_queue(), and that should only be > > > + * called once. > > > + * > > > + * Since we don't care where the debugfs_dir was created this is used for all > > > + * types of of enum blk_debugfs_dir_type. > > > + */ > > > +void blk_queue_debugfs_unregister(struct request_queue *q) > > > +{ > > > + debugfs_remove_recursive(q->debugfs_dir); > > > +} > > > > Why is register needed to be exported, but unregister does not? Does > > some driver not properly clean things up? > > Is the comment on blk_queue_debugfs_register() not sufficient? Ah, hm, ok, I guess so. > I thought I was going overboard with how clear this was. Should I also > add a note here on unregister? Not really, it's fine, thanks. greg k-h