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 22748C2BB55 for ; Thu, 16 Apr 2020 01:20:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E1D772076D for ; Thu, 16 Apr 2020 01:20:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E1D772076D 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 7EE638E0064; Wed, 15 Apr 2020 21:20:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 778FB8E0001; Wed, 15 Apr 2020 21:20:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 618438E0064; Wed, 15 Apr 2020 21:20:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0041.hostedemail.com [216.40.44.41]) by kanga.kvack.org (Postfix) with ESMTP id 46E6F8E0001 for ; Wed, 15 Apr 2020 21:20:46 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 0CFDF52A0 for ; Thu, 16 Apr 2020 01:20:46 +0000 (UTC) X-FDA: 76711963692.01.song40_6a3d9b6e6201 X-HE-Tag: song40_6a3d9b6e6201 X-Filterd-Recvd-Size: 5160 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Thu, 16 Apr 2020 01:20:45 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id y12so741701pll.2 for ; Wed, 15 Apr 2020 18:20:45 -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=t/UVxcfsOZlATHrxT1BtEcSV7XCXKURmZ3LY2D7NJu8=; b=X9FiC7XDB0Kcs40GcsnFR7kKBe754oaZpp1jUh5nwM4T9iVXGeiBg7zw41Oivg269K Evaa1ABF+T1OGFJT+rjy1xK5eSIHhG4yjRbQgNwu25FG+yr1dGHc/0nLy7zTwiBvJC0H MboiSloV736/DSj8K1//oXoa86H1ulELmUx6rrAzhKODPXd77iXnDNQQN4o3lLwoMwKs hqyDoGyVaMHh0Y7rZwXwKgxTA82XJIPVy3a75HMPOyqn5rX/tOhRapT4KRuy26tFL6ZB gF2PkCFc6OjcQdpmh2zm7gMjIZ5Ck/6310GOPX3HORsl9A+aelgOAL+0JwJdRuUsrPxZ sRXA== X-Gm-Message-State: AGi0PuaMfkzrBBXu0QO1y8H5aEZzAKBV2Uf3BosV1s6fp209LpE0+3KO gq7q8DFIdi4n4H2nTK6qM0E= X-Google-Smtp-Source: APiQypKsoy5OswG4beg+t+DZPY2ToYWmF3rusQi++8/xjuNFf2sr4eDmbcDmFPW16CTt2byhESFlqA== X-Received: by 2002:a17:902:9b89:: with SMTP id y9mr6854674plp.75.1587000044633; Wed, 15 Apr 2020 18:20:44 -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 c3sm14942152pfa.160.2020.04.15.18.20.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Apr 2020 18:20:43 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id C7B7C40277; Thu, 16 Apr 2020 01:20:42 +0000 (UTC) Date: Thu, 16 Apr 2020 01:20:42 +0000 From: Luis Chamberlain To: Eric Sandeen 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 2/5] blktrace: fix debugfs use after free Message-ID: <20200416012042.GD11244@42.do-not-panic.com> References: <20200414041902.16769-1-mcgrof@kernel.org> <20200414041902.16769-3-mcgrof@kernel.org> <55401e02-f61c-25eb-271c-3ec7baf35e28@sandeen.net> <20200416005636.GA11244@42.do-not-panic.com> <924950e6-e016-25b2-4ee1-b5ea9f752c12@sandeen.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <924950e6-e016-25b2-4ee1-b5ea9f752c12@sandeen.net> 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 15, 2020 at 08:02:04PM -0500, Eric Sandeen wrote: > > > On 4/15/20 7:56 PM, Luis Chamberlain wrote: > > On Wed, Apr 15, 2020 at 12:38:26PM -0500, Eric Sandeen wrote: > >> On 4/13/20 11:18 PM, Luis Chamberlain wrote: > >>> On commit 6ac93117ab00 ("blktrace: use existing disk debugfs directory") > >>> merged on v4.12 Omar fixed the original blktrace code for request-based > >>> drivers (multiqueue). This however left in place a possible crash, if you > >>> happen to abuse blktrace in a way it was not intended. > >>> > >>> Namely, if you loop adding a device, setup the blktrace with BLKTRACESETUP, > >>> forget to BLKTRACETEARDOWN, and then just remove the device you end up > >>> with a panic: > >> > >> I think this patch makes this all cleaner anyway, but - without the apparent > >> loop bug mentioned by Bart which allows removal of the loop device while blktrace > >> is active (if I read that right), can this still happen? > > > > I have not tested that, but some modifications of the break-blktrace > > program could enable us to test that > > FWIW, I modified it to modprobe & rmmod scsi_debug instead of the loop ioctls, > and the module can't be unloaded after the blktrace is started since it's busy. > > Not sure that's equivalent tho. Given what Bart mentioned about sd_open, that might be the saving grace for blocking async behaviour on scsi. If it only refcounted the request_queue as the loop driver it would have been exposed to the same bug. > > however I don't think the race > > would be possible after patch 3/5 "blktrace: refcount the request_queue > > during ioctl" is merged, as removal then a pending blktrace would > > refcount the request_queue and the removal would have to wait until > > the refcount is decremeneted, until after the blktrace ioctl. > > I'm out of my depth in the block layer, not sure who's supposed to take > refs on what. ;) I'm new to all this code, only been a few weeks looking into it, but am trying to do my best ot make sense of it. So the above is what I can tell would be needed. Luis