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 C91D0C433E2 for ; Mon, 22 Jun 2020 12:42:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 95D3A2071A for ; Mon, 22 Jun 2020 12:42:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 95D3A2071A 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 254B86B0002; Mon, 22 Jun 2020 08:42:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 22CFA6B0003; Mon, 22 Jun 2020 08:42:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 11AA16B0005; Mon, 22 Jun 2020 08:42:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0144.hostedemail.com [216.40.44.144]) by kanga.kvack.org (Postfix) with ESMTP id EB3AC6B0002 for ; Mon, 22 Jun 2020 08:42:12 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5EDC3180AD807 for ; Mon, 22 Jun 2020 12:42:12 +0000 (UTC) X-FDA: 76956810504.10.house84_550866c26e32 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id 2A0E416A040 for ; Mon, 22 Jun 2020 12:42:12 +0000 (UTC) X-HE-Tag: house84_550866c26e32 X-Filterd-Recvd-Size: 5517 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Mon, 22 Jun 2020 12:42:11 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id a127so8343418pfa.12 for ; Mon, 22 Jun 2020 05:42:11 -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=eZIvSoaeoetQ1jhe+tUmzTZniV3Vjg3TwcUn9XcJZg0=; b=psG2RPZGfv3DfzDE7EiLacPkb0+Ssev74uZASAVAkp6cXaHMQ1gnIFFkN0DoRF/XHC RhUKVqpD6RRYEGSAJswnbAktrx0qf1HxeJdS4pNVrQA4r1c3uQ8FGdu3D/yscEbp5jWG iiPHXcBCABGtT6JWvra8Yq1um2Hb3guWZdrYBeR8WyzyMh9TuJ+nb6PgI+ui03GoUGQ3 TCU0SlROHC5c1BftiYMfRRUEwf7Urdg4J9PDgVwRiops48KDszSYN7r6dOoXolyNSc4P tjOB4iV0sOxxZeaI9Qm2IZWq0kFiijtSLCq+voO+xXxcItntw25wqxzCmie0snBk/9Nz CzdA== X-Gm-Message-State: AOAM5324PCVBcydNrnoSgWBU2X+tBMcR0eaZaiHWZa/tbG4LI7Rg6Kb7 xq44kzeGthZhJQeJAzcP6lE= X-Google-Smtp-Source: ABdhPJzbR2A9IaZZuWZL9dXfY/ud3Lh1aZezzViYVOPeMiA3bWIwI/DKubiDM5mP3ixooEqRBs0niA== X-Received: by 2002:a63:5024:: with SMTP id e36mr12198090pgb.438.1592829730707; Mon, 22 Jun 2020 05:42:10 -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 137sm11288142pgg.72.2020.06.22.05.42.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 05:42:09 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 7D5A140430; Mon, 22 Jun 2020 12:42:08 +0000 (UTC) Date: Mon, 22 Jun 2020 12:42:08 +0000 From: Luis Chamberlain To: Bart Van Assche Cc: axboe@kernel.dk, viro@zeniv.linux.org.uk, 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, 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 Subject: Re: [PATCH v7 8/8] block: create the request_queue debugfs_dir on registration Message-ID: <20200622124208.GW11244@42.do-not-panic.com> References: <20200619204730.26124-1-mcgrof@kernel.org> <20200619204730.26124-9-mcgrof@kernel.org> <02112994-4cd7-c749-6bd7-66a772593c90@acm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <02112994-4cd7-c749-6bd7-66a772593c90@acm.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Queue-Id: 2A0E416A040 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000233, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, Jun 20, 2020 at 11:07:43AM -0700, Bart Van Assche wrote: > On 2020-06-19 13:47, Luis Chamberlain wrote: > > We were only creating the request_queue debugfs_dir only > > for make_request block drivers (multiqueue), but never for > > request-based block drivers. We did this as we were only > > creating non-blktrace additional debugfs files on that directory > > for make_request drivers. However, since blktrace *always* creates > > that directory anyway, we special-case the use of that directory > > on blktrace. Other than this being an eye-sore, this exposes > > request-based block drivers to the same debugfs fragile > > race that used to exist with make_request block drivers > > where if we start adding files onto that directory we can later > > run a race with a double removal of dentries on the directory > > if we don't deal with this carefully on blktrace. > > > > Instead, just simplify things by always creating the request_queue > > debugfs_dir on request_queue registration. Rename the mutex also to > > reflect the fact that this is used outside of the blktrace context. > > There are two changes in this patch: a bug fix and a rename of a mutex. > I don't like it to see two changes in a single patch. I thought about doing the split first, and I did it at first, but then I could hear Christoph yelling at me for it. So I merged the two together. Although it makes it more difficult for review, the changes do go together. Kind of late to split this as its already merged now. > Additionally, is the new mutex name really better than the old name? The > proper way to use mutexes is to use mutexes to protect data instead of > code. Where is the documentation that mentions which member variable(s) > of which data structures are protected by the mutex formerly called > blk_trace_mutex? It does not exist, and that is the point. The debugfs_dir use after free showed us *when* that UAF can happen, and so care must be taken if we are to use the mutex to protect the debugfs_dir but also re-use the same directory for other block core shenanigans. > Since the new name makes it even less clear which data > is protected by this mutex, is the new name really better than the old name? I thought the new name makes it crystal clear what is being protected. I can however add a comment to explain that the q->debugfs_mutex protects the q->debugfs_dir if it is created, otherwise it protects the ephemeral debugfs_dir directory which would otherwise be created in lieue of q->debugfs_dir, however the patch still lies under /block/. Let me know if you think that will help. Luis