git: 1c40b15971f0 - main - hwpmc: On attach, fix allowing a PMC's owner to attach it to itself
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 09 Sep 2025 15:57:58 UTC
The branch main has been updated by olce:
URL: https://cgit.FreeBSD.org/src/commit/?id=1c40b15971f09c0c0676ae476b88b32166eae8ac
commit 1c40b15971f09c0c0676ae476b88b32166eae8ac
Author: Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2025-09-09 12:48:05 +0000
Commit: Olivier Certner <olce@FreeBSD.org>
CommitDate: 2025-09-09 15:56:47 +0000
hwpmc: On attach, fix allowing a PMC's owner to attach it to itself
The returned value in this case was wrong, and would basically prevent
some PMC's owner process to attach that PMC to itself although the
security checks underneath would have allowed it.
Now that this early return has been fixed, its block basically becomes
a performance short-circuit which has no effect from a functional
standpoint.
Fixes: ebccf1e3a6b1 ("Bring a working snapshot of hwpmc(4), ...")
MFC after: 9 days
Sponsored by: The FreeBSD Foundation
---
sys/dev/hwpmc/hwpmc_mod.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c
index 15c782b91b69..a6a6ae68996c 100644
--- a/sys/dev/hwpmc/hwpmc_mod.c
+++ b/sys/dev/hwpmc/hwpmc_mod.c
@@ -1041,7 +1041,7 @@ pmc_can_attach(struct pmc *pm, struct proc *t)
*/
if ((o = pm->pm_owner->po_owner) == t)
- return (false);
+ return (true);
PROC_LOCK(o);
oc = o->p_ucred;