I want to monitor systemcalls with bpftrace (https://github.com/iovisor/bpftrace/). For most systemcalls, this works without problems, but I have problems to monitor applications, where the suid bit is set.
Folowing syscalls are monitored (https://github.com/iovisor/bpftrace/blob/master/tools/setuids.bt):
- setuid
- setfsuid
- setreuid
- setresuid
For testing purposes, a copy of the sleep
command is used.
$ cp /bin/sleep ~ $ sudo chown root ~/sleep $ sudo chmod +s ~/sleep
btftrace
is started with following command:
$ sudo ./bpftrace setuids.bt
After the start of btftrace
the custom sleep command is started.
$ ./sleep 1337
I expected, that btftrace should print an information about the started process, but nothing was captured.
ps
is used to verify, if the process is running with root-privileges:
$ ps aux | grep sleep root 5552 0.0 0.0 16872 1012 pts/2 S+ 10:18 0:00 ./sleep 1337
To check if bpftrace
captures the mentioned syscalls, su
was started to switch to a different user:
$ su testuser
This was captured by bpftrace
and to process id and additional information is shown:
$ sudo ./bpftrace setuids.bt Attaching 7 probes... Tracing setuid(2) family syscalls. Hit Ctrl-C to end. TIME PID COMM UID SYSCALL ARGS (RET) 10:23:15 5661 su 1000 setuid uid=1001 (0)
Why is this not detected by monitoring the mentioned syscalls?