From patchwork Wed Apr 29 07:46:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 11516327 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 681F91575 for ; Wed, 29 Apr 2020 07:46:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 400BB2076B for ; Wed, 29 Apr 2020 07:46:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 400BB2076B 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 70A048E0007; Wed, 29 Apr 2020 03:46:34 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6E3528E0001; Wed, 29 Apr 2020 03:46:34 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 55FCF8E0007; Wed, 29 Apr 2020 03:46:34 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0035.hostedemail.com [216.40.44.35]) by kanga.kvack.org (Postfix) with ESMTP id 1AE828E0001 for ; Wed, 29 Apr 2020 03:46:34 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id D00E2824805A for ; Wed, 29 Apr 2020 07:46:33 +0000 (UTC) X-FDA: 76760110266.04.flock97_394332c170829 X-Spam-Summary: 2,0,0,33aa9ef2dc3adbb6,d41d8cd98f00b204,mcgrof@gmail.com,,RULES_HIT:41:69:355:379:421:541:965:966:967:968:973:988:989:1260:1311:1314:1345:1437:1515:1534:1542:1711:1730:1747:1777:1792:2196:2199:2393:2525:2559:2564:2682:2685:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3871:3872:3873:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4321:4385:4390:4395:4605:5007:6261:6671:7903:9025:9040:9389:10004:11657:11658:11914:12043:12048:12291:12296:12297:12517:12519:12555:12679:12683:12895:12986:13007:13161:13229:13894:13972:14096:14181:14394:14721:21063:21080:21324:21444:21451:21627:21939:30012:30054:30076,0,RBL:209.85.216.67:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: flock97_394332c170829 X-Filterd-Recvd-Size: 4915 Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Wed, 29 Apr 2020 07:46:33 +0000 (UTC) Received: by mail-pj1-f67.google.com with SMTP id fu13so429246pjb.5 for ; Wed, 29 Apr 2020 00:46:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NYubAi/xyHN/Pt3WLLDfx9xZYmA2QF+HOc1wknCJjyE=; b=lKNgZ1NDfzpM84AobJ39+nmShvYtmu4EAsJpxmcsSLjGhHaE/I4al9TYi0Fn+gDr8g erOp4u8TUcFPHJH0hOXQihjzOmQwhVaJ2F/7ReeYoSh9HNQ1A5CRnV6XAcoRCNGH4i/t 6qPa29tv5R/mdNxiWcLWVzIkXpjMEX7VWxWEjY6lF3tleuqGn/o1/l0fnz7vpPbIoPTX y+e7p0ZQcyMHJ+10gkAd7Ti7QB/jBbXu2wJOdo47/65jqnsLQ8oP/5eZ82FwqEYmAIKP m1F8YB//i7SzEJ33wxS4Io7Di9fI0XRzGZRaP6ITKgNnDbXykNhwn/4f8+xJnnGzQVmr LfRQ== X-Gm-Message-State: AGi0PuY8R48mEkE9w2m749nA8wY3LUkLVpJ8dRkOh4SMhvju2ZNXjpeO oz8yJNj7NcKYWIQKdJthOZs= X-Google-Smtp-Source: APiQypIfWlYu4r9gGMTIUxtKPyw+8rsye9CqmxwCOpf6XM6xFBrcbMQA0lW6oMqBferHgjxE4Y6RAA== X-Received: by 2002:a17:90a:8c85:: with SMTP id b5mr1555073pjo.187.1588146392532; Wed, 29 Apr 2020 00:46:32 -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 141sm411722pfz.171.2020.04.29.00.46.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2020 00:46:30 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id B9830403AB; Wed, 29 Apr 2020 07:46:29 +0000 (UTC) From: Luis Chamberlain To: 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 Cc: 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, Luis Chamberlain Subject: [PATCH v3 0/6] block: fix blktrace debugfs use after free Date: Wed, 29 Apr 2020 07:46:21 +0000 Message-Id: <20200429074627.5955-1-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 MIME-Version: 1.0 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: Alrighty, here is v3 with all the BUG_*() crap removed, and moving to just create the debugfs directory needed for the partitions as well at initialization. This allows us to get rid of the pesky debugfs_lookup() calls which has made this code very awkward, and allowed us to find surprising bugs when we went with an asynchronous request_queue removal. I'll note that I still see this: debugfs: Directory 'loop0' with parent 'block' already present! But only for break-blktrace [0] run_0004.sh. But since we don't have any more races with blktrace, this has pushed me to look into disk registration / deletion. I'll be posting patches soon about some changes to help with that, on the error handling. If, after these patches, you however find the root cause to this let me know! Also, if folks don't disagree, I'll likely follow up to just merge break-blktrace as a self-test for blktrace. We can later expand on it upstream instead. These patches are based on linux-next tag next-20200428, you can find the code on my 20200428-blktrace-fixes branch [1]. [0] https://github.com/mcgrof/break-blktrace [1] https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git/log/?h=20200428-blktrace-fixes Luis Chamberlain (6): block: revert back to synchronous request_queue removal block: move main block debugfs initialization to its own file blktrace: move blktrace debugfs creation to helper function blktrace: fix debugfs use after free blktrace: break out of blktrace setup on concurrent calls loop: be paranoid on exit and prevent new additions / removals block/Makefile | 1 + block/blk-core.c | 32 ++++++++++++---- block/blk-debugfs.c | 44 ++++++++++++++++++++++ block/blk-mq-debugfs.c | 5 --- block/blk-sysfs.c | 47 ++++++++++++----------- block/blk.h | 18 +++++++++ block/genhd.c | 73 +++++++++++++++++++++++++++++++++++- block/partitions/core.c | 3 ++ drivers/block/loop.c | 4 ++ drivers/scsi/sg.c | 2 + include/linux/blkdev.h | 7 ++-- include/linux/blktrace_api.h | 1 - include/linux/genhd.h | 18 +++++++++ kernel/trace/blktrace.c | 39 ++++++++++++++++--- 14 files changed, 249 insertions(+), 45 deletions(-) create mode 100644 block/blk-debugfs.c