From: Arjan van de Ven <arjan@infradead.org>
To: airlied@linux.ie
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] drm: fix crash due to /proc registration race
Date: Sat, 31 May 2008 20:39:40 -0700 [thread overview]
Message-ID: <20080531203940.40536c9a@infradead.org> (raw)
From: Arjan van de Ven <arjan@linux.intel.com>
Subject: [PATCH] drm: fix crash due to /proc registration race
The DRM layer creates proc entries like this:
ent = create_proc_entry(drm_proc_list[i].name,
S_IFREG | S_IRUGO, minor->dev_root);
if (!ent) {
... stuff ...
}
ent->read_proc = drm_proc_list[i].f;
ent->data = minor;
however that leaves a short window where the /proc file is visible,
but where ->data is not initialized yet.
It appears that this race is actually hit in practice:
http://www.kerneloops.org/search.php?search=drm_name_info
(of course it could be some other race.. but this race appears
to be there at least)
Reported-by: www.kerneloops.org
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
---
drivers/char/drm/drm_proc.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/drivers/char/drm/drm_proc.c b/drivers/char/drm/drm_proc.c
index 93b1e04..19e61ad 100644
--- a/drivers/char/drm/drm_proc.c
+++ b/drivers/char/drm/drm_proc.c
@@ -164,9 +164,20 @@ static int drm_name_info(char *buf, char **start, off_t offset, int request,
int *eof, void *data)
{
struct drm_minor *minor = (struct drm_minor *) data;
- struct drm_device *dev = minor->dev;
+ struct drm_device *dev;
int len = 0;
+ /*
+ * When creating the /proc files, there is a tiny race window
+ * where "data" isn't assigned yet... error out rather than dereference
+ */
+ if (!data) {
+ *eof = 1;
+ return 0;
+ }
+
+ dev = minor->dev;
+
if (offset > DRM_PROC_LIMIT) {
*eof = 1;
return 0;
--
1.5.5.1
--
If you want to reach me at my work email, use arjan@linux.intel.com
For development, discussion and tips for power savings,
visit http://www.lesswatts.org
next reply other threads:[~2008-06-01 3:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-01 3:39 Arjan van de Ven [this message]
2008-06-01 4:48 ` [PATCH] drm: make drm use create_proc_read_entry() instead Arjan van de Ven
2008-06-01 9:25 ` Alexey Dobriyan
2008-06-01 9:36 ` Al Viro
2008-06-01 10:10 ` [PATCH] drm: switch to seq_files Alexey Dobriyan
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=20080531203940.40536c9a@infradead.org \
--to=arjan@infradead.org \
--cc=airlied@linux.ie \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®