lkml.org 
[lkml]   [2004]   [Sep]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Possible race in sysfs_read_file() and sysfs_write_file()
On Fri, 3 Sep 2004, Simon Derr wrote:

> On Thu, 2 Sep 2004, Andrew Morton wrote:
>
> > Simon Derr <Simon.Derr@bull.net> wrote:
> > >
> > > @@ -140,13 +145,17 @@
> > > struct sysfs_buffer * buffer = file->private_data;
> > > ssize_t retval = 0;
> > >
> > > - if (!*ppos) {
> > > + down(&buffer->sem);
> > > + if ((!*ppos) || (!buffer->page)) {
> > > if ((retval = fill_read_buffer(file->f_dentry,buffer)))
> > > - return retval;
> > > + goto out;
> >
> > Why are we testing *ppos at all in here?
>
> And if we open a sysfs file with O_RDWR, and write() into it, then this is
> needed if we want to read(), because else the buffer will have been
> allocated, but ops->show() not called. I'm not too sure about this being
> useful either.

Hmmm...
We are still screwed if we read at offset >0 after a write.

Possible fix would be to add a 'dirty' flag to the sysfs_buffer when
write() is called, so we force a call to fill_read_buffer() on the next
read().

Or maybe simply forbid O_RDWR open() ? Are they of any use ?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:05    [W:0.284 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site