From c216e9bf058708b58d8134c9fef3e499cf3ef73d Mon Sep 17 00:00:00 2001 From: "Bart J.F. De Smet" Date: Fri, 30 Sep 2022 09:13:42 -0700 Subject: [PATCH] Add support for SYS_clone3. --- src/intercept.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/intercept.c b/src/intercept.c index 9600ad8d..f52faf43 100644 --- a/src/intercept.c +++ b/src/intercept.c @@ -601,6 +601,25 @@ get_syscall_in_context(struct context *context, struct syscall_desc *sys) sys->args[5] = context->r9; } +/* + * is_clone_syscall + * Checks if the specified syscall is SYS_clone or SYS_clone3 on platforms + * that support clone3. + */ +static bool +is_clone_syscall(long syscall_number) +{ + if (syscall_number == SYS_clone) + return true; + +#ifdef SYS_clone3 + if (syscall_number == SYS_clone3) + return true; +#endif + + return false; +} + /* * intercept_routine(...) * This is the function called from the asm wrappers, @@ -675,7 +694,7 @@ intercept_routine(struct context *context) * the clone_child_intercept_routine instead, executing * it on the new child threads stack, then returns to libc. */ - if (desc.nr == SYS_clone && desc.args[1] != 0) + if (is_clone_syscall(desc.nr) && desc.args[1] != 0) return (struct wrapper_ret){ .rax = context->rax, .rdx = 2 }; else