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:          ebccf1e3a6 ("Bring a working snapshot of hwpmc(4), ...")
MFC after:      9 days
Sponsored by:   The FreeBSD Foundation
This commit is contained in:
Olivier Certner committed 2025-09-09 17:56:47 +02:00
1 parent 1c3c698ba4
commit 1c40b15971
1 file changed
+1 -1
+1 -1
View File
@@ -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;