From: John Zielinski <grim@undead.cc>
To: linux-kernel@vger.kernel.org
Subject: [RFC] sysfs null dentry pointer checking
Date: Sun, 23 May 2004 15:47:21 -0400 [thread overview]
Message-ID: <40B0FFC9.1060601@undead.cc> (raw)
[-- Attachment #1: Type: text/plain, Size: 670 bytes --]
I've just discovered that some of the sysfs directory functions do not
check if the dentry pointer is valid. Some of the subsystems in the
kernel don't check the return value of subsystem_register since not
being able to create a directory in sysfs is not fatal and shouldn't
prevent booting the machine. Any kobject that tries to create a
directory under that subsystem would cause a null pointer dereference.
Here's a patch where the dentry pointers should be checked. The sysfs
directory structure wouldn't get updated if there were any directory
creation errors in a parent but the internal kset/kobject hierarchy
would still function properly.
John
[-- Attachment #2: sysfs_dir_null_check --]
[-- Type: text/plain, Size: 660 bytes --]
diff -urNX dontdiff linux-2.6.6/fs/sysfs/dir.c linux/fs/sysfs/dir.c
--- linux-2.6.6/fs/sysfs/dir.c 2004-05-09 22:32:28.000000000 -0400
+++ linux/fs/sysfs/dir.c 2004-05-23 15:15:08.000000000 -0400
@@ -26,6 +26,9 @@
{
int error;
+ if (!p)
+ return -EFAULT;
+
down(&p->d_inode->i_sem);
*d = sysfs_get_dentry(p,n);
if (!IS_ERR(*d)) {
@@ -95,7 +98,8 @@
void sysfs_remove_subdir(struct dentry * d)
{
- remove_dir(d);
+ if (d)
+ remove_dir(d);
}
@@ -164,6 +168,11 @@
if (!kobj->parent)
return;
+ if (!kobj->dentry) {
+ kobject_set_name(kobj,new_name);
+ return;
+ }
+
parent = kobj->parent->dentry;
down(&parent->d_inode->i_sem);
reply other threads:[~2004-05-23 19:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=40B0FFC9.1060601@undead.cc \
--to=grim@undead.cc \
--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