FreeBSD: skip exe check for kernel thread

Kernel threads do not have an executable and the check can result in
garbage values as unprivileged user.
This commit is contained in:
Christian Göttsche 2021-06-13 11:18:12 +02:00 committed by Benny Baumann
parent fbe3a2155f
commit af0b67ccd2
1 changed files with 5 additions and 6 deletions

View File

@ -380,16 +380,15 @@ static inline void FreeBSDProcessList_scanMemoryInfo(ProcessList* pl) {
}
static void FreeBSDProcessList_updateExe(const struct kinfo_proc* kproc, Process* proc) {
const int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, kproc->ki_pid };
char buffer[2048];
size_t size = sizeof(buffer);
if (sysctl(mib, 4, buffer, &size, NULL, 0) != 0) {
if (Process_isKernelThread(proc)) {
Process_updateExe(proc, NULL);
return;
}
/* Kernel threads return an empty buffer */
if (buffer[0] == '\0') {
const int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, kproc->ki_pid };
char buffer[2048];
size_t size = sizeof(buffer);
if (sysctl(mib, 4, buffer, &size, NULL, 0) != 0) {
Process_updateExe(proc, NULL);
return;
}