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=-3.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,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 810C4C433E0 for ; Thu, 11 Jun 2020 05:40:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1E0292074B for ; Thu, 11 Jun 2020 05:40:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Ep/0TGcR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1E0292074B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 787B66B00CA; Thu, 11 Jun 2020 01:40:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 711FF8D004C; Thu, 11 Jun 2020 01:40:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D9266B00CC; Thu, 11 Jun 2020 01:40:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0183.hostedemail.com [216.40.44.183]) by kanga.kvack.org (Postfix) with ESMTP id 4224D6B00CA for ; Thu, 11 Jun 2020 01:40:46 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id EA62A3574 for ; Thu, 11 Jun 2020 05:40:45 +0000 (UTC) X-FDA: 76915831650.07.salt20_0602d1526dd1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id C40901803FD61 for ; Thu, 11 Jun 2020 05:40:45 +0000 (UTC) X-HE-Tag: salt20_0602d1526dd1 X-Filterd-Recvd-Size: 4103 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Thu, 11 Jun 2020 05:40:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=nBcFQJGzJiEbDICiDXoaT+SkntQ3fuvNt0VNHFjSgyk=; b=Ep/0TGcRRFvDTNncjorrzAlS1t uBwCTucTGScB5pbbDZx9vslfW9Z0mIzzLY/SsE/G5vx1ZSk99lqNHEtaxjoMOpWaiv8DN8n++AERG fdLwww2/st6O6m4Tm0LALmQU/R8ug+VYSRV8nyhBiR1kzFNoVI+1Csc0tRlNXeNy/E7hV08CBjf+C rexEqTsiuZitiFCW9wTUQ4bLVl3FrFIX17F5oly+MpJk2iM23f+3TIeWs3mjLR2yQfTBuDBNYZq/J bwRHxWR4lAqEz4fiUOCWDPWMhOUKc4nbQNbCQ2QURpZKfQYbLb5hP9IloOIkU/brrMfTCxwYbl5kQ lOAbNbag==; Received: from hch by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jjFwb-0007iI-9y; Thu, 11 Jun 2020 05:40:05 +0000 Date: Wed, 10 Jun 2020 22:40:05 -0700 From: Christoph Hellwig To: Luis Chamberlain Cc: Christoph Hellwig , Jan Kara , axboe@kernel.dk, viro@zeniv.linux.org.uk, bvanassche@acm.org, gregkh@linuxfoundation.org, rostedt@goodmis.org, mingo@redhat.com, ming.lei@redhat.com, nstange@suse.de, akpm@linux-foundation.org, mhocko@suse.com, yukuai3@huawei.com, martin.petersen@oracle.com, jejb@linux.ibm.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 v6 6/6] blktrace: fix debugfs use after free Message-ID: <20200611054005.GA25742@infradead.org> References: <20200608170127.20419-1-mcgrof@kernel.org> <20200608170127.20419-7-mcgrof@kernel.org> <20200609150602.GA7111@infradead.org> <20200609172922.GP11244@42.do-not-panic.com> <20200609173218.GA7968@infradead.org> <20200609175359.GR11244@42.do-not-panic.com> <20200610064234.GB24975@infradead.org> <20200610210917.GH11244@42.do-not-panic.com> <20200610215213.GH13911@42.do-not-panic.com> <20200610233116.GI13911@42.do-not-panic.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200610233116.GI13911@42.do-not-panic.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspamd-Queue-Id: C40901803FD61 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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 Wed, Jun 10, 2020 at 11:31:16PM +0000, Luis Chamberlain wrote: > On Wed, Jun 10, 2020 at 09:52:13PM +0000, Luis Chamberlain wrote: > > diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c > > index 7ff2ea5cd05e..5cea04c05e09 100644 > > --- a/kernel/trace/blktrace.c > > +++ b/kernel/trace/blktrace.c > > @@ -524,10 +524,16 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, > > if (!bt->msg_data) > > goto err; > > > > - ret = -ENOENT; > > - > > - dir = debugfs_lookup(buts->name, blk_debugfs_root); > > - if (!dir) > > + /* > > + * When tracing whole make_request drivers (multiqueue) block devices, > > + * reuse the existing debugfs directory created by the block layer on > > + * init. For request-based block devices, all partitions block devices, > > + * and scsi-generic block devices we create a temporary new debugfs > > + * directory that will be removed once the trace ends. > > + */ > > + if (queue_is_mq(q)) > > And this should be instead: > > if (queue_is_mq(q) && bdev && bdev == bdev->bd_contains) Yes. But I think keeping the queue_is_mq out and always creating the debugfs dir is an improvement as we'll sooner or later grow more debugfs files and than the whole set of problmes reappears. But I'd be fine with doing the above in the first patch that is tiny and backportable, and then have another patch that always creates the debugfs directory.