linux-user: return EINVAL from prctl(PR_*_SECCOMP)
authorJames Cowgill <james.cowgill@mips.com>
Mon, 6 Nov 2017 18:03:51 +0000 (18:03 +0000)
committerRiku Voipio <riku.voipio@linaro.org>
Tue, 7 Nov 2017 19:58:13 +0000 (21:58 +0200)
If an application tries to install a seccomp filter using
prctl(PR_SET_SECCOMP), the filter is likely for the target instead of the host
architecture. This will probably cause qemu to be immediately killed when it
executes another syscall.

Prevent this from happening by returning EINVAL from both seccomp prctl
calls. This is the error returned by the kernel when seccomp support is
disabled.

Fixes: https://bugs.launchpad.net/qemu/+bug/1726394
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: James Cowgill <james.cowgill@mips.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user/syscall.c

index 84e123b67b77d5f0675ae15e91cd67e7966b73d4..f31b853bb7fbb20cd987c64bff97c1021ea8ff9b 100644 (file)
@@ -10505,6 +10505,12 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             break;
         }
 #endif
+        case PR_GET_SECCOMP:
+        case PR_SET_SECCOMP:
+            /* Disable seccomp to prevent the target disabling syscalls we
+             * need. */
+            ret = -TARGET_EINVAL;
+            break;
         default:
             /* Most prctl options have no pointer arguments */
             ret = get_errno(prctl(arg1, arg2, arg3, arg4, arg5));