diff mbox series

[v2] linux-user: strace now handles unshare syscall args correctly

Message ID 20210406144203.1020598-1-mkysel@tachyum.com
State New
Headers show
Series [v2] linux-user: strace now handles unshare syscall args correctly | expand

Commit Message

Matus Kysel April 6, 2021, 2:42 p.m. UTC
Syscall unshare did not have custom print function for strace, but it's argument is same as flags in clone syscall, so it can be easily implemented.
Also updated missing flags from clone_flags.

Signed-off-by: Matus Kysel <mkysel@tachyum.com>
---
 linux-user/strace.c    | 18 ++++++++++++++++++
 linux-user/strace.list |  2 +-
 2 files changed, 19 insertions(+), 1 deletion(-)

--
2.25.1

Comments

Laurent Vivier April 6, 2021, 2:46 p.m. UTC | #1
Le 06/04/2021 à 16:42, Matus Kysel a écrit :
> Syscall unshare did not have custom print function for strace, but it's argument is same as flags in clone syscall, so it can be easily implemented.
> Also updated missing flags from clone_flags.
> 
> Signed-off-by: Matus Kysel <mkysel@tachyum.com>
> ---
>  linux-user/strace.c    | 18 ++++++++++++++++++
>  linux-user/strace.list |  2 +-
>  2 files changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/linux-user/strace.c b/linux-user/strace.c
> index e969121b6c..1cadb6d50f 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -1109,6 +1109,12 @@ UNUSED static struct flags clone_flags[] = {
>  #if defined(CLONE_NEWNET)
>      FLAG_GENERIC(CLONE_NEWNET),
>  #endif
> +#if defined(CLONE_NEWCGROUP)
> +    FLAG_GENERIC(CLONE_NEWCGROUP),
> +#endif
> +#if defined(CLONE_NEWTIME)
> +    FLAG_GENERIC(CLONE_NEWTIME),
> +#endif
>  #if defined(CLONE_IO)
>      FLAG_GENERIC(CLONE_IO),
>  #endif
> @@ -3467,6 +3473,18 @@ print_unlinkat(void *cpu_env, const struct syscallname *name,
>  }
>  #endif
> 
> +#ifdef TARGET_NR_unshare
> +static void
> +print_unshare(void *cpu_env, const struct syscallname *name,
> +              abi_long arg0, abi_long arg1, abi_long arg2,
> +              abi_long arg3, abi_long arg4, abi_long arg5)
> +{
> +    print_syscall_prologue(name);
> +    print_flags(clone_flags, arg0, 1);
> +    print_syscall_epilogue(name);
> +}
> +#endif
> +
>  #ifdef TARGET_NR_utime
>  static void
>  print_utime(void *cpu_env, const struct syscallname *name,
> diff --git a/linux-user/strace.list b/linux-user/strace.list
> index 084048ab96..3b7c15578c 100644
> --- a/linux-user/strace.list
> +++ b/linux-user/strace.list
> @@ -1573,7 +1573,7 @@
>  { TARGET_NR_unlinkat, "unlinkat" , NULL, print_unlinkat, NULL },
>  #endif
>  #ifdef TARGET_NR_unshare
> -{ TARGET_NR_unshare, "unshare" , NULL, NULL, NULL },
> +{ TARGET_NR_unshare, "unshare" , NULL, print_unshare, NULL },
>  #endif
>  #ifdef TARGET_NR_userfaultfd
>  { TARGET_NR_userfaultfd, "userfaultfd" , NULL, NULL, NULL },
> --
> 2.25.1
> 
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Laurent Vivier May 15, 2021, 7:35 p.m. UTC | #2
Le 06/04/2021 à 16:42, Matus Kysel a écrit :
> Syscall unshare did not have custom print function for strace, but it's argument is same as flags in clone syscall, so it can be easily implemented.
> Also updated missing flags from clone_flags.
> 
> Signed-off-by: Matus Kysel <mkysel@tachyum.com>
> ---
>  linux-user/strace.c    | 18 ++++++++++++++++++
>  linux-user/strace.list |  2 +-
>  2 files changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/linux-user/strace.c b/linux-user/strace.c
> index e969121b6c..1cadb6d50f 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -1109,6 +1109,12 @@ UNUSED static struct flags clone_flags[] = {
>  #if defined(CLONE_NEWNET)
>      FLAG_GENERIC(CLONE_NEWNET),
>  #endif
> +#if defined(CLONE_NEWCGROUP)
> +    FLAG_GENERIC(CLONE_NEWCGROUP),
> +#endif
> +#if defined(CLONE_NEWTIME)
> +    FLAG_GENERIC(CLONE_NEWTIME),
> +#endif
>  #if defined(CLONE_IO)
>      FLAG_GENERIC(CLONE_IO),
>  #endif
> @@ -3467,6 +3473,18 @@ print_unlinkat(void *cpu_env, const struct syscallname *name,
>  }
>  #endif
> 
> +#ifdef TARGET_NR_unshare
> +static void
> +print_unshare(void *cpu_env, const struct syscallname *name,
> +              abi_long arg0, abi_long arg1, abi_long arg2,
> +              abi_long arg3, abi_long arg4, abi_long arg5)
> +{
> +    print_syscall_prologue(name);
> +    print_flags(clone_flags, arg0, 1);
> +    print_syscall_epilogue(name);
> +}
> +#endif
> +
>  #ifdef TARGET_NR_utime
>  static void
>  print_utime(void *cpu_env, const struct syscallname *name,
> diff --git a/linux-user/strace.list b/linux-user/strace.list
> index 084048ab96..3b7c15578c 100644
> --- a/linux-user/strace.list
> +++ b/linux-user/strace.list
> @@ -1573,7 +1573,7 @@
>  { TARGET_NR_unlinkat, "unlinkat" , NULL, print_unlinkat, NULL },
>  #endif
>  #ifdef TARGET_NR_unshare
> -{ TARGET_NR_unshare, "unshare" , NULL, NULL, NULL },
> +{ TARGET_NR_unshare, "unshare" , NULL, print_unshare, NULL },
>  #endif
>  #ifdef TARGET_NR_userfaultfd
>  { TARGET_NR_userfaultfd, "userfaultfd" , NULL, NULL, NULL },
> --
> 2.25.1
> 
> 

Applied to my linux-user-for-6.1 branch.

Thanks,
Laurent
diff mbox series

Patch

diff --git a/linux-user/strace.c b/linux-user/strace.c
index e969121b6c..1cadb6d50f 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -1109,6 +1109,12 @@  UNUSED static struct flags clone_flags[] = {
 #if defined(CLONE_NEWNET)
     FLAG_GENERIC(CLONE_NEWNET),
 #endif
+#if defined(CLONE_NEWCGROUP)
+    FLAG_GENERIC(CLONE_NEWCGROUP),
+#endif
+#if defined(CLONE_NEWTIME)
+    FLAG_GENERIC(CLONE_NEWTIME),
+#endif
 #if defined(CLONE_IO)
     FLAG_GENERIC(CLONE_IO),
 #endif
@@ -3467,6 +3473,18 @@  print_unlinkat(void *cpu_env, const struct syscallname *name,
 }
 #endif

+#ifdef TARGET_NR_unshare
+static void
+print_unshare(void *cpu_env, const struct syscallname *name,
+              abi_long arg0, abi_long arg1, abi_long arg2,
+              abi_long arg3, abi_long arg4, abi_long arg5)
+{
+    print_syscall_prologue(name);
+    print_flags(clone_flags, arg0, 1);
+    print_syscall_epilogue(name);
+}
+#endif
+
 #ifdef TARGET_NR_utime
 static void
 print_utime(void *cpu_env, const struct syscallname *name,
diff --git a/linux-user/strace.list b/linux-user/strace.list
index 084048ab96..3b7c15578c 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -1573,7 +1573,7 @@ 
 { TARGET_NR_unlinkat, "unlinkat" , NULL, print_unlinkat, NULL },
 #endif
 #ifdef TARGET_NR_unshare
-{ TARGET_NR_unshare, "unshare" , NULL, NULL, NULL },
+{ TARGET_NR_unshare, "unshare" , NULL, print_unshare, NULL },
 #endif
 #ifdef TARGET_NR_userfaultfd
 { TARGET_NR_userfaultfd, "userfaultfd" , NULL, NULL, NULL },