p_candebug(9)

p_candebug9

Determine debuggability of a process

Usage

#include <sys/param.h>

#include <sys/proc.h>

int

p_candebug(struct thread *td, struct proc *p);

Overview

This function determines if a given process p is debuggable by some thread td.

The following sysctl(8) variables directly influence the behaviour of p_candebug():

security.bsd.unprivileged_proc_debug

Must be set to a non-zero value to allow unprivileged processes access to the kernel's debug facilities.

kern.securelevel

Debugging of the init process is not allowed if this variable is 1 or greater.

Other such variables indirectly influence it; see cr_bsd_visible(9).

Return values

The p_candebug() function returns 0 if the process denoted by p is debuggable by thread td, or a non-zero error return value otherwise.

Errors

[EPERM]

An unprivileged process attempted to debug another process but the system is configured to deny it( see sysctl(8) variable security.bsd.unprivileged_proc_debug above).

[ESRCH]

Thread td has been jailed and the process to debug does not belong to the same jail or one of its sub-jails, as determined by prison_check(9).

[ESRCH]

cr_bsd_visible(9) denied visibility according to the BSD security policies in force.

[EPERM]

Thread td lacks superuser credentials and its (effective) group set is not a superset of process p's whole group set (including real, effective and saved group IDs).

[EPERM]

Thread td lacks superuser credentials and its (effective) user ID does not match all user IDs of process p.

[EPERM]

Thread td lacks superuser credentials and process p is executing a set-user-ID or set-group-ID executable.

[EPERM]

Process p denotes the initial process initproc() and the sysctl(8) variable kern.securelevel is greater than zero.

[EBUSY]

Process p is in the process of being exec(Ns, 'ed.)

[EPERM]

Process p denied debuggability( see procctl(2), command PROC_TRACE_CTL).

Releases

52 releases since FreeBSD 5.3-RELEASE; the text changed 34 times.

  1. 5.3–6.2
  2. 6.3
  3. 6.4
  4. 7.0
  5. 7.1
  6. 7.2
  7. 7.3
  8. 7.4
  9. 8.0
  10. 8.1
  11. 8.2
  12. 8.3
  13. 8.4
  14. 9.0
  15. 9.1
  16. 9.2
  17. 9.3
  18. 10.0
  19. 10.1
  20. 10.2
  21. 10.3
  22. 10.4
  23. 11.0
  24. 11.1
  25. 11.2
  26. 11.3
  27. 11.4
  28. 12.0
  29. 12.1
  30. 12.2
  31. 12.3
  32. 12.4
  33. 13.0–13.2
  34. 13.3–14.2
  35. 14.3–16.0

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.