aboutsummaryrefslogtreecommitdiffstats
path: root/include/trace
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2017-01-06 08:12:51 -0500
committerDavid Sterba <dsterba@suse.com>2017-01-09 05:24:50 -0500
commitac0c7cf8be00f269f82964cf7b144ca3edc5dbc4 (patch)
treeec90457b5fe8979eeb3f3d63cc6131ed53b1f735 /include/trace
parent2939e1a86f758b55cdba73e29397dd3d94df13bc (diff)
btrfs: fix crash when tracepoint arguments are freed by wq callbacks
Enabling btrfs tracepoints leads to instant crash, as reported. The wq callbacks could free the memory and the tracepoints started to dereference the members to get to fs_info. The proposed fix https://marc.info/?l=linux-btrfs&m=148172436722606&w=2 removed the tracepoints but we could preserve them by passing only the required data in a safe way. Fixes: bc074524e123 ("btrfs: prefix fsid to all trace events") CC: stable@vger.kernel.org # 4.8+ Reported-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'include/trace')
-rw-r--r--include/trace/events/btrfs.h22
1 files changed, 13 insertions, 9 deletions
diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h
index c14bed4ab097..b09225c77676 100644
--- a/include/trace/events/btrfs.h
+++ b/include/trace/events/btrfs.h
@@ -1157,22 +1157,26 @@ DECLARE_EVENT_CLASS(btrfs__work,
1157 __entry->func, __entry->ordered_func, __entry->ordered_free) 1157 __entry->func, __entry->ordered_func, __entry->ordered_free)
1158); 1158);
1159 1159
1160/* For situiations that the work is freed */ 1160/*
1161 * For situiations when the work is freed, we pass fs_info and a tag that that
1162 * matches address of the work structure so it can be paired with the
1163 * scheduling event.
1164 */
1161DECLARE_EVENT_CLASS(btrfs__work__done, 1165DECLARE_EVENT_CLASS(btrfs__work__done,
1162 1166
1163 TP_PROTO(struct btrfs_work *work), 1167 TP_PROTO(struct btrfs_fs_info *fs_info, void *wtag),
1164 1168
1165 TP_ARGS(work), 1169 TP_ARGS(fs_info, wtag),
1166 1170
1167 TP_STRUCT__entry_btrfs( 1171 TP_STRUCT__entry_btrfs(
1168 __field( void *, work ) 1172 __field( void *, wtag )
1169 ), 1173 ),
1170 1174
1171 TP_fast_assign_btrfs(btrfs_work_owner(work), 1175 TP_fast_assign_btrfs(fs_info,
1172 __entry->work = work; 1176 __entry->wtag = wtag;
1173 ), 1177 ),
1174 1178
1175 TP_printk_btrfs("work->%p", __entry->work) 1179 TP_printk_btrfs("work->%p", __entry->wtag)
1176); 1180);
1177 1181
1178DEFINE_EVENT(btrfs__work, btrfs_work_queued, 1182DEFINE_EVENT(btrfs__work, btrfs_work_queued,
@@ -1191,9 +1195,9 @@ DEFINE_EVENT(btrfs__work, btrfs_work_sched,
1191 1195
1192DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done, 1196DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
1193 1197
1194 TP_PROTO(struct btrfs_work *work), 1198 TP_PROTO(struct btrfs_fs_info *fs_info, void *wtag),
1195 1199
1196 TP_ARGS(work) 1200 TP_ARGS(fs_info, wtag)
1197); 1201);
1198 1202
1199DEFINE_EVENT(btrfs__work, btrfs_ordered_sched, 1203DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,