ProcessCreate: ParentImage is empty when the parent starts the process from a non-main thread
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 68/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- c, linux
- Bereich
- backend, operating-systems
Rechercherichtung
Start with ebpfKern/sysmonProcCreate.c around lines 124–134, where the parent task and pid are read, then trace how the process cache looks up parent details. Check how Linux thread ids, process ids, and thread group leaders are represented in this path. Done means ProcessCreate events from worker threads report the parent process id, image, and command line correctly; the issue provides a Python reproduction to verify the behavior.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Version: sysmonforlinux 1.6.0 and sysinternalsebpf 2.3.0 from packages.microsoft.com, Ubuntu 24.04.5 on WSL2 (kernel 6.18.33.1-microsoft-standard-WSL2), with a config that logs all ProcessCreate events.
Repro
python3 -c 'import subprocess, threading
subprocess.run(["bash", "-c", "echo from-main-thread"])
t = threading.Thread(target=lambda: subprocess.run(["bash", "-c", "echo from-worker-thread"]))
t.start(); t.join()'
Result (event ID 1)
ProcessId CommandLine ParentProcessId ParentImage
23208 bash -c echo from-main-thread 23207 /usr/bin/python3.12
23210 bash -c echo from-worker-thread 23209 -
Both bash processes have the same parent process (python, 23207), but the second one gets ParentProcessId 23209, the id of the Python worker thread, and ParentImage -. ParentCommandLine is - too.
Cause
sysmonProcCreate.c takes task->parent and then parent->pid (L124-L134). When the child was created by a thread that is not the group leader, parent is that thread, so pid is a thread id; the process id is tgid. The process cache has no entry for that id, so the parent fields stay empty. Reading tgid, and using the thread group leader as the parent process object for the cache lookup, should fix it.
Impact
Any program that starts processes from a worker thread is affected. With Java it is every child process, because the JVM runs main() on a second thread: in my test, the children of java (pid 22953) got ParentProcessId 22954 and ParentImage -. So detections based on the parent image, like "unusual child of java", never match.
Related
When a process execs twice without forking, children of the second image get the first one as ParentImage. Java starts jspawnhelper, which execs the target in the same pid, and a child of that target shows ParentImage .../jspawnhelper. ProcessCache::ProcessGet returns the first open entry for the pid (eventsCommon.cpp L186-L210). I can open a separate issue for this one if you prefer.
- Vorherrschende Sprache
- C
- Sterne
- 2.2k
- Forks
- 224
- Ø Merge
- 4 Std. 50 Min.
- Gemergte PRs (30 T.)
- 3
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus microsoft/Sysmon-Linux
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 72/100
microsoft/Sysmon-Linux#252 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
microsoft/Sysmon-Linux#247 ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 12/100
microsoft/Sysmon-Linux#246 · 3 Kommentare ·
-
Sysmon service executable remains `(deleted)` after restart, causing repeated needrestart restarts and systemd start-limit-hitEvtl. wieder frei @MarioHewardt hat das vor 31 Tagen übernommen, und es ist kein Pull Request offen. Offen
microsoft/Sysmon-Linux#244 · 1 zugewiesene Person ·
-
ProcessTerminate events intermittently report an unrelated user's UID instead of the terminating process's UIDEvtl. vergeben @MarioHewardt hat das vor 111 Tagen übernommen. Offen
microsoft/Sysmon-Linux#238 · 1 zugewiesene Person ·
Alle Issues in microsoft/Sysmon-Linux
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
ly05010419/MacNativeGames#2001 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area/docdb kind/bug priority/medium status/awaiting-triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
yugabyte/yugabyte-db#37426 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area/documentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
obsproject/obs-studio#14184 ·
Maintainer antworten meist innerhalb von 1 Tag
-
extension-modules type-bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
30-minutes algorithm any-language beginner-friendly c community cpp csharp data-structures go good first issue hacktoberfest help wanted kotlin learning leetcode php ruby rust swift
Schwierigkeit 2/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
Huerte/algo-solutions-python#211 ·
Maintainer antworten meist innerhalb von 1 Tag