Re: [PATCH] Possible race in sysfs_read_file() andsysfs_write_file()

From: Andrew Morton
Date: Wed Sep 01 2004 - 18:48:17 EST


Simon Derr <Simon.Derr@xxxxxxxx> wrote:
>
> I think there is a possibility for two threads from a single process to
> race in sysfs_read_file() if they call read() on the same file at the same
> time.

I think there is, too.

I also wonder what happens if the first read of a sysfs file is not at
offset zero (eg: pread()):

static ssize_t
sysfs_read_file(struct file *file, char __user *buf, size_t count, loff_t *ppos)
{
struct sysfs_buffer * buffer = file->private_data;
ssize_t retval = 0;

if (!*ppos) {
if ((retval = fill_read_buffer(file->f_dentry,buffer)))


we seem to not allocate the buffer at all?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/