From: Maneesh Soni <maneesh@in.ibm.com>
To: "Duetsch, Thomas LDE1" <thomas.duetsch@siemens.com>
Cc: linux-kernel@vger.kernel.org,
Steven Rostedt <rostedt@goodmis.org>,
mingo@elte.hu
Subject: Re: [SYSFS] Kernel Null pointer dereference in sysfs_readdir()
Date: Thu, 13 Jul 2006 01:28:21 +0530 [thread overview]
Message-ID: <20060712195821.GB1743@in.ibm.com> (raw)
In-Reply-To: <5B0042046ADE774687F32BF3652F5BB9021C9190@kher9eaa.ww007.siemens.net>
On Wed, Jul 12, 2006 at 01:35:50PM +0200, Duetsch, Thomas LDE1 wrote:
> Hi,
>
> I'm currently working on a custom kernel based on Ingo's -rt patch
> (2.6.16-rt29).
>
> While rebooting my machine, I came across a kernel null pointer
> dereference in this code segment in fs/sysfs/dir.c, function
> sysfs_readdir():
>
> for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
> struct sysfs_dirent *next;
> const char * name;
> int len;
>
> next = list_entry(p, struct sysfs_dirent,
> s_sibling);
> if (!next->s_element)
> continue;
>
> name = sysfs_get_name(next);
> len = strlen(name);
> if (next->s_dentry)
> PROBLEM -> ino = next->s_dentry->d_inode->i_ino;
> else
> ino = iunique(sysfs_sb, 2);
>
> Checking the mailing list, I came across this thread:
> "What protection does sysfs_readdir have with SMP/Preemption?"
> http://lkml.org/lkml/2005/11/22/293
> Which handels the exact same problem (And I'm working on the kernel
> Steve was working back then).
> Reading through your suggestions and solutions, I was wondering, what
> would happen if a sysfs file would be deleted instead of created, while
> a sysfs_readdir were in progress.
> Looking through the code, I don't see, where the parents inode mutex is
> taken, to prevent a race condition.
>
parent's inode mutex is taken in vfs_readdir() in case of sysfs_readdir() call
and in sysfs_hash_and_remove() in case of delete path.
> Unfortunately, I can't reproduce the behaviour, nor do I know, which
> file was accessed, when this happens.
>
> Like Steve said back then, this might well be a problem in our code, but
>
> since we didn't change the sysfs, maybe it's a vanilla problem as well.
>
I thought at that time the issue was due to bug in error path which got
fixed by Steve's patch.
Thanks
Maneesh
prev parent reply other threads:[~2006-07-12 19:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-12 11:35 [SYSFS] Kernel Null pointer dereference in sysfs_readdir() Duetsch, Thomas LDE1
2006-07-12 12:06 ` Steven Rostedt
2006-07-12 12:39 ` AW: " Duetsch, Thomas LDE1
2006-07-12 14:06 ` Steven Rostedt
2006-07-12 19:57 ` Maneesh Soni
2006-07-12 20:28 ` Steven Rostedt
2006-07-12 20:39 ` Maneesh Soni
2006-07-13 2:59 ` Steven Rostedt
2006-07-12 19:58 ` Maneesh Soni [this message]
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=20060712195821.GB1743@in.ibm.com \
--to=maneesh@in.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
--cc=thomas.duetsch@siemens.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