]> git.baikalelectronics.ru Git - kernel.git/commit
vfs: lseek(fd, 0, SEEK_CUR) race condition
authorAlain Knaff <alain@knaff.lu>
Tue, 11 Nov 2008 01:08:08 +0000 (17:08 -0800)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 5 Jan 2009 16:53:07 +0000 (11:53 -0500)
commit5b6f1eb97d462a45be3b30759758b5fdbb562c8c
treee8f664c34dde71b95955f57caad3093581be87ef
parent7d3b56ba37a95f1f370f50258ed3954c304c524b
vfs: lseek(fd, 0, SEEK_CUR) race condition

This patch fixes a race condition in lseek. While it is expected that
unpredictable behaviour may result while repositioning the offset of a
file descriptor concurrently with reading/writing to the same file
descriptor, this should not happen when merely *reading* the file
descriptor's offset.

Unfortunately, the only portable way in Unix to read a file
descriptor's offset is lseek(fd, 0, SEEK_CUR); however executing this
concurrently with read/write may mess up the position.

[with fixes from akpm]

Signed-off-by: Alain Knaff <alain@knaff.lu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/read_write.c