[Bug 279566] procctl not working as expected.

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 07 Jun 2024 07:29:16 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=279566

            Bug ID: 279566
           Summary: procctl not working as expected.
           Product: Base System
           Version: 13.2-RELEASE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: wzis@hotmail.com

the procctl for PROC_TRACE_CTL is not working on my FreeBSD 13.1.
[root@bsd123 ~]# uname -a
FreeBSD bsd123 13.1-RELEASE-p9 FreeBSD 13.1-RELEASE-p9 GENERIC amd64
[root@bsd123 ~]# cat dt.c
#include <stdlib.h>
#include <sys/types.h>
#include <sys/procctl.h>
#include <unistd.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
    int trace_flag = PROC_TRACE_CTL_DISABLE;
    pid_t pid;

    if (argc != 2) {
        printf("Usage: %s <pid>\n", argv[0]);
        return 1;
    }

    pid = atoi(argv[1]);

    if (procctl(P_PID, pid, PROC_TRACE_CTL, &trace_flag) == -1) {
        perror("procctl");
        return 1;
    }

    printf("Tracing disabled for process %d\n", pid);

    return 0;
}
[root@bsd123 ~]# cc -o dt dt.c
[root@bsd123 ~]# ./dt 868
Tracing disabled for process 868
[root@bsd123 ~]# truss -p 868

As above showing, though the procctl didn't error out, but after "disable" the
tracing, the "truss -p PID" still can attach to the process.

-- 
You are receiving this mail because:
You are the assignee for the bug.