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-next>] [day] [month] [year] [list]
Message-Id: <20191106052935.8352-1-cai@lca.pw>
Date:   Wed,  6 Nov 2019 00:29:35 -0500
From:   Qian Cai <cai@....pw>
To:     mingo@...hat.com, peterz@...radead.org
Cc:     andi@...stfloor.org, acme@...nel.org, mark.rutland@....com,
        jolsa@...hat.com, namhyung@...nel.org,
        linux-kernel@...r.kernel.org, Qian Cai <cai@....pw>
Subject: [PATCH -next] perf/core: fix unlock balance in perf_init_event

The -next commit "perf/core: Optimize perf_init_event()" [1] introduced
an unlock imbalance in perf_init_event() where it calls "goto again" and
then only repeat rcu_read_unlock().

  WARNING: bad unlock balance detected!
  perf_event_open/6185 is trying to release lock (rcu_read_lock) at:
  [<ffffffffb5eb4039>] perf_event_alloc+0xbb9/0x17f0
  but there are no more locks to release!
  other info that might help us debug this:
  2 locks held by perf_event_open/6185:
  #0: ffff888526780b50 (&sig->cred_guard_mutex){+.+.}, at: __do_sys_perf_event_open+0x6ee/0x1460
  #1: ffffffffb866b4e8 (&pmus_srcu){....}, at: perf_event_alloc+0xab8/0x17f0
  Call Trace:
   dump_stack+0xa0/0xea
   print_unlock_imbalance_bug.cold.40+0xb1/0xb6
   lock_release+0x349/0x4b0
   perf_event_alloc+0xbcf/0x17f0
   __do_sys_perf_event_open+0x1e2/0x1460
   __x64_sys_perf_event_open+0x62/0x70
   do_syscall_64+0xcc/0xaec
   entry_SYSCALL_64_after_hwframe+0x49/0xbe

[1] https://lore.kernel.org/lkml/20191022092307.425783389@infradead.org/

Signed-off-by: Qian Cai <cai@....pw>
---
 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 cfd89b4a02d8..8226d6ecdb86 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -10307,7 +10307,6 @@ static struct pmu *perf_init_event(struct perf_event *event)
 			goto unlock;
 	}
 
-	rcu_read_lock();
 	/*
 	 * PERF_TYPE_HARDWARE and PERF_TYPE_HW_CACHE
 	 * are often aliases for PERF_TYPE_RAW.
@@ -10317,6 +10316,7 @@ static struct pmu *perf_init_event(struct perf_event *event)
 		type = PERF_TYPE_RAW;
 
 again:
+	rcu_read_lock();
 	pmu = idr_find(&pmu_idr, type);
 	rcu_read_unlock();
 	if (pmu) {
-- 
2.21.0 (Apple Git-122)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ