From: Luis Chamberlain <mcgrof@kernel.org>
To: Bart Van Assche <bvanassche@acm.org>
Cc: axboe@kernel.dk, viro@zeniv.linux.org.uk,
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 <osandov@fb.com>,
Hannes Reinecke <hare@suse.com>, Michal Hocko <mhocko@kernel.org>,
Christof Schmitt <christof.schmitt@de.ibm.com>,
syzbot+603294af2d01acfdd6da@syzkaller.appspotmail.com
Subject: Re: [PATCH v4 3/5] blktrace: fix debugfs use after free
Date: Mon, 11 May 2020 13:44:06 +0000 [thread overview]
Message-ID: <20200511134406.GN11244@42.do-not-panic.com> (raw)
In-Reply-To: <16fe176f-1dbd-d14c-bfc2-5aee1ca8c64e@acm.org>
On Sat, May 09, 2020 at 05:58:55PM -0700, Bart Van Assche wrote:
> On 2020-05-08 20:10, Luis Chamberlain wrote:
> > Screenshots of what the debugfs for block looks like after running
> > blktrace on a system with sg0 which has a raid controllerand then sg1
> > as the media changer:
> >
> > # ls -l /sys/kernel/debug/block
> > total 0
> > drwxr-xr-x 3 root root 0 May 9 02:31 bsg
> > drwxr-xr-x 19 root root 0 May 9 02:31 nvme0n1
> > drwxr-xr-x 19 root root 0 May 9 02:31 nvme1n1
> > lrwxrwxrwx 1 root root 0 May 9 02:31 nvme1n1p1 -> nvme1n1
> > lrwxrwxrwx 1 root root 0 May 9 02:31 nvme1n1p2 -> nvme1n1
> > lrwxrwxrwx 1 root root 0 May 9 02:31 nvme1n1p3 -> nvme1n1
> > lrwxrwxrwx 1 root root 0 May 9 02:31 nvme1n1p5 -> nvme1n1
> > lrwxrwxrwx 1 root root 0 May 9 02:31 nvme1n1p6 -> nvme1n1
> > drwxr-xr-x 2 root root 0 May 9 02:33 sch0
> > lrwxrwxrwx 1 root root 0 May 9 02:33 sg0 -> bsg/2:0:0:0
> > lrwxrwxrwx 1 root root 0 May 9 02:33 sg1 -> sch0
> > drwxr-xr-x 5 root root 0 May 9 02:31 vda
> > lrwxrwxrwx 1 root root 0 May 9 02:31 vda1 -> vda
>
> So this patch creates one soft link per partition at partition creation
> time instead of letting the blktrace code create one directory per
> partition when tracing starts?
Yes.
> Does this break running blktrace
> simultaneously for a partition and for the entire block device?
blktrace already has this limitation, one blktrace is only allowed per
request_queue, the next patch clarifies this, as we currently just error
out without telling the user what has happened.e user what has
happened.e user what has happened.e user what has happened.
> > +static struct dentry *queue_debugfs_symlink_type(struct request_queue *q,
> > + const char *src,
> > + const char *dst,
> > + enum blk_debugfs_dir_type type)
> > +{
> > + struct dentry *dentry = ERR_PTR(-EINVAL);
> > + char *dir_dst;
> > +
> > + dir_dst = kzalloc(PATH_MAX, GFP_KERNEL);
> > + if (!dir_dst)
> > + return dentry;
> > +
> > + switch (type) {
> > + case BLK_DBG_DIR_BASE:
> > + if (dst)
> > + snprintf(dir_dst, PATH_MAX, "%s", dst);
> > + else if (!IS_ERR_OR_NULL(q->debugfs_dir))
> > + snprintf(dir_dst, PATH_MAX, "%s",
> > + q->debugfs_dir->d_name.name);
> > + else
> > + goto out;
> > + break;
> > + case BLK_DBG_DIR_BSG:
> > + if (dst)
> > + snprintf(dir_dst, PATH_MAX, "bsg/%s", dst);
> > + else
> > + goto out;
> > + break;
> > + }
> > +
> > + /*
> > + * The base block debugfs directory is always used for the symlinks,
> > + * their target is what changes.
> > + */
> > + dentry = debugfs_create_symlink(src, blk_debugfs_root, dir_dst);
> > +out:
> > + kfree(dir_dst);
> > +
> > + return dentry;
> > +}
>
> Please use kasprintf() instead of k?alloc() followed by snprintf().
Sure thing.
Luis
next prev parent reply other threads:[~2020-05-11 13:44 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-09 3:10 [PATCH v4 0/5] block: fix blktrace debugfs use after free Luis Chamberlain
2020-05-09 3:10 ` [PATCH v4 1/5] block: revert back to synchronous request_queue removal Luis Chamberlain
2020-05-10 0:36 ` Bart Van Assche
2020-05-10 6:20 ` Greg KH
2020-05-11 13:41 ` Luis Chamberlain
2020-05-09 3:10 ` [PATCH v4 2/5] block: move main block debugfs initialization to its own file Luis Chamberlain
2020-05-09 3:10 ` [PATCH v4 3/5] blktrace: fix debugfs use after free Luis Chamberlain
2020-05-10 0:58 ` Bart Van Assche
2020-05-11 13:44 ` Luis Chamberlain [this message]
2020-05-10 6:26 ` Greg KH
2020-05-11 14:03 ` Luis Chamberlain
2020-05-09 3:10 ` [PATCH v4 4/5] blktrace: break out of blktrace setup on concurrent calls Luis Chamberlain
2020-05-10 1:09 ` Bart Van Assche
2020-05-11 13:39 ` Luis Chamberlain
2020-05-16 1:39 ` Luis Chamberlain
2020-05-09 3:10 ` [PATCH v4 5/5] loop: be paranoid on exit and prevent new additions / removals Luis Chamberlain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200511134406.GN11244@42.do-not-panic.com \
--to=mcgrof@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=christof.schmitt@de.ibm.com \
--cc=gregkh@linuxfoundation.org \
--cc=hare@suse.com \
--cc=jack@suse.cz \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=mhocko@suse.com \
--cc=ming.lei@redhat.com \
--cc=mingo@redhat.com \
--cc=nstange@suse.de \
--cc=osandov@fb.com \
--cc=rostedt@goodmis.org \
--cc=syzbot+603294af2d01acfdd6da@syzkaller.appspotmail.com \
--cc=viro@zeniv.linux.org.uk \
--cc=yukuai3@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).