From patchwork Mon Jul 3 13:44:21 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: 698704 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp1762703wrs; Mon, 3 Jul 2023 06:54:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlE1wwDZUwX3MWbpEoyCkNmAQ1DVMrYm7OdRebLjtUk1xxjNgI0sQLXyZ0F2F7kIS+o31OcI X-Received: by 2002:a05:6359:6797:b0:134:e4fe:e162 with SMTP id sq23-20020a056359679700b00134e4fee162mr5506371rwb.13.1688392477711; Mon, 03 Jul 2023 06:54:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688392477; cv=none; d=google.com; s=arc-20160816; b=I9PzWMnmdl5vmHB6KmBHnbkFgAkjQn2hK8baJSrZDJAq5seqfJt2eFdVcfvpGNu6Z+ l/YbY75oggLxmNLMWaRtQjV9aKpsGiGUJPQU9u4mpQzxTHF9dJbceflS5i+klhvCmaKW HZXTG1vLxP9E88SA0iaKD9nuqYBpgAp8hyTeUMdTVziy4GoTy/Pev9teTJ4jBiMtA0CO Nb13IPiPx2sukCZJwp3xlXC1efC1SQfhxN5Fs9LmiwO3rAzeEsd66X/m6fSlImKp5Pf+ 0GuoiVFPlXonSBARIHP1hyGNblBwA8iXm4Wn6Da3nT1DDRj1FCW1XRs9WdnB3ZA18VQN RNUg== 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=7Mnp8y2sy0S7tTiA16Y+6uh+LPx0EUvTSKKrt0wZYOY=; fh=D2Rp/LVqP92oybp44Lc4WqHSiNHRumdEjZlh6dY9LNQ=; b=N9QPQz1yAla8DawNNLfZNvNkH4gjKsTwzlbVCEnQM0Qfl3tO/cLEpHFV++3WG0bdGX ZLB0G7ww9qenTEqwJDldSv24CPbmngwzxCs9pgybIDlA2vgN8F0c4vwNVK8W0HgWqLEM A2ZxM0wwRQP2Jttco6NEF9owvKdnpqS9JVRrf6kqkRsEFlairEBTENa9SCpcwm2rZByh YQ3p6ZbX67+0zvkpsTzFVwDwM9z4tmEJBwhvYiI8wGOmWTh8mhSxQZe8hnOFjzlwlAS9 WE9//DEhke5dc32s7te77008eNsRDcWem1G1vXu+q3GveQKGpQUQvdxmXHBRpLj2priv DWgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qL7nZT0a; 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 p19-20020a05622a049300b003ff242dc090si10445931qtx.18.2023.07.03.06.54.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Jul 2023 06:54:37 -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=qL7nZT0a; 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 1qGJzr-0000ec-Js; Mon, 03 Jul 2023 09:53:45 -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 1qGJzj-0000Ya-Sd for qemu-devel@nongnu.org; Mon, 03 Jul 2023 09:53:35 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGJzi-00083g-4E for qemu-devel@nongnu.org; Mon, 03 Jul 2023 09:53:35 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3fbc6ab5ff5so40371005e9.1 for ; Mon, 03 Jul 2023 06:53:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688392413; x=1690984413; 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=7Mnp8y2sy0S7tTiA16Y+6uh+LPx0EUvTSKKrt0wZYOY=; b=qL7nZT0aCCIujUGSsKbP9AuPbtlnvKLalFwg5qxpruA24pzhu8Xw84nglQtw4F/X7N Ayx7inBY8OFjh3auk3hN3MilXUYj038wIMO4C6glg77wnw8aVL9Kbbft67f0SB9MFZ0T qUfl0yQMEOXlgW+edc+JF7YCRf96CiyBj0+f42NrTK/4EPIGvCvJ7rXfwnOmCD6lzX0C BPVbCeFhBNyHsMc3eKWB1cqC9fnrgi+DQzgUSc2++M1OacHGMRNCQLiPjXcQ4AYY0QHy 0ONOtrI2pqup453j3WgtrKJR+NI6ekmFgIMGno0eSxTW9rK/LEE8Ywah3TWx1cTvs1r9 E9Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688392413; x=1690984413; 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=7Mnp8y2sy0S7tTiA16Y+6uh+LPx0EUvTSKKrt0wZYOY=; b=a9s7ZrDHwbe9heKaUhuz8nhug1CEqOJDL3ONHimRwkw7i2jXZGi5j7b1K2hYmzu/49 2lDBv78m5N58GMnvXOl+wA/VXElKE2TQrXo15EGNvLxwOB0iv9udG/aw3KO66BQP1QCO YQzuLgGJ3qmLbXrdthZY/lC5MMKU8YHiNH8G5BR9VewBOVfNHk9tRzWSwO5qubCJ/xzT WNoT6YazfMmeRNJ0cH8d09kv4TcXBcuWIRycfu/6t/XmzPVNBakOMLl79ZVBye8WrCmx jPdwFPGDKC1hTFqUdimm69WCov/U9VDjrNu566+en++x+r9AiIMOgs7bc55bvZBrPYSb g6YA== X-Gm-Message-State: ABy/qLZKiMe1V3f7bHb/fW5WZHp6piV0Yf0TGJ5hv7LlSmeTGPyA8tD9 nL7GtaA5XnBLfzS6FaLuG4hhJA== X-Received: by 2002:a5d:494c:0:b0:314:3724:6fcb with SMTP id r12-20020a5d494c000000b0031437246fcbmr2801262wrs.50.1688392412875; Mon, 03 Jul 2023 06:53:32 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id w11-20020a5d680b000000b00313f031876esm21505406wru.43.2023.07.03.06.53.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 06:53:32 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7DAD81FFC2; Mon, 3 Jul 2023 14:44:31 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, Ilya Leoshkevich , =?utf-8?q?Alex_Benn=C3=A9e?= , Laurent Vivier Subject: [PULL 32/38] linux-user: Add "safe" parameter to do_guest_openat() Date: Mon, 3 Jul 2023 14:44:21 +0100 Message-Id: <20230703134427.1389440-33-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230703134427.1389440-1-alex.bennee@linaro.org> References: <20230703134427.1389440-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x330.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=ham 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 Message-Id: <20230630180423.558337-33-alex.bennee@linaro.org> 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;