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 141DBC433E0 for ; Tue, 9 Jun 2020 17:54:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DA58020801 for ; Tue, 9 Jun 2020 17:54:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA58020801 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 6DE276B0003; Tue, 9 Jun 2020 13:54:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 68D716B0005; Tue, 9 Jun 2020 13:54:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A2656B0006; Tue, 9 Jun 2020 13:54:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0242.hostedemail.com [216.40.44.242]) by kanga.kvack.org (Postfix) with ESMTP id 423D36B0003 for ; Tue, 9 Jun 2020 13:54:07 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 018AE172C75 for ; Tue, 9 Jun 2020 17:54:06 +0000 (UTC) X-FDA: 76910422134.13.fog15_501656326dc4 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id CF4C61811F8B7 for ; Tue, 9 Jun 2020 17:54:02 +0000 (UTC) X-HE-Tag: fog15_501656326dc4 X-Filterd-Recvd-Size: 5170 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Tue, 9 Jun 2020 17:54:02 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id s88so1718504pjb.5 for ; Tue, 09 Jun 2020 10:54:02 -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=l535t0gtEMhwRmJuEGpot34AcMJTeoyuOmb6/SPxdIo=; b=iz44fWAkX5kMjkuRaOtZZj7bHB/EuRtGVc7x7uuBpGueBXJhU4Q2m/hfdsP/YnX56J SyU6LfAe6bK5pe1vIoTZvcsnt1Vu/wqE76F6JkxKOC1rt7Osqk+Dj/amlI/ka18uIkYF msZe/3GFvs/CWmI8ss4JuUXQB/uOR6ketyPy1urpHe4XUUWTKpazLIb+ZvK8OCQntYXm 2YUzjVqT8ho5f/nA80Hjn3ELzag4s2rXaACqmJNEyZXgk8X3pu0Ju7QY4aCt9bSM6BUR MqsKPGc8DO5Gh2NyZQM7X+q5wphZP+3IOBosrVItlqhVf4omkDJy/C1Q7itD5hC/dgHP NsRw== X-Gm-Message-State: AOAM530wxXx3DKuQh8Ahj5IeXsKCGZjPTeWZjEe0VDb9QfodOx+2ytPG uAXwpldxRqVgdQNGfcrc9fE= X-Google-Smtp-Source: ABdhPJy/NmjQ3jEGM1rDQ6v1rJGJ2kfZGaht+oE0SOlu7pxqvuGtyZmIoYsQQ37mHn9Ym+N88QSF5w== X-Received: by 2002:a17:902:ee93:: with SMTP id a19mr4432067pld.144.1591725241302; Tue, 09 Jun 2020 10:54:01 -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 x77sm10745875pfc.4.2020.06.09.10.54.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 10:54:00 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id A13B6403AB; Tue, 9 Jun 2020 17:53:59 +0000 (UTC) Date: Tue, 9 Jun 2020 17:53:59 +0000 From: Luis Chamberlain To: Christoph Hellwig Cc: 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: <20200609175359.GR11244@42.do-not-panic.com> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200609173218.GA7968@infradead.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Queue-Id: CF4C61811F8B7 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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, Jun 09, 2020 at 10:32:18AM -0700, Christoph Hellwig wrote: > On Tue, Jun 09, 2020 at 05:29:22PM +0000, Luis Chamberlain wrote: > > Is scsi-generic is the only unwanted ugly child blktrace has to deal > > with? For some reason I thought drivers/md/md.c was one but it seems > > like it is not. Do we have an easy way to search for these? I think > > this would just affect how we express the comment only. > > grep for blk_trace_setup. For all blk devices that setup comes in > through the block device ioctl path, and that relies on having a > struct block_device and queue. sg on the other hand calls > blk_trace_setup directly with a NULL bdev argument. Alright, then we should be good. > > > */ > > > - dir = q->sg_debugfs_dir; > > > + dir = debugfs_create_dir(buts->name, blk_debugfs_root); > > > + bt->dir = dir; > > > > The other chicken and egg problem to consider at least in the comments > > is that the debugfs directory for these types of devices *have* an > > exposed path, but the data structure is rather opaque to the device and > > even blktrace. Fortunately given the recent set of changes around the > > q->blk_trace and clarifications around its use we have made it clear now > > that so long as hold the q->blk_trace_mutex *and* check q->blk_trace we > > *should* not race against two separate creations of debugfs directories, > > so I think this is safe, so long as these indpendent drivers don't end > > up re-using the same path for some other things later in the future, and > > since we have control over what goes under debugfsroot block / I think > > we should be good. > > > > But I think that the concern for race on names may still be worth > > explaining a bit here. > > Feel free to add more comments, but please try to keep them short > and crisp. At the some point long comments really distract from what > is going on. Sure. Come to think of it, given the above, I think we can also do way with the the partition stuff too, and rely on the buts->name too. I'll try this out, and test it. Luis