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 507AFC433E0 for ; Sat, 16 May 2020 03:20:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 11E372074A for ; Sat, 16 May 2020 03:20:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 11E372074A 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 B30C28E0003; Fri, 15 May 2020 23:20:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE1738E0001; Fri, 15 May 2020 23:20:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F6888E0003; Fri, 15 May 2020 23:20:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0109.hostedemail.com [216.40.44.109]) by kanga.kvack.org (Postfix) with ESMTP id 8445D8E0001 for ; Fri, 15 May 2020 23:20:02 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 3C51A4DC1 for ; Sat, 16 May 2020 03:20:02 +0000 (UTC) X-FDA: 76821128244.18.fire99_1d60908313127 X-HE-Tag: fire99_1d60908313127 X-Filterd-Recvd-Size: 5516 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Sat, 16 May 2020 03:20:01 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id s20so1696423plp.6 for ; Fri, 15 May 2020 20:20:01 -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=YV3/UWo+QrQjEja7xqDM3mkCEeETF9cGsA9Cr+G6NWM=; b=RxJnkzjwWxr7cWWrL95k1pJjDLpZD/rFAKKoA+r1gFDFzRWWOcKyZ0mIzYAhHlE7AB vEOUTeNrfwerUf9ZwOTY6u/1ohVTcP7d0OUMtltU4gDa1kiw1jv8BHvYni767wljkpYh dhUuot1oAmRbXwzhVtckeCH7/9ZYCH/BJl1rcxQ0GN7tPU+9pMlSdubq/eHzAJT3AKH4 kzr/JNt6PGNrgHLrPNwcJwFjulCYJjPFWegaLzpIKiAmbOEwyyjTwRR9zS0LODpsQc6s lT5Z8d06lcA/7Tvapg70YhMwYrbWxNQe8COl0BCBcdOiQnNJDDGeUkFi2xgDLjV5WzAR a/ow== X-Gm-Message-State: AOAM530x7k5naKCr612GQtNRGiGVhY8QeZOQWMUxQ3QDKkfoO0VP+Yfs KBInIVlVrOHs5vSxfWMHniM= X-Google-Smtp-Source: ABdhPJyX70yrh/cMjp+9Dz4fChywx1PSJecwmDqWYDJSH2DMWbAhrLB6vr4UVE2r+Lo9hAtfEQDoiw== X-Received: by 2002:a17:902:23:: with SMTP id 32mr6510510pla.40.1589599200697; Fri, 15 May 2020 20:20:00 -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 m19sm2543770pjv.30.2020.05.15.20.19.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 20:19:59 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 99D78404B0; Sat, 16 May 2020 03:19:58 +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 v5 0/7] block: fix blktrace debugfs use after free Date: Sat, 16 May 2020 03:19:49 +0000 Message-Id: <20200516031956.2605-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: On this v5 I've split up the first patch into 3, one for comments, another for context / might_sleep() updates, and the last the big revert back to synchronous request_queue removal. I didn't update the context for the put / decrements for gendisk & request_queue as they would be updated in the next patch. Since the first 3 patches are a reflection of the original one, I've left the Reviewed-by's collected in place. I've changed the kzalloc() / snprintf() to just kasprintf() as requested by Bart. Since it was not clear that we don't have the bdev on do_blk_trace_setup() for the patch titled "blktrace: break out of blktrace setup on concurrent calls", I've added a comment so that someone doesn't later try to add a dev_printk() or the like. I've also addressed a compilation issue with debugfs disabled reported by 0-day on the patch titled "blktrace: fix debugfs use after free". It was missing a "static inline" on a function. I've also moved the new declarations underneath the "#ifdef CONFIG_BLOCK" on include/linux/genhd.= h, I previously had them outside of this block. I've left in place the scsi-generic blktrace suppport given I didn't rece= ive any feedback to kill it. This ensures this works as it used to. Since these are minor changes I've given this a spin with break-blktrace tests I have written and also ran blktrace with a scsi-generic media changer. Both sg0 (the controller) and sg1 worked as expected. These changes are based on linux-next tag next-20200515, and can also be found on my git tree: https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git/log= /?h=3D20200515-blktrace-fixes Luis Chamberlain (7): block: add docs for gendisk / request_queue refcount helpers block: clarify context for gendisk / request_queue refcount increment helpers 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 | 10 +- block/blk-core.c | 32 ++++-- block/blk-debugfs.c | 197 +++++++++++++++++++++++++++++++++++ block/blk-mq-debugfs.c | 5 - block/blk-sysfs.c | 46 ++++---- block/blk.h | 24 +++++ 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 | 37 +++++-- 17 files changed, 545 insertions(+), 48 deletions(-) create mode 100644 block/blk-debugfs.c --=20 2.26.2