lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20151130115615.GJ17308@twins.programming.kicks-ass.net>
Date:	Mon, 30 Nov 2015 12:56:15 +0100
From:	Peter Zijlstra <peterz@...radead.org>
To:	Dmitry Vyukov <dvyukov@...gle.com>
Cc:	Ingo Molnar <mingo@...hat.com>,
	Arnaldo Carvalho de Melo <acme@...nel.org>,
	LKML <linux-kernel@...r.kernel.org>,
	syzkaller <syzkaller@...glegroups.com>,
	Alexander Potapenko <glider@...gle.com>,
	Kostya Serebryany <kcc@...gle.com>,
	Eric Dumazet <edumazet@...gle.com>,
	Sasha Levin <sasha.levin@...cle.com>
Subject: Re: deadlock in perf_ioctl

On Mon, Nov 30, 2015 at 10:20:49AM +0100, Dmitry Vyukov wrote:
> =============================================
> [ INFO: possible recursive locking detected ]
> 4.4.0-rc1+ #129 Not tainted
> ---------------------------------------------
> a.out/6283 is trying to acquire lock:
>  (&ctx->lock){-.....}, at: [<ffffffff815072ce>]
> __perf_event_period+0x8e/0x4b0 kernel/events/core.c:4156
> 
> but task is already holding lock:
>  (&ctx->lock){-.....}, at: [<     inline     >] perf_event_period
> kernel/events/core.c:4212
>  (&ctx->lock){-.....}, at: [<     inline     >] _perf_ioctl
> kernel/events/core.c:4266
>  (&ctx->lock){-.....}, at: [<ffffffff8152331c>] perf_ioctl+0x7bc/0xcc0
> kernel/events/core.c:4320
> 

Indeed so. I suppose the below should fix this, I'll go try in a bit.

---
Subject: perf: Fix PERF_EVENT_IOC_PERIOD deadlock

Dmitry reported a fairly silly recursive lock deadlock for
PERF_EVENT_IOC_PERIOD, fix this by explicitly doing the inactive part of
__perf_event_period() instead of calling that function.

Reported-by: Dmitry Vyukov <dvyukov@...gle.com>
Fixes: c7999c6f3fed ("perf: Fix PERF_EVENT_IOC_PERIOD migration race")
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
---
 kernel/events/core.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 36babfd20648..a991e12e4d0d 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -4216,7 +4216,14 @@ static int perf_event_period(struct perf_event *event, u64 __user *arg)
 		goto retry;
 	}
 
-	__perf_event_period(&pe);
+	if (event->attr.freq) {
+		event->attr.sample_freq = value;
+	} else {
+		event->attr.sample_period = value;
+		event->hw.sample_period = value;
+	}
+
+	local64_set(&event->hw.period_left, 0);
 	raw_spin_unlock_irq(&ctx->lock);
 
 	return 0;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ