--- x/fs/read_write.c +++ y/fs/read_write.c @@ -570,6 +570,7 @@ EXPORT_SYMBOL(kernel_write); ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) { ssize_t ret; + struct super_block *sb; if (!(file->f_mode & FMODE_WRITE)) return -EBADF; @@ -583,6 +584,9 @@ ssize_t vfs_write(struct file *file, con return ret; if (count > MAX_RW_COUNT) count = MAX_RW_COUNT; + sb = file_inode(file)->i_sb; + if (!down_read_trylock(&sb->s_umount)) + return -EINVAL; file_start_write(file); if (file->f_op->write) ret = file->f_op->write(file, buf, count, pos); @@ -596,6 +600,7 @@ ssize_t vfs_write(struct file *file, con } inc_syscw(current); file_end_write(file); + up_read(&sb->s_umount); return ret; }