This patch disallows setting/enabling or multiple concurrent setting
and/or reading of event filters.
Signed-off-by: Tom Zanussi <[email protected]>
---
kernel/trace/trace_events.c | 30 ++++++++++++++++++++++++++----
1 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index be9299a..eb7ee65 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -481,7 +481,10 @@ event_filter_read(struct file *filp, char __user *ubuf, size_t cnt,
trace_seq_init(s);
+ mutex_lock(&event_mutex);
filter_print_preds(call->preds, s);
+ mutex_unlock(&event_mutex);
+
r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, s->len);
kfree(s);
@@ -514,20 +517,28 @@ event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
return err;
}
+ mutex_lock(&event_mutex);
if (pred->clear) {
filter_free_preds(call);
filter_free_pred(pred);
- return cnt;
+ err = cnt;
+ goto out;
}
if (filter_add_pred(call, pred)) {
filter_free_pred(pred);
- return -EINVAL;
+ err = -EINVAL;
+ goto out;
}
+ mutex_unlock(&event_mutex);
*ppos += cnt;
return cnt;
+
+out:
+ mutex_unlock(&event_mutex);
+ return err;
}
static ssize_t
@@ -547,7 +558,10 @@ subsystem_filter_read(struct file *filp, char __user *ubuf, size_t cnt,
trace_seq_init(s);
+ mutex_lock(&event_mutex);
filter_print_preds(system->preds, s);
+ mutex_unlock(&event_mutex);
+
r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, s->len);
kfree(s);
@@ -580,21 +594,29 @@ subsystem_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
return err;
}
+ mutex_lock(&event_mutex);
if (pred->clear) {
filter_free_subsystem_preds(system);
filter_free_pred(pred);
- return cnt;
+ err = cnt;
+ goto out;
}
if (filter_add_subsystem_pred(system, pred)) {
filter_free_subsystem_preds(system);
filter_free_pred(pred);
- return -EINVAL;
+ err = -EINVAL;
+ goto out;
}
+ mutex_unlock(&event_mutex);
*ppos += cnt;
return cnt;
+
+out:
+ mutex_unlock(&event_mutex);
+ return err;
}
static const struct seq_operations show_event_seq_ops = {
--
1.5.6.3