LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: tip-bot for Leon Yu <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, paulus@samba.org,
	tglx@linutronix.de, hpa@zytor.com, acme@kernel.org,
	a.p.zijlstra@chello.nl, mingo@kernel.org, chianglungyu@gmail.com
Subject: [tip:perf/urgent] perf: Fix context leak in put_event()
Date: Mon, 16 Mar 2015 05:06:50 -0700	[thread overview]
Message-ID: <tip-d415a7f1c1a8406b22d95b943c66a5b73a37bc19@git.kernel.org> (raw)
In-Reply-To: <1424954613-5034-1-git-send-email-chianglungyu@gmail.com>

Commit-ID:  d415a7f1c1a8406b22d95b943c66a5b73a37bc19
Gitweb:     http://git.kernel.org/tip/d415a7f1c1a8406b22d95b943c66a5b73a37bc19
Author:     Leon Yu <chianglungyu@gmail.com>
AuthorDate: Thu, 26 Feb 2015 20:43:33 +0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 13 Mar 2015 10:02:18 +0100

perf: Fix context leak in put_event()

Commit:

  a83fe28e2e45 ("perf: Fix put_event() ctx lock")

changed the locking logic in put_event() by replacing mutex_lock_nested()
with perf_event_ctx_lock_nested(), but didn't fix the subsequent
mutex_unlock() with a correct counterpart, perf_event_ctx_unlock().

Contexts are thus leaked as a result of incremented refcount
in perf_event_ctx_lock_nested().

Signed-off-by: Leon Yu <chianglungyu@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Fixes: a83fe28e2e45 ("perf: Fix put_event() ctx lock")
Link: http://lkml.kernel.org/r/1424954613-5034-1-git-send-email-chianglungyu@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/events/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index f04daab..453ef61 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3591,7 +3591,7 @@ static void put_event(struct perf_event *event)
 	ctx = perf_event_ctx_lock_nested(event, SINGLE_DEPTH_NESTING);
 	WARN_ON_ONCE(ctx->parent_ctx);
 	perf_remove_from_context(event, true);
-	mutex_unlock(&ctx->mutex);
+	perf_event_ctx_unlock(event, ctx);
 
 	_free_event(event);
 }

      parent reply	other threads:[~2015-03-16 12:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-26 12:43 [PATCH] perf: fix put_event() ctx leak Leon Yu
2015-03-13  4:53 ` Leon Yu
2015-03-16 12:06 ` tip-bot for Leon Yu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-d415a7f1c1a8406b22d95b943c66a5b73a37bc19@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=chianglungyu@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulus@samba.org \
    --cc=tglx@linutronix.de \
    --subject='Re: [tip:perf/urgent] perf: Fix context leak in put_event()' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).