aboutsummaryrefslogtreecommitdiffstats
path: root/src/godo.go
diff options
context:
space:
mode:
authorWe-unite <3205135446@qq.com>2024-07-23 19:32:09 +0800
committerWe-unite <3205135446@qq.com>2024-07-25 17:09:45 +0800
commitfc61a4a525846fa31ee2288df4e82f745bb39c95 (patch)
treee97c7b942c7e843782efbcc48882e6c0854df473 /src/godo.go
parentcf5618ff2e2a183c5bdf6444787dccdcbf26ce76 (diff)
downloadgodo-fc61a4a525846fa31ee2288df4e82f745bb39c95.tar.gz
godo-fc61a4a525846fa31ee2288df4e82f745bb39c95.zip
Try ot fix the out-of-order bug, add EXECVE to itthings_left
The Most important work during this time is to find out solution to the out-of-order bug. Discribe it here in detail: info from audit may be out of order, which means fork may comes after execve, even after exit. What an absurd penomenon to see a process not yet created to work or exit! To deal with this problem, I've tried several ways: - in the 2nd coroutine, when EOE msg comes, if it's a fork/clone event, send it immediately, otherwise wait for some time(such as 100 ms). But after all it delays longer, and has other problems. - the 2nd coroutine doesn't send directly, but record all the finished event id in a slice, and another thread checks once every one second, if there are sth in slice, send corresponding events in the order of event id. But: event that happens first doesn't always has lower id or time, for example, 1 forks 2, then 2 execve, the audit in kernel it self may gets execve before fork(maybe fork makes other settings), which means execve has earlier timestamp and lower event id. The out- of-order problem is not completely resolved. If we then add delays to non-clone event, a more serious problem happens: we must use mutex to lock the slice recording finished event id to prevent crush between send thread and wait thread, but the wait thread can't get the mutex again, because there are to much clone event and frequent send! - So I use no delay but mongodb, when an execve comes, if pid is not recorded, just insert it and wait for the fork. It does works, but some other works is still left to do: - what should i do if 2 forks 3 comes before 1 forks 2? Now I suggest it doesn't happen, but what if? - when execve comes before fork, i recorded it, but if this process has a parent i don't care, delete, or stays there? Also, as mentioned above, I've add EXECVE field in process into db, records all the execve(time, and args) from the same process. Besides, exit_timestamp and exit_code can be caught now, but too many process has no exit info. This is also to be fixed. Now, let's listen to the file changed by process. Don't forget the to-do works listed above!
Diffstat (limited to 'src/godo.go')
-rw-r--r--src/godo.go18
1 files changed, 0 insertions, 18 deletions
diff --git a/src/godo.go b/src/godo.go
index 72f68c0..cc29a01 100644
--- a/src/godo.go
+++ b/src/godo.go
@@ -51,26 +51,8 @@ func main() {
51 } 51 }
52 52
53 // 创世之神,1号进程 53 // 创世之神,1号进程
54 // pids[1] = &process{rootfs: "/", children: make([]int, 0)}
55 // pids[1].children = append(pids[1].children, containerdPid)
56 // 1号进程还是不要在进程树上直接出现了,不然它的小儿子们都会出现 54 // 1号进程还是不要在进程树上直接出现了,不然它的小儿子们都会出现
57
58 // /usr/bin/containerd,也就是我们最关注的进程 55 // /usr/bin/containerd,也就是我们最关注的进程
59 // pids[containerdPid] = &process{rootfs: "/", children: make([]int, 0)}
60 pids.Store(containerdPid, &process{
61 ppid: 1,
62 pid: containerdPid,
63 argv: make([]string, 0),
64 cwd: "/",
65 rootfs: "/",
66 children: make([]int, 0),
67 })
68 p, ok := pids.Load(containerdPid)
69 if !ok {
70 fmt.Printf("???\n")
71 return
72 }
73 p.(*process).argv = append(p.(*process).argv, "/usr/bin/containerd")
74 56
75 // 开始运行,解析命令行参数后监听 57 // 开始运行,解析命令行参数后监听
76 if err := fs.Parse(os.Args[1:]); err != nil { 58 if err := fs.Parse(os.Args[1:]); err != nil {