aboutsummaryrefslogtreecommitdiffstats
path: root/include/trace
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2017-01-06 08:12:51 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-01-19 14:18:02 -0500
commit28dad9aa9b367b81f99a36a06d16e89e649133ce (patch)
treebd7f2e951fd7cabc7d8989dbc639daf829b8473e /include/trace
parent4d0f302bf56a03b8023f06a27b811c1a4625c20d (diff)
btrfs: fix crash when tracepoint arguments are freed by wq callbacks
commit ac0c7cf8be00f269f82964cf7b144ca3edc5dbc4 upstream. 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") Reported-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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 e030d6f6c19a..6d7fe1169956 100644
--- a/include/trace/events/btrfs.h
+++ b/include/trace/events/btrfs.h
@@ -1162,22 +1162,26 @@ DECLARE_EVENT_CLASS(btrfs__work,
1162 __entry->func, __entry->ordered_func, __entry->ordered_free) 1162 __entry->func, __entry->ordered_func, __entry->ordered_free)
1163); 1163);
1164 1164
1165/* For situiations that the work is freed */ 1165/*
1166 * For situiations when the work is freed, we pass fs_info and a tag that that
1167 * matches address of the work structure so it can be paired with the
1168 * scheduling event.
1169 */
1166DECLARE_EVENT_CLASS(btrfs__work__done, 1170DECLARE_EVENT_CLASS(btrfs__work__done,
1167 1171
1168 TP_PROTO(struct btrfs_work *work), 1172 TP_PROTO(struct btrfs_fs_info *fs_info, void *wtag),
1169 1173
1170 TP_ARGS(work), 1174 TP_ARGS(fs_info, wtag),
1171 1175
1172 TP_STRUCT__entry_btrfs( 1176 TP_STRUCT__entry_btrfs(
1173 __field( void *, work ) 1177 __field( void *, wtag )
1174 ), 1178 ),
1175 1179
1176 TP_fast_assign_btrfs(btrfs_work_owner(work), 1180 TP_fast_assign_btrfs(fs_info,
1177 __entry->work = work; 1181 __entry->wtag = wtag;
1178 ), 1182 ),
1179 1183
1180 TP_printk_btrfs("work->%p", __entry->work) 1184 TP_printk_btrfs("work->%p", __entry->wtag)
1181); 1185);
1182 1186
1183DEFINE_EVENT(btrfs__work, btrfs_work_queued, 1187DEFINE_EVENT(btrfs__work, btrfs_work_queued,
@@ -1196,9 +1200,9 @@ DEFINE_EVENT(btrfs__work, btrfs_work_sched,
1196 1200
1197DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done, 1201DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
1198 1202
1199 TP_PROTO(struct btrfs_work *work), 1203 TP_PROTO(struct btrfs_fs_info *fs_info, void *wtag),
1200 1204
1201 TP_ARGS(work) 1205 TP_ARGS(fs_info, wtag)
1202); 1206);
1203 1207
1204DEFINE_EVENT(btrfs__work, btrfs_ordered_sched, 1208DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,