From patchwork Sat Oct 30 17:16:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 516518 Delivered-To: patch@linaro.org Received: by 2002:ad5:5208:0:0:0:0:0 with SMTP id p8csp1466008iml; Sat, 30 Oct 2021 11:38:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwE5qg0YJwEsErouYFZDTbDmvkKMr5QNCnaQBYi8XqRFUX7lUwTOM8hOVd4yLlgbRwSoqzx X-Received: by 2002:a4a:c015:: with SMTP id v21mr12998945oop.17.1635619102765; Sat, 30 Oct 2021 11:38:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635619102; cv=none; d=google.com; s=arc-20160816; b=trdVXHHECzKjPiS2DWX5IZj3AzZYd6+QyJItT0xB+gbuGrDJoGkHQfdL5SZOJKp0Wi lr47sUqz6e/CAtCDOH/8uoOE25K+4ih0hzZhXRdfBtUjN1eyey/N/g5peS0KfWrC3fRC bWjDdaBzaTaWGwlX5QckQ+iX3OzdjztGIfiNwakHKhEaV4Rr2jENg1Yjsaq3hiS0I879 8aq5u0O5h31nk5Ddm2Lnvcplgh+xn7zftkGSOJ+YQ4Vnz0O7P2FY8RXhtsfhIZmngV2+ ZOBEn2Wy5XBDEk9XNpjtS4RXGoh/xbOC0HMBDwH6czy8oS0FBxxH3TLNnbzLDGSDASPp H+ag== 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=g7KivaWOxLTQI76TiiTqdyNDyipZ7uNArNJX5U0kY2drqbWDbC5ZTfdnpGVuvqml/W 06htqLNmqE5R4iwudftdzs99y0GjJzo9CSKr52FRLWg/r5I/hlXyw47zujUvtQu4P4Mj Np8sbznPg2huMK9c2jwKFgHxJxF2ze+LEJLNIjZLyP+qg5GRN2yDh5IxV6IkYBN+WYqt 4LmIcmxbSmtb/+qGDzQuxEIREpgvot9OhSpT1kwLVYG7ty3x5A7UedW4ric0BQzlxVoI 5PzJdpMgLLTRGx2IZj8hleA2jJkIP9XODxLL7KwSP17Jm8PWVNqOkA5/8YCYFc2Cg7lI ktpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=mDBOvEjW; 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 f1si326573ool.70.2021.10.30.11.38.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 30 Oct 2021 11:38:22 -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=mDBOvEjW; 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]:59678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mgtFG-0004DO-0I for patch@linaro.org; Sat, 30 Oct 2021 14:38:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58892) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgs21-0001gI-Le for qemu-devel@nongnu.org; Sat, 30 Oct 2021 13:20:37 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]:38680) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mgs1z-0002JM-3F for qemu-devel@nongnu.org; Sat, 30 Oct 2021 13:20:37 -0400 Received: by mail-pf1-x432.google.com with SMTP id l1so5883533pfu.5 for ; Sat, 30 Oct 2021 10:20:34 -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=mDBOvEjWkGkgjoMtShmnNxJDU4RQJedFJFxPCOu0ivToaxhErXKlx0cAQWkRnR8wMw TY6phnyTr7hpmscfJCzpMzruO+e2rN8Lkj7yYf3QnoFX8hME1IjjiJK5NkCts8QVqmN1 U+wL/l3pBgZpIZ1T6BAFnFjpHpojWtd0Euqkrga2GiUpBVb++F5cltsaXw1HQBnbQO6z VbfDKEOgIfOjm0yzVxQxYI40X5/5c5MdTgDd16C64CD32o+fIeqji8KqzH+cn5ZJhYGa EQOImi69+nL+lujFceyJ7SBxWmgMZWAKz5b3i1y+beHwmKo5mg/mRqcccHDLYT2ctBkI xu3A== 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=f/Oe9Q4QyN3WodPvccM9qxk12rlBkKZZxI1OO0bBG0xWSLn/NRX6Ar66NeCz2sFTnR MvF8/gMp+mePfw45gdbO8vgbIUjQk91f/QXO7mgRyiVVVW4jVZKrOCzwrAIeQPbutZhG B5qgvqnn9gB86w4GScrHtlW4LF6gXKJHutwuOMXvksj3acCRim6/uceSsF56eX5Mr44c PhHuz6h+KiK+uoOlLzjvrxLbKH9lJ73LpwZW1FWlJFelEbWh8SoId2Dm5EwrWDV7I+6u Pixy+CjRvwwOso4ErzT6yWqZ6R1tD5C1TRD6Q2AySY/AeqQfM1pz3JYH0RUqG2V+YE3r ycTg== X-Gm-Message-State: AOAM532I8lukv/TVIiu3eYQ5rQIDunCafX5CBf5EGUss0cDuBd2ZveED pQqWzMAU7C5zpdNZlDDn4z38fK9Q3BngpQ== X-Received: by 2002:a63:7c0d:: with SMTP id x13mr13782375pgc.410.1635614433462; Sat, 30 Oct 2021 10:20:33 -0700 (PDT) Received: from localhost.localdomain (174-21-75-75.tukw.qwest.net. [174.21.75.75]) by smtp.gmail.com with ESMTPSA id k14sm9584798pji.45.2021.10.30.10.20.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Oct 2021 10:20:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v6 62/66] linux-user: Disable more prctl subcodes Date: Sat, 30 Oct 2021 10:16:31 -0700 Message-Id: <20211030171635.1689530-63-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211030171635.1689530-1-richard.henderson@linaro.org> References: <20211030171635.1689530-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.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, f4bug@amsat.org 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; } }