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.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, 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 58FB6C5321D for ; Mon, 20 Apr 2020 00:39:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2675C2145D for ; Mon, 20 Apr 2020 00:39:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2675C2145D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B2A368E0005; Sun, 19 Apr 2020 20:39:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ADBC38E0003; Sun, 19 Apr 2020 20:39:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F12E8E0005; Sun, 19 Apr 2020 20:39:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0115.hostedemail.com [216.40.44.115]) by kanga.kvack.org (Postfix) with ESMTP id 85A948E0003 for ; Sun, 19 Apr 2020 20:39:04 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 35F3F5DC6 for ; Mon, 20 Apr 2020 00:39:04 +0000 (UTC) X-FDA: 76726373808.29.hate87_14f2f57b4a502 X-HE-Tag: hate87_14f2f57b4a502 X-Filterd-Recvd-Size: 5017 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Mon, 20 Apr 2020 00:39:03 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id x77so1506218pfc.0 for ; Sun, 19 Apr 2020 17:39:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=QdNUMRhAVT84vFSs1IwKOQ/o9/+SJlOoUnD+T6ObXFw=; b=Llf0ymNOkw2GQyfK+gh7rDVi2iCyHjmPxJXPIHAG5EzxpkEtiYMTCTqs0iqUGX+vKB PCcMFCutM27Dd5gwHrYJ1hJNWZR1bIPdmb2Z+cPo1FJSnRzS9lcLM6mwI8wikAdaprtV kFP+X7bran8dmxI4/AyjLh68Pzd/JR29WVoViB3BYBRVo/UB3kBdhOWas8EqIEpJpT2Q e8klbAjQ21kYkvGWSfIcrEenzFGTRWsiVHLSseVpr9/ovsB4Wz4sej1ZZsM2yQCgFIHy eqlKKqE8VyeQTzfuhgkj6+dx+lDX7MoDIL1qsDQvA0HaSDrvEBIZz9XTfGGwoX4muoeH NfRQ== X-Gm-Message-State: AGi0PubCnq1cSGKMr9qGkzEG0X7NyBfa9VvNxnDJuW2oT0CLroreAgAV n5u5zN/5PCbaJGRCjeiG8r0= X-Google-Smtp-Source: APiQypLemCyE2sMdLPxxbXHy9KKBQYlkJRmRqQNH4pz9gt0gi1ZgK7eNY69ge+gaay8LMO3NTcrlEA== X-Received: by 2002:a63:7416:: with SMTP id p22mr13833579pgc.140.1587343142909; Sun, 19 Apr 2020 17:39:02 -0700 (PDT) Received: from [100.124.11.78] ([104.129.198.66]) by smtp.gmail.com with ESMTPSA id j5sm12271672pjb.36.2020.04.19.17.39.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 19 Apr 2020 17:39:01 -0700 (PDT) Subject: Re: [PATCH v2 03/10] blktrace: fix debugfs use after free To: Luis Chamberlain 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, 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 References: <20200419194529.4872-1-mcgrof@kernel.org> <20200419194529.4872-4-mcgrof@kernel.org> <91c82e6a-24ce-0b7d-e6e4-e8aa89f3fb79@acm.org> <20200420000436.GI11244@42.do-not-panic.com> From: Bart Van Assche Message-ID: Date: Sun, 19 Apr 2020 17:38:59 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200420000436.GI11244@42.do-not-panic.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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 4/19/20 5:04 PM, Luis Chamberlain wrote: > On Sun, Apr 19, 2020 at 02:55:42PM -0700, Bart Van Assche wrote: >> On 4/19/20 12:45 PM, Luis Chamberlain wrote: >>> +int __must_check blk_queue_debugfs_register(struct request_queue *q) >>> +{ >>> + struct dentry *dir = NULL; >>> + >>> + /* This can happen if we have a bug in the lower layers */ >> >> What does "this" refer to? Which layers does "lower layers" refer to? Most >> software developers consider a module that calls directly into another >> module as a higher layer (callbacks through function pointers do not count; >> see also https://en.wikipedia.org/wiki/Modular_programming). According to >> that definition block drivers are a software layer immediately above the >> block layer core. >> >> How about changing that comment into the following to make it unambiguous >> (if this is what you meant)? >> >> /* >> * Check whether the debugfs directory already exists. This can >> * only happen as the result of a bug in a block driver. >> */ > > But I didn't mean on a block driver. I meant the block core. In our > case, the async request_queue removal is an example. There is nothing > that block drivers could have done to help much with that. > > I could just change "lower layers" to "block layer" ? That sounds good to me. >> Independent of what the purpose of the above code is, can that code be >> rewritten such that it does not depend on the details of how names are >> assigned to disks and partitions? Would disk_get_part() be useful here? > > I did try, but couldn't figure out a way. I'll keep looking but likewise > let me know if you find a way. How about making blk_trace_setup() pass the result of the following expression as an additional argument to blk_trace_setup(): bdev != bdev->bd_contains I think that is a widely used approach to verify after a block device has been opened whether or not 'bdev' refers to a partition (bdev != bdev->bd_contains means that 'bdev' represents a partition). Thanks, Bart.