This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH] plug preempt leak in _stp_runtime_entryfn_put/get_context
- From: Mateusz Guzik <mguzik at redhat dot com>
- To: systemtap at sourceware dot org
- Cc: dsmith at redhat dot com
- Date: Mon, 2 May 2016 17:48:11 +0200
- Subject: [PATCH] plug preempt leak in _stp_runtime_entryfn_put/get_context
- Authentication-results: sourceware.org; auth=none
If _stp_runtime_entryfn_get_context returns a context, preemption
counter is always incremented. On the other hand
_stp_runtime_entryfn_put_context only decrements the counter if the
passed context matches the one currently set on the cpu.
The context can be set to NULL by _stp_runtime_contexts_free, making the
comparison false and in effect leading to a leak, e.g.:
timer: _stp_ctl_work_callback+0x0/0x1e0[stap_af8544c7eb51251ef8c
377abff659b05_25070] preempt leak: 00000101 -> 00000102
Signed-off-by: Mateusz Guzik <mguzik@redhat.com>
---
runtime/linux/runtime_context.h | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/runtime/linux/runtime_context.h b/runtime/linux/runtime_context.h
index c9ffe18..9d325da 100644
--- a/runtime/linux/runtime_context.h
+++ b/runtime/linux/runtime_context.h
@@ -80,11 +80,12 @@ static struct context * _stp_runtime_entryfn_get_context(void)
static inline void _stp_runtime_entryfn_put_context(struct context *c)
{
- if (c && c == _stp_runtime_get_context()) {
- atomic_dec(&c->busy);
+ if (c) {
+ if (c == _stp_runtime_get_context())
+ atomic_dec(&c->busy);
+ /* else, warn about bad state? */
preempt_enable_no_resched();
}
- /* else, warn about bad state? */
return;
}
--
2.5.5