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 DB0A5C433E0 for ; Fri, 19 Jun 2020 15:36:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A95AA206FA for ; Fri, 19 Jun 2020 15:36:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A95AA206FA 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 1FEB98D00AE; Fri, 19 Jun 2020 11:36:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1AE8F8D00AD; Fri, 19 Jun 2020 11:36:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 09D548D00AE; Fri, 19 Jun 2020 11:36:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0056.hostedemail.com [216.40.44.56]) by kanga.kvack.org (Postfix) with ESMTP id E36958D00AD for ; Fri, 19 Jun 2020 11:36:28 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 560A7180AD804 for ; Fri, 19 Jun 2020 15:36:28 +0000 (UTC) X-FDA: 76946363256.14.look35_2c0d63326e1a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id A5B3A180C958D for ; Fri, 19 Jun 2020 15:36:24 +0000 (UTC) X-HE-Tag: look35_2c0d63326e1a X-Filterd-Recvd-Size: 4256 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Fri, 19 Jun 2020 15:36:24 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id i4so4438031pjd.0 for ; Fri, 19 Jun 2020 08:36:24 -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=LjzrirVb+ZQBftcrRnoHLV9aRjuJIVfcPAYJhueLEQk=; b=gjCmE+BCVIiqb3bpzpf+5UhneVKYp/QQOfg0HRFExOJsm3kQ0LMMfibfYEAau89VDg +3GJV2pNut1uhO6xKFJl0YNgAEAY3S/6iUDcQek/Td1+b0Nx2qsX4Eo7nxA7Flx3V1fe LhaAwewIjCVS9py5ecGnVPmRUTh/xIEA7BKDGaUm/rW0Av/r4vH2QsPznmww6WH/22EY 5sD2I2WtgqV5TaYVmH8aistC75YQMtutrivVtMQ9Skq1CsckD47j8t0/bItZ3QPHaEtR rSAUlU5H/sxcfZzTrgHpg/ysl5WsChJ0FQzfeLB/JQ9fG1OVar/I1Nax9JlmCdDcnDs4 Gh/A== X-Gm-Message-State: AOAM531v6O/+brVix/6xEoMmHbRqKEA69+UrkklLYILR4JktpiMws+Pj akSOXNo9lSYoWPUnWeZbQ8w= X-Google-Smtp-Source: ABdhPJzViKsR3tVw6K/ch+JBLdo17uGcti8CT335conquQT26tgspJ89pJQG6ng0CCGMq0+rPtsHZQ== X-Received: by 2002:a17:902:b906:: with SMTP id bf6mr8845200plb.129.1592580983204; Fri, 19 Jun 2020 08:36:23 -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 p16sm5382348pgj.53.2020.06.19.08.36.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jun 2020 08:36:21 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id CD1B84063E; Fri, 19 Jun 2020 15:36:20 +0000 (UTC) Date: Fri, 19 Jun 2020 15:36:20 +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, 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: <20200619153620.GI11244@42.do-not-panic.com> References: <20200608170127.20419-1-mcgrof@kernel.org> <20200608170127.20419-7-mcgrof@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Queue-Id: A5B3A180C958D 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 Fri, Jun 12, 2020 at 07:42:12PM -0700, Bart Van Assche wrote: > On 2020-06-08 10:01, Luis Chamberlain wrote: > > + /* > > + * Blktrace needs a debugfs name even for queues that don't register > > + * a gendisk, so it lazily registers the debugfs directory. But that > > + * can get us into a situation where a SCSI device is found, with no > > + * driver for it (yet). Then blktrace is used on the device, creating > > + * the debugfs directory, and only after that a driver is loaded. In > > + * that case we might already have a debugfs directory registered here. > > + * Even worse we could be racing with blktrace to register it. > > + */ > > There are LLD and ULD drivers in the SCSI subsystem. Please mention the > driver type explicitly. I assume that you are referring to SCSI ULDs > since only SCSI ULD drivers call device_add_disk()? I've simplified this and so this is no longer a valid comment. > > case BLKTRACESETUP: > > + if (!sdp->device->request_queue->sg_debugfs_dir) > > + blk_sg_debugfs_init(sdp->device->request_queue, > > + sdp->disk->disk_name); > > How about moving the sg_debugfs_dir check into blk_sg_debugfs_init()? I found a way to not have to do any of this, the fix will be short and sweet now. Luis