From patchwork Fri Oct 15 04:10:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 515842 Delivered-To: patch@linaro.org Received: by 2002:ac0:da11:0:0:0:0:0 with SMTP id d17csp154193imi; Thu, 14 Oct 2021 21:53:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaguyTwxqAcUZOlCX3hMgcIlGgbPpDYji3PyGRIoQW/6HGBAfgR/vnzOnS5XQ8OaqXTJ8X X-Received: by 2002:a25:b7d3:: with SMTP id u19mr10459349ybj.158.1634273628742; Thu, 14 Oct 2021 21:53:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634273628; cv=none; d=google.com; s=arc-20160816; b=oHmCrRRU6RkNTk/7+aTN5PfCoZiFDLJZw+u0F05oHRPbr02X8Ocs38Bpk9unDmRgZT yzkhIOobByo2jyPKqJfedgla8zrlNl30p611jrbMAjAJX+YaYWqgIBgWXYurM3wgA073 t99XkQ2LWJnHVeXX9f+gNNrQtQVpe7jrkpYSMAzRdarCjLmrKEn9KIUrgnR7N1qtqq03 Ck3BT2fQBMP2gGTus378wE6IlGhhl3+xTW392rlNicNiAHzbwfLaM0Lx2xxn7l490k+z yyfuRoiqYTa/C+B4Uw3dS/D3mQhhukeEj/CwEyHS/fEB1vKG6q7pd+PKvwiFguy/qjM2 cTxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=OxMgM7wzD4BcAcUx2qJmodE4BwJ9QwGNSAt09qoFyFU=; b=RH/yHa3o8nuMqsRY7HI/9hz9BXEuGIALRa9tJqKG5qEH7DOZmf8j/CsyXHe3HOrnTe LeYN4aNqUj3glOa3P0tgbgDrsbIms/8E06iiAdiHn7leOs4agAfKJIAeDEu43luFODF+ MiJx9HWHFuvdaM56QGiY13hQOHT7YTJu2h9LfipSWITW99fFeqcGNsCFzt3uy4zTVoYE vj8WmOthPvxH4lf+NwvWXYkh8OYNlOLruU9+39rlX8XuMUgLp8bb0+D5bo1a24pjh34m zIxZlxC3ClCI5sOK21fW4YQ+z+EubRKDdqT64bhWUGREFXo+0VYv+im6Iz/NwzyaEQz4 0Uww== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=n2oEhFHE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 205si6869494ybn.213.2021.10.14.21.53.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Oct 2021 21:53:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=n2oEhFHE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mbFE4-0004h9-1U for patch@linaro.org; Fri, 15 Oct 2021 00:53:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39756) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mbEcJ-00070P-T1 for qemu-devel@nongnu.org; Fri, 15 Oct 2021 00:14:49 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:45904) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mbEcI-00030d-2S for qemu-devel@nongnu.org; Fri, 15 Oct 2021 00:14:47 -0400 Received: by mail-pf1-x42c.google.com with SMTP id f11so3410927pfc.12 for ; Thu, 14 Oct 2021 21:14:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OxMgM7wzD4BcAcUx2qJmodE4BwJ9QwGNSAt09qoFyFU=; b=n2oEhFHE1FfC+NGrQFPyUFWLxN7nZbYmgUcOZZXMymDYfFnaE6FG98C8jxVGAVAb/n r1niXz3J9VA8S2nYLT+fA8trxPYESN4A0Un874SfVpqHg7AIKpnoYjMmLENVKLa1qZCw Cxa8mXZvQQCBdA7K/SDZkZfsdN6KV+4FjzvLQr0+/Ifg09Sr8fLGI5YQQbemE4ZVlj2u 2W9/z4NaU+Bl1gXhrsGh4bu0c+fmR2V91e6y3qceyS9vjKeF5v+RHhupR1rWqu6IQ2rC WvA5FaNT6zY7+pLWlSEXPAYrq/XPLECr8v/EsnXuVx+VGRa9/rR/qylSHAIGTM81MmMN l6aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OxMgM7wzD4BcAcUx2qJmodE4BwJ9QwGNSAt09qoFyFU=; b=C3g0YuyKDQ+6B7EQ+pO/QmIt4LglhoT7DrivFnUyQUMmSf2BnhvvsZ941BqfE9XC6o tUsELF3Cb0lkwMrtkTWzxXuXVfXYvK4178FysZNHYDq3U3tTf6LYyZi6UrQ7rmjpKv3r IjUNOQZTQAD4f6c9CuqnlDUsLblUwCll5cNfdtA3M54j1eK8HLE0gOfwElxMr5P6Ddq1 ESkaI2dPhZ2TXxDz/sGffhprFG4FJUaNVqEQMKk0WTPyNpEdfJJCeh5PBKVEVSWKZiJO KHL1o+3jAcLY+K5vAnSj2UE4yG0jo7WLxeZ+ry9UXd/P1raHux65xXcGNEoSCis5Iyxe FEag== X-Gm-Message-State: AOAM531Udum5GvQZTGhQKqGlcvsT27jfJE6sdare3I3GqYkbTZ9KujhK +l+EnBwoEw7zXEt5geYr7Bwr4v5K6rfAAw== X-Received: by 2002:a05:6a00:8d0:b0:44c:26e6:1c13 with SMTP id s16-20020a056a0008d000b0044c26e61c13mr9506973pfu.28.1634271284454; Thu, 14 Oct 2021 21:14:44 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id q8sm10236885pja.52.2021.10.14.21.14.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Oct 2021 21:14:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 63/67] linux-user: Disable more prctl subcodes Date: Thu, 14 Oct 2021 21:10:49 -0700 Message-Id: <20211015041053.2769193-64-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211015041053.2769193-1-richard.henderson@linaro.org> References: <20211015041053.2769193-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, laurent@vivier.eu, imp@bsdimp.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create a list of subcodes that we want to pass on, a list of subcodes that should not be passed on because they would affect the running qemu itself, and a list that probably could be implemented but require extra work. Do not pass on unknown subcodes. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 56 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 4 deletions(-) -- 2.25.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a417396981..7635c2397a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6334,6 +6334,13 @@ abi_long do_arch_prctl(CPUX86State *env, int code, abi_ulong addr) # define PR_MTE_TAG_SHIFT 3 # define PR_MTE_TAG_MASK (0xffffUL << PR_MTE_TAG_SHIFT) #endif +#ifndef PR_SET_IO_FLUSHER +# define PR_SET_IO_FLUSHER 57 +# define PR_GET_IO_FLUSHER 58 +#endif +#ifndef PR_SET_SYSCALL_USER_DISPATCH +# define PR_SET_SYSCALL_USER_DISPATCH 59 +#endif #include "target_prctl.h" @@ -6430,13 +6437,54 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2, return -TARGET_EINVAL; } return do_prctl_get_tagged_addr_ctrl(env); + + case PR_GET_DUMPABLE: + case PR_SET_DUMPABLE: + case PR_GET_KEEPCAPS: + case PR_SET_KEEPCAPS: + case PR_GET_TIMING: + case PR_SET_TIMING: + case PR_GET_TIMERSLACK: + case PR_SET_TIMERSLACK: + case PR_MCE_KILL: + case PR_MCE_KILL_GET: + case PR_GET_NO_NEW_PRIVS: + case PR_SET_NO_NEW_PRIVS: + case PR_GET_IO_FLUSHER: + case PR_SET_IO_FLUSHER: + /* Some prctl options have no pointer arguments and we can pass on. */ + return get_errno(prctl(option, arg2, arg3, arg4, arg5)); + + case PR_GET_CHILD_SUBREAPER: + case PR_SET_CHILD_SUBREAPER: + case PR_GET_SPECULATION_CTRL: + case PR_SET_SPECULATION_CTRL: + case PR_GET_TID_ADDRESS: + /* TODO */ + return -TARGET_EINVAL; + + case PR_GET_FPEXC: + case PR_SET_FPEXC: + /* Was used for SPE on PowerPC. */ + return -TARGET_EINVAL; + + case PR_GET_ENDIAN: + case PR_SET_ENDIAN: + case PR_GET_FPEMU: + case PR_SET_FPEMU: + case PR_SET_MM: case PR_GET_SECCOMP: case PR_SET_SECCOMP: - /* Disable seccomp to prevent the target disabling syscalls we need. */ - return -TARGET_EINVAL; + case PR_SET_SYSCALL_USER_DISPATCH: + case PR_GET_THP_DISABLE: + case PR_SET_THP_DISABLE: + case PR_GET_TSC: + case PR_SET_TSC: + case PR_GET_UNALIGN: + case PR_SET_UNALIGN: default: - /* Most prctl options have no pointer arguments */ - return get_errno(prctl(option, arg2, arg3, arg4, arg5)); + /* Disable to prevent the target disabling stuff we need. */ + return -TARGET_EINVAL; } }