fs/open.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fs/open.c b/fs/open.c index 5c68282ea79e..5dfe7cde4ff5 100644 --- a/fs/open.c +++ b/fs/open.c @@ -1075,6 +1075,21 @@ struct file *file_open_root(struct dentry *dentry, struct vfsmount *mnt, } EXPORT_SYMBOL(file_open_root); +/* Hacky hack hack */ +static void check_if_stream(struct file *f, const char *name) +{ + /* Already marked as FMODE_STREAM */ + if (f->f_mode & FMODE_STREAM) + return; + + /* Does it have a real lseek implementation? Not a stream */ + if (f->f_op && f->f_op->llseek && f->f_op->llseek != no_llseek) + return; + + pr_info("%s: file '%s' with ops %lx (%pS) might be a stream file\n", + current->comm, name, (unsigned long)f->f_op, f->f_op); +} + long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode) { struct open_flags op; @@ -1097,6 +1112,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode) } else { fsnotify_open(f); fd_install(fd, f); + check_if_stream(f, tmp->name); } } putname(tmp);