From 214351e168def9426c79e1f65a93ddb112cee906 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Wed, 19 Jan 2022 17:38:24 +0000 Subject: executor: fail on SEGV during clone() As was found out in #2921, fork bombs are still possible in Linux-based instances. One of the possible reasons is described below. An invalid stack can be passed to the clone() call, thus causing it to stumble on an invalid memory access right during returning from the clone() call. This is in turn catched by the NONFAILING() macro and the control actually jumps over it and eventually both the child and the parent continue executing the same code. Prevent it by handling SIGSEGV and SIGBUS differently during the clone process. Co-authored-by: Andrei Vagin --- pkg/csource/csource.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'pkg/csource/csource.go') diff --git a/pkg/csource/csource.go b/pkg/csource/csource.go index 9c820a2e8..55e52347c 100644 --- a/pkg/csource/csource.go +++ b/pkg/csource/csource.go @@ -548,6 +548,8 @@ func (ctx *context) postProcess(result []byte) []byte { } result = bytes.Replace(result, []byte("NORETURN"), nil, -1) result = bytes.Replace(result, []byte("doexit("), []byte("exit("), -1) + // TODO: Figure out what would be the right replacement for doexit_thread(). + result = bytes.Replace(result, []byte("doexit_thread("), []byte("exit("), -1) result = regexp.MustCompile(`PRINTF\(.*?\)`).ReplaceAll(result, nil) result = regexp.MustCompile(`\t*debug\((.*\n)*?.*\);\n`).ReplaceAll(result, nil) result = regexp.MustCompile(`\t*debug_dump_data\((.*\n)*?.*\);\n`).ReplaceAll(result, nil) -- cgit mrf-deployment