diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2024-09-04 12:15:38 +0200 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2024-09-04 12:15:38 +0200 |
commit | eb876ea724835126f215c9a5bcc9e6148e2a6d15 (patch) | |
tree | 689c215270b023c2f94a6629c7f1d3ef8e49c28a /kernel/trace/trace.h | |
parent | 2dce993165088dbe728faa21547e3b74213b6732 (diff) | |
parent | 67784a74e258a467225f0e68335df77acd67b7ab (diff) |
Merge branch 'linus' into smp/core
Pull in upstream changes so further patches don't conflict.
Diffstat (limited to 'kernel/trace/trace.h')
-rw-r--r-- | kernel/trace/trace.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 8783bebd0562e..bd3e3069300e2 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -1634,6 +1634,29 @@ static inline void *event_file_data(struct file *filp) extern struct mutex event_mutex; extern struct list_head ftrace_events; +/* + * When the trace_event_file is the filp->i_private pointer, + * it must be taken under the event_mutex lock, and then checked + * if the EVENT_FILE_FL_FREED flag is set. If it is, then the + * data pointed to by the trace_event_file can not be trusted. + * + * Use the event_file_file() to access the trace_event_file from + * the filp the first time under the event_mutex and check for + * NULL. If it is needed to be retrieved again and the event_mutex + * is still held, then the event_file_data() can be used and it + * is guaranteed to be valid. + */ +static inline struct trace_event_file *event_file_file(struct file *filp) +{ + struct trace_event_file *file; + + lockdep_assert_held(&event_mutex); + file = READ_ONCE(file_inode(filp)->i_private); + if (!file || file->flags & EVENT_FILE_FL_FREED) + return NULL; + return file; +} + extern const struct file_operations event_trigger_fops; extern const struct file_operations event_hist_fops; extern const struct file_operations event_hist_debug_fops; |