From patchwork Fri Jun 30 18:04:17 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: 697968 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp596710wrs; Fri, 30 Jun 2023 11:14:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5zXIdpfCFCOr4OApYg56YEZK4JBcBCziwMdr2VCYpi5zR/8VDjLngh0UkYO7feyEXF588G X-Received: by 2002:ac8:5b42:0:b0:400:8e42:8dd9 with SMTP id n2-20020ac85b42000000b004008e428dd9mr4668982qtw.30.1688148855534; Fri, 30 Jun 2023 11:14:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688148855; cv=none; d=google.com; s=arc-20160816; b=ZlMlSm+oH1p8hn7OAx7CSjY/LE8plYOHgaWG6fWRirqzzwVuh/ZxNn8VnWtYKPEI+T kJIp6BHUhcNyhhSwCwiy8hKYrbAR+M6ndURDjBWBmpQ0dCZEd4p3SOYZQRx+WPUjmMga QXYf44iSvO2wouGX8Gq0C7hunyP9ub89GwFUVzBs3xH8MkpFojO3CmKeyuU3Q1CD91RG kWpxeT47G99++jPutpLDeGe+y4wmzyfoVkkk+7VYSY9pDBW9DbFmvdQ3mb1S1hKpGrOh gPTZc4SVkk5/51YrfPmMPC9oh1f11uaEYSkMVR4l1DtXZmNTS2TgZsSmQSRv1a+gTAda uaYQ== 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=WuTBZDcfojtFbKfkJjfEwZ/JCpHxFhyq5cXQ7fdJG7M=; b=GMu6jXR7KlW79r3QHP4ispe3JltTr94JYZXbRAMW6ZOVNA77maiqaeIyKAD35DA7tP oI/pCdw6dOo3/YBTHXnxwJaie0dihWyiWundxG+OPenr9UF3OVha/xXbfy1Oua2L8zvi 0MHoF539Mvv9ZPU0ORzqLwv0tc4N2Me7ll4//G3NwajArt70TD4qWCEQKGvTMGWIv5ua OT46w/4MCqJatlwL0Dud8v979dEmMN9lvs2hCox9+OvGaYhzSu1t8PwdrnFEOVi2vXYo 7q4GDSeyZkw8AQNaQztXGwKX8HelpjRUQq38q4oiy+JL5iWAHEOnGHlw9EZHAwozdmqq Sr0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vavoppwc; 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 u13-20020a05622a14cd00b003e4e85115casi2478460qtx.679.2023.06.30.11.14.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Jun 2023 11:14:15 -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=Vavoppwc; 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 1qFIcg-0005NX-CY; Fri, 30 Jun 2023 14:13:34 -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 1qFIcf-0005MN-4O for qemu-devel@nongnu.org; Fri, 30 Jun 2023 14:13:33 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qFIcb-0003VP-ME for qemu-devel@nongnu.org; Fri, 30 Jun 2023 14:13:32 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3fbc244d384so16348515e9.0 for ; Fri, 30 Jun 2023 11:13:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688148808; x=1690740808; 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=VavoppwcK7F8QbOXizPkeLrt8cOBceNhpfRKa4jwnasgfzOthsTM2SDmLZ6XG5xQzC oKNnfK2GUqRPSx61xRtddY2mhMXdlj9OfJtEYLMGnt59Q5jB5WCCt9yP+sU3drHv9PJI mUZ3yin+xzi4gS1Ik0Iah8h5TDa98t4WkFWycL1/HADbcPaIg/+u9m3ea1y/TC+aB6fk 8yqppZndxIrbNv9TFwanENbpbfPFauHyK/BBGT39b9MZrR+/0GUW+wg+Gd40Mx2RabVm v1uEHIit4gekd5njgE8Ac0jd2pE3cCETQovUTQZXyFATZi7thXMoTZZ0zNvJeDh8wY06 BQ/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688148808; x=1690740808; 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=NdiiOIEE9ro/kgcJBMCm44Cpfdf1tyzHYi2Gj0FIeBt2J4cnLvcIVzF3+aKWR1PXyK 43ZGlZ4Fix+W1s5nKwsMluiacc1y+7IeJfa+StY9kiIYiPpT1Ts5s+ZF5nut/TJb6S8Y vXg3bG0frQQO5LAokY9PRnKEiWRSJ3KHBUjiaFHCCriaHtOmmpdkKGlRrv86jsdwnobA 3KgNaEc25Ve5vOiFdIph3pZCLP5r2Yk15576qpJ6TI3/IITTtJw6revbkde6/Tt2WKs+ 71OeVPtRHp8k430bInidT2npNd/8FYECiBu8UyN28m/meekyxcg9IPKwzuhlaVAKyZ3t xMTw== X-Gm-Message-State: AC+VfDwKEbG5W1WYyA/CMEZsbf3Nyn9nT/lQeyBOCOVACj4NWPurPl64 apeoFOY2cZt8eX/wa1V7dO+79g== X-Received: by 2002:a05:600c:215:b0:3fa:97ad:2ba5 with SMTP id 21-20020a05600c021500b003fa97ad2ba5mr2626436wmi.31.1688148808167; Fri, 30 Jun 2023 11:13:28 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id q9-20020a1ce909000000b003fbc90e030csm1682204wmc.37.2023.06.30.11.13.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jun 2023 11:13:27 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 9EDD21FFD7; Fri, 30 Jun 2023 19:04:27 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Paolo Bonzini , Stefan Hajnoczi , Leonardo Bras , Laurent Vivier , Peter Xu , Juan Quintela , Beraldo Leal , Radoslaw Biernacki , Qiuhao Li , Peter Maydell , Yanan Wang , Riku Voipio , Wainer dos Santos Moschetta , Mahmoud Mandour , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= , Eduardo Habkost , Thomas Huth , Laurent Vivier , Bin Meng , Marcel Apfelbaum , Bandan Das , Cleber Rosa , Richard Henderson , Leif Lindholm , Marcin Juszkiewicz , qemu-arm@nongnu.org, Darren Kenny , Alexander Bulekov , Ilya Leoshkevich Subject: [PATCH v4 32/38] linux-user: Add "safe" parameter to do_guest_openat() Date: Fri, 30 Jun 2023 19:04:17 +0100 Message-Id: <20230630180423.558337-33-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230630180423.558337-1-alex.bennee@linaro.org> References: <20230630180423.558337-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32f.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;