Re: PROBLEM: pthread-safety bug in write(2) on Linux 2.6.x

From: Nikita Danilov
Date: Fri Apr 14 2006 - 06:25:45 EST


Linus Torvalds writes:
>

[...]

> + * so it's ok to test it independently on the lock/unlock path
> + * rather than explicitly remembering whether we locked it.
> + */
> +static inline loff_t file_pos_read_lock(struct file *file)
> {
> + if (file->f_mode & FMODE_LSEEK)
> + mutex_lock(&file->f_pos_lock);
> return file->f_pos;
> }
>
> -static inline void file_pos_write(struct file *file, loff_t pos)
> +static inline void file_pos_write_unlock(struct file *file, loff_t pos)
> {
> file->f_pos = pos;
> + if (file->f_mode & FMODE_LSEEK)
> + mutex_unlock(&file->f_pos_lock);
> }

Naming of two functions above is confusing: it looks like read/write
lock is taken. Maybe file_pos_lock_and_get() and
file_pos_set_and_unlock()?

Nikita.
-
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/