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: <175551254829.1420.17985179925554402194.tip-bot2@tip-bot2>
Date: Mon, 18 Aug 2025 10:22:28 -0000
From: "tip-bot2 for Peter Zijlstra" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: "Peter Zijlstra (Intel)" <peterz@...radead.org>,
 Lorenzo Stoakes <lorenzo.stoakes@...cle.com>, x86@...nel.org,
 linux-kernel@...r.kernel.org
Subject: [tip: perf/core] perf: Use guard() for aux_mutex in perf_mmap()

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     b33a51564e3eb6c468979f9f08d9b4ad8451bed7
Gitweb:        https://git.kernel.org/tip/b33a51564e3eb6c468979f9f08d9b4ad8451bed7
Author:        Peter Zijlstra <peterz@...radead.org>
AuthorDate:    Tue, 12 Aug 2025 12:39:06 +02:00
Committer:     Peter Zijlstra <peterz@...radead.org>
CommitterDate: Fri, 15 Aug 2025 13:13:00 +02:00

perf: Use guard() for aux_mutex in perf_mmap()

After duplicating the common code into the rb/aux branches is it
possible to use a simple guard() for the aux_mutex. Making the aux
branch self-contained.

Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
Link: https://lore.kernel.org/r/20250812104019.246250452@infradead.org
---
 kernel/events/core.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 89fb069..236c60a 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6975,7 +6975,6 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
 	struct perf_event *event = file->private_data;
 	unsigned long vma_size, nr_pages;
 	long user_extra = 0, extra = 0;
-	struct mutex *aux_mutex = NULL;
 	struct perf_buffer *rb = NULL;
 	int ret, flags = 0;
 	mapped_f mapped;
@@ -7100,8 +7099,7 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
 		if (!rb)
 			goto unlock;
 
-		aux_mutex = &rb->aux_mutex;
-		mutex_lock(aux_mutex);
+		guard(mutex)(&rb->aux_mutex);
 
 		aux_offset = READ_ONCE(rb->user_page->aux_offset);
 		aux_size = READ_ONCE(rb->user_page->aux_size);
@@ -7161,8 +7159,6 @@ aux_success:
 	}
 
 unlock:
-	if (aux_mutex)
-		mutex_unlock(aux_mutex);
 	mutex_unlock(&event->mmap_mutex);
 
 	if (ret)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ