From: Paolo 'Blaisorblade' Giarrusso Ext3 is currently using a duplicate version of generic_open_file, and this should be fixed, before it gets out of sync. In fact, it *has* got out of sync. Apart some cosmetic changes (which are not a problem), note that it directly reads inode->i_size, while the generic version uses i_size_read(). I'm not sure if this bug can actually be triggered, but here follows a possible scenario: when - a file is brought into inode cache - that file is either truncated or extended (i.e. inode->i_size is changed) and after this it changes it's "more than 2Gb" property, - and process B opens that file in the meanwhile, I suppose the size check can be hurted by a race condition, doesn't it? Similar checks should probably be done for other FS's. Also, ext2 does not have this problem - someone fixed this problem in ext2 but not ext3? How? Signed-off-by: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton --- 25-akpm/fs/ext3/file.c | 16 +--------------- 1 files changed, 1 insertion(+), 15 deletions(-) diff -puN fs/ext3/file.c~ext3-use-generic_open_file-to-fix-possible-preemption-bugs fs/ext3/file.c --- 25/fs/ext3/file.c~ext3-use-generic_open_file-to-fix-possible-preemption-bugs Thu Nov 18 15:00:58 2004 +++ 25-akpm/fs/ext3/file.c Thu Nov 18 15:00:58 2004 @@ -43,20 +43,6 @@ static int ext3_release_file (struct ino return 0; } -/* - * Called when an inode is about to be opened. - * We use this to disallow opening RW large files on 32bit systems if - * the caller didn't specify O_LARGEFILE. On 64bit systems we force - * on this flag in sys_open. - */ -static int ext3_open_file (struct inode *inode, struct file *filp) -{ - if (!(filp->f_flags & O_LARGEFILE) && - inode->i_size > 0x7FFFFFFFLL) - return -EFBIG; - return 0; -} - static ssize_t ext3_file_write(struct kiocb *iocb, const char __user *buf, size_t count, loff_t pos) { @@ -125,7 +111,7 @@ struct file_operations ext3_file_operati .writev = generic_file_writev, .ioctl = ext3_ioctl, .mmap = generic_file_mmap, - .open = ext3_open_file, + .open = generic_file_open, .release = ext3_release_file, .fsync = ext3_sync_file, .sendfile = generic_file_sendfile, _