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=-2.5 required=3.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 323DFC5518C for ; Wed, 22 Apr 2020 08:26:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F0E7E2074F for ; Wed, 22 Apr 2020 08:26:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F0E7E2074F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8D7B98E0006; Wed, 22 Apr 2020 04:26:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 838468E0003; Wed, 22 Apr 2020 04:26:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6FF978E0006; Wed, 22 Apr 2020 04:26:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0088.hostedemail.com [216.40.44.88]) by kanga.kvack.org (Postfix) with ESMTP id 54EE88E0003 for ; Wed, 22 Apr 2020 04:26:19 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 04A32181AEF1A for ; Wed, 22 Apr 2020 08:26:19 +0000 (UTC) X-FDA: 76734808878.22.dog71_8e6876f288022 X-HE-Tag: dog71_8e6876f288022 X-Filterd-Recvd-Size: 4892 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Wed, 22 Apr 2020 08:26:18 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id b8so700361pfp.8 for ; Wed, 22 Apr 2020 01:26:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=8i3s56k4FMGcvexGwr0CiDNJKnDe69VPIGR2Ex4KDzk=; b=pWMiDtQw7X0TEOYexIcElZ8la9f0MFot4E1cGSnnPxFnn6pxBQNpwA8fv+2TCIB6Pm RHC1fkCTiAz29maCPJyRHass1Fgwf2bCHOEghWSwakv5NkrLHeN2fsRn/dMNMRb9Kbc4 BpLanyznx/kGDhMjyZeozTtHfqat9BMXr0KMSZ5D5rXa9/EKOLs0R0srLfSW1WyUL+hD 3F6rjiw9YyIpiJ/29xQxbBsg118Y5x+FBIxwKznaFvkpASyKtK/XKvPgTSTSd5TAOlu/ ivl/ATZSH+ueULb95s9HgSwUsaOgZEJauH4WJ/qGxhkXKh4Fx/Tpv5ZxYouhw8Pzyd9o kn0w== X-Gm-Message-State: AGi0PuYIS4AfE1TuvvGy2er2oM/G2SJSbaldENasuZE/V26gfCH/CoWN c/1YYx0DQoYZAwTi8imr1Eg= X-Google-Smtp-Source: APiQypIGS3BmOJ3kOCU3MzTcBmmcDehn1M4KxdV6lt1hvbYSD4+iDCsRidjNpHdHB5Di/2A0u0IqDg== X-Received: by 2002:aa7:9811:: with SMTP id e17mr25216152pfl.70.1587543977422; Wed, 22 Apr 2020 01:26:17 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id b20sm4626488pff.8.2020.04.22.01.26.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Apr 2020 01:26:09 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 8C3D2402A1; Wed, 22 Apr 2020 08:26:04 +0000 (UTC) Date: Wed, 22 Apr 2020 08:26:04 +0000 From: Luis Chamberlain To: Christoph Hellwig Cc: axboe@kernel.dk, viro@zeniv.linux.org.uk, bvanassche@acm.org, gregkh@linuxfoundation.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 v2 03/10] blktrace: fix debugfs use after free Message-ID: <20200422082604.GT11244@42.do-not-panic.com> References: <20200419194529.4872-1-mcgrof@kernel.org> <20200419194529.4872-4-mcgrof@kernel.org> <20200422072715.GC19116@infradead.org> <20200422074802.GS11244@42.do-not-panic.com> <20200422081011.GA22409@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200422081011.GA22409@infradead.org> User-Agent: Mutt/1.10.1 (2018-07-13) 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, Apr 22, 2020 at 01:10:11AM -0700, Christoph Hellwig wrote: > On Wed, Apr 22, 2020 at 07:48:02AM +0000, Luis Chamberlain wrote: > > > I don't see why we need this check. If it is valueable enough we > > > should have a debugfs_create_dir_exclusive or so that retunrns an error > > > for an exsting directory, instead of reimplementing it in the caller in > > > a racy way. But I'm not really sure we need it to start with. > > > > In short races, and even with synchronous request_queue removal I'm > > seeing the race is still possible, but that's due to some other races > > I'm going to chase down now. > > > > The easier solution really is to just have a debugfs dir created for > > each partition if debugfs is enabled, this way the directory will > > always be there, and the lookups are gone. > > That sounds like the best plan to me. Groovy. > > > > + > > > > + q->debugfs_dir = debugfs_create_dir(kobject_name(q->kobj.parent), > > > > + blk_debugfs_root); > > > > + if (!q->debugfs_dir) > > > > + return -ENOMEM; > > > > + > > > > + return 0; > > > > +} > > > > + > > > > +void blk_queue_debugfs_unregister(struct request_queue *q) > > > > +{ > > > > + debugfs_remove_recursive(q->debugfs_dir); > > > > + q->debugfs_dir = NULL; > > > > +} > > > > > > Which to me suggests we can just fold these two into the callers, > > > with an IS_ENABLED for the creation case given that we check for errors > > > and the stub will always return an error. > > > > Sorry not sure I follow this. > > Don't both with the two above functions and just open code them in > the callers. IFF you still want to check for errors after the > discussion with Greg, wrap the call in a > > if (IS_ENABLED(CONFIG_DEBUG_FS)) > > to ensure that you don't fail queue creation in the !DEBUG_FS > case. Got it, thanks. Luis