Hi all, While learning about POSIX, I noticed that file_pread() in fs/vfs/fs_pread.c does a save-seek-read-restore sequence with no locking around it:
savepos = file_seek(filep, 0, SEEK_CUR); pos = file_seek(filep, offset, SEEK_SET); ret = file_read(filep, buf, nbytes); pos = file_seek(filep, savepos, SEEK_SET); If two threads call pread() on the same fd concurrently, one thread's seek() can interfere with the other's read(). POSIX requires pread() to be atomic and not affect the file position. I also checked filep->f_locked but it's only set in file_setlk() for advisory record locking, not as a thread-safety guard here. Is my analysis correct? Happy to work on a patch if confirmed. Thanks, Abhishek Mishra
