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=-9.0 required=3.0 tests=MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 A26ABC47257 for ; Sat, 9 May 2020 03:11:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 68BAE2496B for ; Sat, 9 May 2020 03:11:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 68BAE2496B 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 F184A900029; Fri, 8 May 2020 23:11:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EC82990001C; Fri, 8 May 2020 23:11:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB74D900029; Fri, 8 May 2020 23:11:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0024.hostedemail.com [216.40.44.24]) by kanga.kvack.org (Postfix) with ESMTP id C049690001C for ; Fri, 8 May 2020 23:11:03 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7B7C4181AEF0B for ; Sat, 9 May 2020 03:11:03 +0000 (UTC) X-FDA: 76795704006.07.rat77_7d9e0fdb27b45 X-HE-Tag: rat77_7d9e0fdb27b45 X-Filterd-Recvd-Size: 5326 Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Sat, 9 May 2020 03:11:03 +0000 (UTC) Received: by mail-pj1-f67.google.com with SMTP id k7so179834pjs.5 for ; Fri, 08 May 2020 20:11: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:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=p5NcTJui4Fu9/J9tXQ/zepXkgIKrwl9gDgd73XI0wYc=; b=nrxGhTEKrCTlS/1lQptej8ml0ahCmCHlwtmtelMVlFBOiNfohCRtXPUkpm8U4vrUJR fL3x70ODNmFsDfUrAEbDM6Kq+IKwjX43o/RGeL71sW/76RY9Iv7lGbW4+PRP0DkjqQob J1WMO+Dp1tdx/TOytOjoxwaeqRdOoemt2Z7e6ixjrWagCiCq/Vn7ZSzX50e4OjXTbYDN yHXsq5g1AT6dfM6eskCzNK70RzUJLWriMSUbHNEKPAsYhXvi/AAtEio0k7I6JrmaFom4 nL9U0dlEYdwrqaj7/afDLfqJV4mltkf+d1afWV6SCXcQr1ZdQd110jUF/PA8SD2nZ4Xf 2YNA== X-Gm-Message-State: AGi0PuZ76eJU24tyN8CYDTpbkSJWRUw3SwAo2KOIQcM74Amt2nauUohy 2t4FfVZbO857tpG0j35+qBk= X-Google-Smtp-Source: APiQypJJo3vtBLT/+F50uK9YwKjnwZupKT9TMWAfYkMfkofkKXyVoI6FIcRSuFmkZZNsc5UL7pmUIw== X-Received: by 2002:a17:90a:20ca:: with SMTP id f68mr1501737pjg.67.1588993861986; Fri, 08 May 2020 20:11:01 -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 b1sm3105905pfa.202.2020.05.08.20.11.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 May 2020 20:11:00 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id BBC854035F; Sat, 9 May 2020 03:10:59 +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 v4 0/5] block: fix blktrace debugfs use after free Date: Sat, 9 May 2020 03:10:53 +0000 Message-Id: <20200509031058.8239-1-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: Phew, well, since we did't hear back about removing scsi-generic blktrace functionality I put work into addressing to keep it. That took a lot of code inspection and also testing. Since libvirt is limited to what devices you can test I resorted to testing all supported device types with iscsi tcp and tgt. I decided to simplfiy the partition work further by just using a symbolic link. In the end that makes the blktrace code even cleaner than anything we had before. scsi-generic stuff still required quite a bit of work to figure out what to do. Since scsi devices probe asynchronously and scsi-generic is nothing but a class_interface whose sg_add_device() runs *prior* to the scsi device probe, we currently address the symlink on the sg ioctl. I however think this reveals a shortcoming of the class interface, now that we have async probe and its used widely. I think we need a probe_complete() call or something like that. If that seems reasonable I can work on that, that would allow us to move the debugfs_dir symlink / settings from sg's ioctl to a new proper call. I'd prefer to address that later though, as an evolution. Its my first time touching scsi stuff, so I'd highly appreciate a good review of what I propose for scsi-generic. It gets a bit more complicated with some drivers using the bsg queue. FWIW, if bsg is enabled we *reshare* the request_queue from the scsi_device, unless you're a scsi transport, in which case it creates its own. You can find this on my git tree: https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git/log= /?h=3D20200508-block-fixes Luis Chamberlain (5): block: revert back to synchronous request_queue removal block: move main block debugfs initialization to its own file 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 | 202 +++++++++++++++++++++++++++++++++++ block/blk-mq-debugfs.c | 5 - block/blk-sysfs.c | 46 ++++---- block/blk.h | 23 ++++ block/bsg.c | 2 + block/genhd.c | 73 ++++++++++++- block/partitions/core.c | 9 ++ drivers/block/loop.c | 4 + drivers/scsi/ch.c | 1 + drivers/scsi/sg.c | 75 +++++++++++++ drivers/scsi/st.c | 2 + include/linux/blkdev.h | 6 +- include/linux/blktrace_api.h | 1 - include/linux/genhd.h | 69 ++++++++++++ kernel/trace/blktrace.c | 33 ++++-- 17 files changed, 539 insertions(+), 45 deletions(-) create mode 100644 block/blk-debugfs.c --=20 2.25.1