From: Li Zefan <lizf@cn.fujitsu.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, acme@redhat.com, hpa@zytor.com,
mingo@redhat.com, lizf@cn.fujitsu.com, jens.axboe@oracle.com,
fweisbec@gmail.com, rostedt@goodmis.org, tglx@linutronix.de,
mingo@elte.hu
Subject: [tip:tracing/blktrace] blktrace: avoid accessing NULL bdev->bd_disk
Date: Fri, 20 Mar 2009 10:26:44 GMT [thread overview]
Message-ID: <tip-afaebb6720cc62df1b03e36c2f699b00cfee784e@git.kernel.org> (raw)
In-Reply-To: <49C30098.6080107@cn.fujitsu.com>
Commit-ID: afaebb6720cc62df1b03e36c2f699b00cfee784e
Gitweb: http://git.kernel.org/tip/afaebb6720cc62df1b03e36c2f699b00cfee784e
Author: Li Zefan <lizf@cn.fujitsu.com>
AuthorDate: Fri, 20 Mar 2009 10:34:00 +0800
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Fri, 20 Mar 2009 11:20:07 +0100
blktrace: avoid accessing NULL bdev->bd_disk
bdev->bd_disk can be NULL, if the block device is not opened.
Try this against an unmounted partition, and you'll see NULL dereference:
# echo 1 > /sys/block/sda/sda5/enable
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <49C30098.6080107@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
kernel/trace/blktrace.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index dfee6f9..108f4f7 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -1362,6 +1362,14 @@ static int blk_str2act_mask(const char *str)
return mask;
}
+static struct request_queue *blk_trace_get_queue(struct block_device *bdev)
+{
+ if (bdev->bd_disk == NULL)
+ return NULL;
+
+ return bdev_get_queue(bdev);
+}
+
static ssize_t sysfs_blk_trace_attr_show(struct device *dev,
struct device_attribute *attr,
char *buf)
@@ -1376,9 +1384,10 @@ static ssize_t sysfs_blk_trace_attr_show(struct device *dev,
if (bdev == NULL)
goto out_unlock_kernel;
- q = bdev_get_queue(bdev);
+ q = blk_trace_get_queue(bdev);
if (q == NULL)
goto out_bdput;
+
mutex_lock(&bdev->bd_mutex);
if (attr == &dev_attr_enable) {
@@ -1435,7 +1444,7 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev,
if (bdev == NULL)
goto out_unlock_kernel;
- q = bdev_get_queue(bdev);
+ q = blk_trace_get_queue(bdev);
if (q == NULL)
goto out_bdput;
next prev parent reply other threads:[~2009-03-20 10:31 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-20 1:47 [PATCH 0/7] blktrace: various cleanups and fixes Li Zefan
2009-03-20 1:47 ` [PATCH 1/7] blktrace: fix possible memory leak Li Zefan
2009-03-20 10:25 ` [tip:tracing/blktrace] " Li Zefan
2009-03-20 12:53 ` [PATCH 1/7] " Arnaldo Carvalho de Melo
2009-03-21 15:18 ` [tip:tracing/blktrace] " Li Zefan
2009-03-20 1:48 ` [PATCH 2/7] blktrace: make blk_tracer_enabled a bool flag Li Zefan
2009-03-20 8:47 ` Frederic Weisbecker
2009-03-20 10:26 ` [tip:tracing/blktrace] " Li Zefan
2009-03-20 12:58 ` [PATCH 2/7] " Arnaldo Carvalho de Melo
2009-03-21 15:18 ` [tip:tracing/blktrace] " Li Zefan
2009-03-20 1:48 ` [PATCH 3/7] blktrace: remove blk_probe_mutex Li Zefan
2009-03-20 8:50 ` Frederic Weisbecker
2009-03-20 10:26 ` [tip:tracing/blktrace] " Li Zefan
2009-03-20 13:03 ` [PATCH 3/7] " Arnaldo Carvalho de Melo
2009-03-22 6:04 ` Li Zefan
2009-03-22 15:09 ` Arnaldo Carvalho de Melo
2009-03-21 15:18 ` [tip:tracing/blktrace] " Li Zefan
2009-03-20 1:48 ` [PATCH 4/7] blktrace: don't increase blk_probes_ref if failed to setup blk trace Li Zefan
2009-03-20 10:26 ` [tip:tracing/blktrace] " Li Zefan
2009-03-20 13:04 ` [PATCH 4/7] " Arnaldo Carvalho de Melo
2009-03-21 15:18 ` [tip:tracing/blktrace] " Li Zefan
2009-03-20 1:49 ` [PATCH 5/7] blktrace: report EBUSY correctly Li Zefan
2009-03-20 10:26 ` [tip:tracing/blktrace] " Li Zefan
2009-03-20 13:10 ` [PATCH 5/7] " Arnaldo Carvalho de Melo
2009-03-21 15:18 ` Ingo Molnar
2009-03-21 15:19 ` [tip:tracing/blktrace] " Li Zefan
2009-03-20 1:49 ` [PATCH 6/7] blktrace: remove sysfs_blk_trace_enable_show/store() Li Zefan
2009-03-20 3:33 ` Li Zefan
2009-03-20 10:26 ` [tip:tracing/blktrace] " Li Zefan
2009-03-21 15:19 ` Li Zefan
2009-03-20 13:07 ` [PATCH 6/7] " Arnaldo Carvalho de Melo
2009-03-20 1:49 ` [PATCH 7/7] blktrace: avoid accessing NULL bdev->bd_disk Li Zefan
2009-03-20 2:34 ` Li Zefan
2009-03-20 10:26 ` Li Zefan [this message]
2009-03-21 15:19 ` [tip:tracing/blktrace] " Li Zefan
2009-03-20 13:08 ` [PATCH 7/7] " Arnaldo Carvalho de Melo
2009-03-20 10:20 ` [PATCH 0/7] blktrace: various cleanups and fixes Ingo Molnar
2009-03-20 11:09 ` Ingo Molnar
2009-03-23 14:48 ` Steven Rostedt
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=tip-afaebb6720cc62df1b03e36c2f699b00cfee784e@git.kernel.org \
--to=lizf@cn.fujitsu.com \
--cc=acme@redhat.com \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=jens.axboe@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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