From patchwork Mon Dec 20 21:41:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526094 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp4475317imb; Mon, 20 Dec 2021 13:43:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzH6j3BkwztZb5E/KPdppRadXLDjjWFAyb06Dz+VRcfkwPr5MMA8qSSVjKakG8HWWti1v2a X-Received: by 2002:a25:42d8:: with SMTP id p207mr203472yba.500.1640036601903; Mon, 20 Dec 2021 13:43:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640036601; cv=none; d=google.com; s=arc-20160816; b=VzDmpltHL9Tp8+oBDcrDOSL3akHGIpWN0mLZ2w75H1FR40hHAGiVmLYqQtM/IaPfgC QvjkOXTxLjCj8xzdYQ2mdNDlVqB9nvU1FDHmoiJ6pXi0CMqIEGfXmszJwaiM3Fku3Vf1 6Tv0hMOarEC8Y4DTZSJsXA+a7WoL6IQ7GM9KlhNzNfAToL7cOjesmfl6DjM+8cRuNNNu IJyYtlkMivHHFyV/6QMCwrJcCblipmtaqVMtqwC0zigRo0UTfZAepvaS1pWuLIDfRvJu s+VvTBQ5v37sskA3/9gNUf1fKm+k+io5pepYcOsqVTa5QFthMZ8cjGHITkNRByUpOtxO F5Jw== 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=gmIBORhArPNArisk4J+dnmMHDstihd5iWVdGFgq2QSE=; b=m9LcMZcDmVOeExf/JcfYTvT8jmLuphlCjcOTX77rCYrF9t7ft97Wu3nUD7EnAlBBKd n+9CUSeZ4FVlTxnUIJ1VivLHPjLpkN2Zicfpz99AazZl1rll0Kz4SjOdXXELhAI/MbHA yv3Wcn+0Prn5KzrvcMX4IDB57K5t5qSzpCTyBBVExf+dVoPSWK7dqdTVE3mKVtT0ZIsy MWVefc59vSG5sHIF6Yk8Z27LMNMVx/yH4pua1y2Pt6kk80TkCXkn7jfnsJlzAvhkhdYw Z4lQILSWagROVBlH73TKBVLA8xQ9I8EFoukkFAGXK53/yOYee/Ocd+66jc8Ddf14aSMb fErw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fx1kRiI3; 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=pass (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 185si11285068ybq.62.2021.12.20.13.43.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Dec 2021 13:43:21 -0800 (PST) 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=pass header.i=@linaro.org header.s=google header.b=fx1kRiI3; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:54430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzQRE-0000JL-UN for patch@linaro.org; Mon, 20 Dec 2021 16:43:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzQPf-0000Bt-HC for qemu-devel@nongnu.org; Mon, 20 Dec 2021 16:41:43 -0500 Received: from [2607:f8b0:4864:20::1035] (port=41877 helo=mail-pj1-x1035.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mzQPd-0002wm-HW for qemu-devel@nongnu.org; Mon, 20 Dec 2021 16:41:43 -0500 Received: by mail-pj1-x1035.google.com with SMTP id b1-20020a17090a990100b001b14bd47532so1237769pjp.0 for ; Mon, 20 Dec 2021 13:41:41 -0800 (PST) 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=gmIBORhArPNArisk4J+dnmMHDstihd5iWVdGFgq2QSE=; b=fx1kRiI3FHvj7B+rsltpnYheGN5zPWYOhR3y++ETniBTOv7/H8WnnWsIQRngJBMzo6 D2FfGyBYkRGwHpPL85Ps2nsNVh2Tq1D2ZT2FNfjZ/aQJQxwu+rn6sn/cw7DUhmY9bTzv g0Ie31aBDoYNLtmv6WatByHNSl5QuO152F+oGk5dLB9rxGBMR8Tm0qgjBnIFUhMcX2zz 7F9HTj3aC24/OWrf/x7zLLWsSFvyCFBXZCBQkygIyq3Ea9wi04l17HZ0gz4ptlw79EIG FGd1A5n31WzJ7zznAxmBoGdNQqXIYmTazspqUlqxJNsAdYg7+2DxRDpqW5pt1Guf+ToK fRSQ== 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=gmIBORhArPNArisk4J+dnmMHDstihd5iWVdGFgq2QSE=; b=xDKSsnE1xDRSfj39ivWP70qCTPVU5kQDPJa3Ns8dp5/8reg7AqMYLzChVZbTYkVDS1 PvurjjFhmQ7ZJNMlo1H6tX64kExE4wD8o1112W2rFF8fNJy7KYfK/TzCerAm2n35Kg9x gS7btyRofr+8ke6hU7j594LROYZwp/EkIZB/UNzFpqQiPsXJ94MwKeT8jQQtcPQynzW9 QFKA+c6/buz7hMok+oWNlggiJsLr/xu0Q6BlkiMP4Qz4Olw4m1w6ULaq+A3hs0IjDVGy PJLYC477BcT1RNb9zENHd5c+JWUdDnZdBdHA8nKbTESZbMA8E0k62te1wRSOypDJPvNr KBmg== X-Gm-Message-State: AOAM532kb95/Kp3qc4G5Yvs7CeMCxM5XsTYSVwCb71XaAgET30TYPftB 8sIpZYw/TMl2WkawYzbAWRnYAr/45h6Y0Q== X-Received: by 2002:a17:90b:20ca:: with SMTP id ju10mr38412pjb.171.1640036500164; Mon, 20 Dec 2021 13:41:40 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id u10sm12508748pfm.58.2021.12.20.13.41.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 13:41:39 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 2/6] linux-user: Disable more prctl subcodes Date: Mon, 20 Dec 2021 13:41:31 -0800 Message-Id: <20211220214135.189157-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211220214135.189157-1-richard.henderson@linaro.org> References: <20211220214135.189157-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1035 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu 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 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier --- linux-user/syscall.c | 56 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b93b8a4f5e..ef7a955dbb 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6336,6 +6336,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" @@ -6432,13 +6439,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; } }