tracing: only truncate ftrace files when O_TRUNC is set
The current code will truncate the ftrace files contents if O_APPEND is not set and the file is opened in write mode. This is incorrect. It should only truncate the file if O_TRUNC is set. Otherwise if one of these files is opened by a C program with fopen "r+", it will incorrectly truncate the file. Reported-by: Jiri Olsa <jolsa@redhat.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
This commit is contained in:
committed by
Steven Rostedt
parent
4c739ff043
commit
8650ae32ef
@@ -2031,7 +2031,7 @@ static int tracing_open(struct inode *inode, struct file *file)
|
||||
|
||||
/* If this file was open for write, then erase contents */
|
||||
if ((file->f_mode & FMODE_WRITE) &&
|
||||
!(file->f_flags & O_APPEND)) {
|
||||
(file->f_flags & O_TRUNC)) {
|
||||
long cpu = (long) inode->i_private;
|
||||
|
||||
if (cpu == TRACE_PIPE_ALL_CPU)
|
||||
|
Reference in New Issue
Block a user