[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200610215213.GH13911@42.do-not-panic.com>
Date: Wed, 10 Jun 2020 21:52:13 +0000
From: Luis Chamberlain <mcgrof@...nel.org>
To: Christoph Hellwig <hch@...radead.org>
Cc: Jan Kara <jack@...e.cz>, axboe@...nel.dk, viro@...iv.linux.org.uk,
bvanassche@....org, gregkh@...uxfoundation.org,
rostedt@...dmis.org, mingo@...hat.com, ming.lei@...hat.com,
nstange@...e.de, akpm@...ux-foundation.org, mhocko@...e.com,
yukuai3@...wei.com, martin.petersen@...cle.com, jejb@...ux.ibm.com,
linux-block@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Omar Sandoval <osandov@...com>,
Hannes Reinecke <hare@...e.com>,
Michal Hocko <mhocko@...nel.org>,
syzbot+603294af2d01acfdd6da@...kaller.appspotmail.com
Subject: Re: [PATCH v6 6/6] blktrace: fix debugfs use after free
So, upon updating the commit log, and moving the empty directory check
into another patch, I realized we might be able to simplify this now even
further still. Patch below. The key of the issue was that the use after free
happens when a recursive removal happens, and then later a specific
dentry removal happens. This happened for make_request block drivers
when using the whole disk, but since we *don't* have any other users of
the directory for the others cases, this in theory shuld not happen for
them either.
I'll try to shoot some bullets at this.
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 7ff2ea5cd05e..5cea04c05e09 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -524,10 +524,16 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
if (!bt->msg_data)
goto err;
- ret = -ENOENT;
-
- dir = debugfs_lookup(buts->name, blk_debugfs_root);
- if (!dir)
+ /*
+ * When tracing whole make_request drivers (multiqueue) block devices,
+ * reuse the existing debugfs directory created by the block layer on
+ * init. For request-based block devices, all partitions block devices,
+ * and scsi-generic block devices we create a temporary new debugfs
+ * directory that will be removed once the trace ends.
+ */
+ if (queue_is_mq(q))
+ dir = q->debugfs_dir;
+ else
bt->dir = dir = debugfs_create_dir(buts->name, blk_debugfs_root);
bt->dev = dev;
@@ -565,8 +571,6 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
ret = 0;
err:
- if (dir && !bt->dir)
- dput(dir);
if (ret)
blk_trace_free(bt);
return ret;
Powered by blists - more mailing lists