From patchwork Tue Jun 27 16:09:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 696872 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp3866249wrm; Tue, 27 Jun 2023 09:14:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Wxzky3YpQY8428bMUsfnIvkmHyI4U1FAF3uen1wpsb4lLiHxLarndnONJwMaUmzoWgDvD X-Received: by 2002:a05:6214:252f:b0:631:f9ad:1d43 with SMTP id gg15-20020a056214252f00b00631f9ad1d43mr28531572qvb.14.1687882461688; Tue, 27 Jun 2023 09:14:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687882461; cv=none; d=google.com; s=arc-20160816; b=a8+wPvasXYok6Qg9Cc9lJCHmdXOGXyRIseKtP9WMm3TLN4K4qrmrFH69hyi0ycwiVH oHhu3PWTGOgw1tWOs0bQukDxMQnmrVSG7vTyU8qPNm6BUIXsoS/7lqprxEXyNlDmu9JA nj0WNjUDKVoaVy559njOZFHgP8cH9ZAoHj5fQW3rQaMY1kk52mQGwdBgN2XkW1W29dcC FmnMn/sbEObZkmfzYkLV4aiUJYDgJFE1kt7/JYyKx+E3H1Co1DKTusoba5w9beAuodPR iIzqSxTv6K6kK8vZNV9k46/p2HkOx1ir9u/y3GmtfBS3qfKR54hs7Y2taZFqB4e6Yekj WA/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=u8VqszCYj9oqwHFxWVNQZUykN/PvSJ3ab7nReTpSKM8=; fh=B6/adVaiTRj/g/M/QPigvyXZO+x+u/FNsaNX2Qo1+tw=; b=BFcfy8zIuza4r7Y3HJk7z/rca9FGjc8UGKvQYvLJuYJ9v9WWBiHmDxZ6YxuUSZ0nJR 6FbxCi9m8ht1FnHB2bBFRfF69LDUQyfwI/QNZtoMnmG6fWfhf5iYMGbihwQNKuTCaJxT pHPmeI9tLDiFmJxGs82yALWW4O+UGobwOYlFA0l0XT0QM01I0ffwwX75jTGQETTvPUh/ 1zhhsgeyPa8E4bk25bDLUOxOcMQdN49DYCRnfp+vlVRq3NYRIRYmOC+iqqXyjHA4N/20 vWSqboB2PNyVvPX9Krrk6eCQ2eHHXlbkOfK8auOrLaqCIgErl2FM1/pOWqKSLHOrnr6W hO2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XMhm8FgS; 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 13-20020a056214202d00b00630173ee631si3431024qvf.321.2023.06.27.09.14.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Jun 2023 09:14:21 -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=pass header.i=@linaro.org header.s=google header.b=XMhm8FgS; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qEBGa-0000ng-NB; Tue, 27 Jun 2023 12:10:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qEBGV-0000UJ-Nr for qemu-devel@nongnu.org; Tue, 27 Jun 2023 12:10:03 -0400 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qEBGM-0005r6-RW for qemu-devel@nongnu.org; Tue, 27 Jun 2023 12:10:03 -0400 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-4f96d680399so6563407e87.0 for ; Tue, 27 Jun 2023 09:09:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687882192; x=1690474192; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u8VqszCYj9oqwHFxWVNQZUykN/PvSJ3ab7nReTpSKM8=; b=XMhm8FgS8giBNBK5ETfbrA6xJ5oNX8WRTHa90LgBxgSEuqHi2XjhMOfLVrr1l7RHo5 PTXSUv25u2pr8jgcyjPDsZKBgJsJMOP3zu7w6i2Q2wK5JcBbjHkVhDlIembD+DegUXFU hlAgNXXcngS2UPAQ+oSxM1THsn83DyeRPd6uKxS3S5yjiKWwN7EPEeQ8DUQbqI58iQ9m ePz6e2He2NflCCs9KurPBCU+17ADYY/WiVpxC257huHPqNPtnorDpVxRvk+RygqzCein p2TcLFUx/FblveNqwW4dAhe7jaA1LeyUXqA8tNQVMhcVsa9dw+lUtEHbrR3iPtFO6A/0 ol+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687882192; x=1690474192; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u8VqszCYj9oqwHFxWVNQZUykN/PvSJ3ab7nReTpSKM8=; b=mFo4s5ToUTc7G+BGmFu+R0lfpZ7P74DTwFB3l5W62tYMGIcxg1/X4Fn/G5jBWdy7g4 LN9FFK2LFHADClWVFAeuzYmf5UBqDM5/yRb2lj046NMAdHAMAmUR8x6rAOv6htSJp+Hi 6BpU9zdRfcCOPwerIkMZkNCMAf8ZAvxEH1cPFV/3DApfBGpB+FFvl+hOqathXvFIY0SB PsK7fI26l9MXtr8nlgec/PoUzd0U/m2Mv8xeFDdiBY9TCvu5GMcJenGRdnkXj2rV/Oew jd+9UGES09sgDgIvh0WUCUQcvJ7KVc4zbdynFFS7zKRACDLXOZ82zjmIa08ZnkshlHj5 jDWQ== X-Gm-Message-State: AC+VfDwl95tJ3k7tKFY+C65QwuQHKuU7dW2y4KAZLOd0gMoTVIp3aLUF npz63rTQaik3Dwkgdc3bzsB46A== X-Received: by 2002:a05:6512:118d:b0:4f9:596d:c803 with SMTP id g13-20020a056512118d00b004f9596dc803mr17906428lfr.53.1687882192454; Tue, 27 Jun 2023 09:09:52 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 14-20020a05600c020e00b003f8d6647661sm14109513wmi.15.2023.06.27.09.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 09:09:51 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 71F201FFD6; Tue, 27 Jun 2023 17:09:47 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Juan Quintela , Thomas Huth , Cleber Rosa , Leonardo Bras , Beraldo Leal , Peter Maydell , Bin Meng , Yanan Wang , Darren Kenny , Alexander Bulekov , Marcel Apfelbaum , Peter Xu , Radoslaw Biernacki , Laurent Vivier , Paolo Bonzini , Eduardo Habkost , qemu-arm@nongnu.org, Stefan Hajnoczi , Richard Henderson , Bandan Das , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Dani?= =?utf-8?q?el_P=2E_Berrang=C3=A9?= , Alexandre Iooss , Marcin Juszkiewicz , Leif Lindholm , Laurent Vivier , Qiuhao Li , Mahmoud Mandour , Riku Voipio , =?utf-8?q?Alex_Benn=C3=A9e?= , Ilya Leoshkevich Subject: [PATCH v3 30/36] linux-user: Add "safe" parameter to do_guest_openat() Date: Tue, 27 Jun 2023 17:09:37 +0100 Message-Id: <20230627160943.2956928-31-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230627160943.2956928-1-alex.bennee@linaro.org> References: <20230627160943.2956928-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12e; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x12e.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Ilya Leoshkevich gdbstub cannot meaningfully handle QEMU_ERESTARTSYS, and it doesn't need to. Add a parameter to do_guest_openat() that makes it use openat() instead of safe_openat(), so that it becomes usable from gdbstub. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson Message-Id: <20230621203627.1808446-3-iii@linux.ibm.com> Signed-off-by: Alex Bennée --- linux-user/qemu.h | 2 +- linux-user/syscall.c | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index a5830ec239..9b8e0860d7 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -166,7 +166,7 @@ typedef struct TaskState { abi_long do_brk(abi_ulong new_brk); int do_guest_openat(CPUArchState *cpu_env, int dirfd, const char *pathname, - int flags, mode_t mode); + int flags, mode_t mode, bool safe); ssize_t do_guest_readlink(const char *pathname, char *buf, size_t bufsiz); /* user access */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index fa83737192..ecd9f5e23d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8449,7 +8449,7 @@ static int open_hardware(CPUArchState *cpu_env, int fd) #endif int do_guest_openat(CPUArchState *cpu_env, int dirfd, const char *pathname, - int flags, mode_t mode) + int flags, mode_t mode, bool safe) { struct fake_open { const char *filename; @@ -8476,7 +8476,11 @@ int do_guest_openat(CPUArchState *cpu_env, int dirfd, const char *pathname, }; if (is_proc_myself(pathname, "exe")) { - return safe_openat(dirfd, exec_path, flags, mode); + if (safe) { + return safe_openat(dirfd, exec_path, flags, mode); + } else { + return openat(dirfd, exec_path, flags, mode); + } } for (fake_open = fakes; fake_open->filename; fake_open++) { @@ -8518,7 +8522,11 @@ int do_guest_openat(CPUArchState *cpu_env, int dirfd, const char *pathname, return fd; } - return safe_openat(dirfd, path(pathname), flags, mode); + if (safe) { + return safe_openat(dirfd, path(pathname), flags, mode); + } else { + return openat(dirfd, path(pathname), flags, mode); + } } ssize_t do_guest_readlink(const char *pathname, char *buf, size_t bufsiz) @@ -9027,7 +9035,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, return -TARGET_EFAULT; ret = get_errno(do_guest_openat(cpu_env, AT_FDCWD, p, target_to_host_bitmask(arg2, fcntl_flags_tbl), - arg3)); + arg3, true)); fd_trans_unregister(ret); unlock_user(p, arg1, 0); return ret; @@ -9037,7 +9045,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, return -TARGET_EFAULT; ret = get_errno(do_guest_openat(cpu_env, arg1, p, target_to_host_bitmask(arg3, fcntl_flags_tbl), - arg4)); + arg4, true)); fd_trans_unregister(ret); unlock_user(p, arg2, 0); return ret;