git: 30ea55ff5eea - stable/15 - hwpmc: On attach, fix allowing a PMC's owner to attach it to itself

From: Olivier Certner <olce_at_FreeBSD.org>
Date: Thu, 18 Sep 2025 08:51:57 UTC
The branch stable/15 has been updated by olce:

URL: https://cgit.FreeBSD.org/src/commit/?id=30ea55ff5eea80ee9b1e021b151b16c799fb288d

commit 30ea55ff5eea80ee9b1e021b151b16c799fb288d
Author:     Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2025-09-09 12:48:05 +0000
Commit:     Olivier Certner <olce@FreeBSD.org>
CommitDate: 2025-09-18 08:50:28 +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
    
    (cherry picked from commit 1c40b15971f09c0c0676ae476b88b32166eae8ac)
---
 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;