* [RFC] sysfs null dentry pointer checking
@ 2004-05-23 19:47 John Zielinski
0 siblings, 0 replies; only message in thread
From: John Zielinski @ 2004-05-23 19:47 UTC (permalink / raw)
To: linux-kernel
[-- 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);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-05-23 19:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-23 19:47 [RFC] sysfs null dentry pointer checking John Zielinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox