diff options
author | Slava Pestov <slavapestov@google.com> | 2010-11-24 15:13:16 -0800 |
---|---|---|
committer | Willy Tarreau <w@1wt.eu> | 2011-02-09 22:15:39 +0100 |
commit | ab42f1f2ba5bea8d266ed383438ad5652617b366 (patch) | |
tree | 77e7c3f72e4abbceec819ad2f50944c741a5dfb8 /kernel | |
parent | 19e91969bdb9e50973805dfaa7c0e9cd80ab6657 (diff) |
tracing: Fix panic when lseek() called on "trace" opened for writing
commit 364829b1263b44aa60383824e4c1289d83d78ca7 upstream.
The file_ops struct for the "trace" special file defined llseek as seq_lseek().
However, if the file was opened for writing only, seq_open() was not called,
and the seek would dereference a null pointer, file->private_data.
This patch introduces a new wrapper for seq_lseek() which checks if the file
descriptor is opened for reading first. If not, it does nothing.
Signed-off-by: Slava Pestov <slavapestov@google.com>
LKML-Reference: <1290640396-24179-1-git-send-email-slavapestov@google.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
[wt: applied to tracing_lt_fops too /wt]
Signed-off-by: Willy Tarreau <w@1wt.eu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index dfe39952622..f937f5d719c 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -2041,17 +2041,25 @@ static int show_traces_open(struct inode *inode, struct file *file) return ret; } +static loff_t tracing_seek(struct file *file, loff_t offset, int origin) +{ + if (file->f_mode & FMODE_READ) + return seq_lseek(file, offset, origin); + else + return 0; +} + static struct file_operations tracing_fops = { .open = tracing_open, .read = seq_read, - .llseek = seq_lseek, + .llseek = tracing_seek, .release = tracing_release, }; static struct file_operations tracing_lt_fops = { .open = tracing_lt_open, .read = seq_read, - .llseek = seq_lseek, + .llseek = tracing_seek, .release = tracing_release, }; |