From patchwork Fri Nov 4 17:36:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 621385 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp412150pvb; Fri, 4 Nov 2022 10:38:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6pd8CpZEUXRDhTCKJK2A4LFfxOv2PiPk4pvPgh1FLYctYJ6HxU7UfJhqamT7ZI8XEd/OVu X-Received: by 2002:a05:6214:4101:b0:4af:8641:e9cc with SMTP id kc1-20020a056214410100b004af8641e9ccmr33665176qvb.82.1667583486960; Fri, 04 Nov 2022 10:38:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667583486; cv=none; d=google.com; s=arc-20160816; b=DpLwCHNZE6TthV3ww1GvzUgznCEH+g9orUwbpaHf8T6q/XZuEGTlZjb4PKgdFSA4Nz ePnKGQK5i7hwtUWDVeV8AkUe2fnNdbLpUbBE4vhs5Wt6ex5tBh4ulGhzJNoZewM38v8g vgUpKBVg3YgivoSvcx9n4mCJJwAcgLvw5tXVd9pPj0v9RAfX0ASqHEwhl06xGPo4mNym yCqgxXzHgOOrsj/CbgAZI0pMY8gnHkCqrQGwt3PH9xc1oTmhzk79uFeTJKd+X/nv3Jbs c50oiRcgFsUDyXIRh9W51Cz0FDBb35Z8B89kix6zi4Z0q8OBtJsmqmkPCd1L4c8nb6aX dDQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender: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=b05feXPZ3apphQxTxrxWgfNP3iO/wjyZxV5mXVldZE8=; b=AwQDa3l4H/y3IUElJCS5RQ1X3Z2iMDMYjIVRHzKWPFHDLctBX09DZ2y1NcSvMyrUCd 99Efm7nu9d3/HHfW45t3LBmZ7LZoI9yPk9o578XaKuWfA5tUBl24dKifn1kKUTcuG5oJ +aCS+RlfQxGW6GdupAeFoHW+7EhLOGcbPABMn6rO1N1uxJH5v7uY0GSqnvQaHgYb6Ljo k0TbJ4qMunx6J/+/fVbtccBXQbnWNInZpoemznMF6OR80GghQ6vQAPIiuPNliAruHNiL kIqaSOOK/eKPQKBB3zQZSAHS1tlLyI0K4MXShsbZWAKNksYuCj2/87YgHxji6WkjqxyB 61nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mng5nxYe; 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 f23-20020a05622a1a1700b0035ba1cd8a1dsi3545520qtb.596.2022.11.04.10.38.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Nov 2022 10:38:06 -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=Mng5nxYe; 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 1or0cX-00007F-67; Fri, 04 Nov 2022 13:36: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 1or0cV-000051-Ok for qemu-devel@nongnu.org; Fri, 04 Nov 2022 13:36:43 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1or0cT-0003vM-RN for qemu-devel@nongnu.org; Fri, 04 Nov 2022 13:36:43 -0400 Received: by mail-wr1-x429.google.com with SMTP id k8so8078362wrh.1 for ; Fri, 04 Nov 2022 10:36:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=b05feXPZ3apphQxTxrxWgfNP3iO/wjyZxV5mXVldZE8=; b=Mng5nxYeAB5icTGXTnB6EFfjuzxizsJzvhS4JsPKhhkEkBbDcPpnqo+oN1dpLZGkM2 wpQdRl3L/4aDRf6Tk+HYg/qWjVrYCbPVnRMPUKdVBUTZAQeBLW+qdqzbUw5rq2qLsBS5 D9FOrkz5P2KRG4Fh5IHGYvMr8UNQJ6f9UFmonTXD6ghEev6ImXQ4KvtOgPvOlXROAtKW I1GseEMPJKYhEjrTFhJdKEtnKufGbrqEKxj88vlm1m3Nli4DdTgWll9AIEkZeH05m0O7 uHHgzco94dHoXDZcrbEW4C9SBf1yk9sYXPcBWLRTLyBpe1rIjgjAZKVrOD3Q9e2qu2c6 d5rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=b05feXPZ3apphQxTxrxWgfNP3iO/wjyZxV5mXVldZE8=; b=KMnWyI0g+ugr3IinfcZJFKElhXJwtQqnlaktfOcub9L6Co3mK5evh7TZ+/b0nAdjBo zip0aqAy8ivUwXlv8jFVhuoCoshgDnidLp6m5RE/9Wt6oxHGodKC9DSCosobZsmU+QtK dEzEHEOvqw2lyZwpXCSfOVhPnI54eBKkj/wRUSNo3iH9ruj/1sv7K5zHR+DjyK/YJQeJ Xdvyyz1bjb2Dlfa/uh1bGe92f5lBj+zSZLUGVZ0LROBL8v0+G7QbyDBgq3+FM1b/qXEm 3DfCHoxljxVrlP6q4jFopNWQKByLjKHYmTm/d6NxgdJjCdxtt/PVkiXLSUU+r7Rqvahu 86CA== X-Gm-Message-State: ACrzQf2Wot9DL7lNujsqftV3UZwOCRt8MjaTWDEAcggDgHJphRb4rgdN A4RLe/JvTwengcW8qZmdVQF/k5Z6AwYG1A== X-Received: by 2002:a05:6000:684:b0:236:839f:9276 with SMTP id bo4-20020a056000068400b00236839f9276mr22597588wrb.586.1667583400044; Fri, 04 Nov 2022 10:36:40 -0700 (PDT) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id k16-20020a5d6e90000000b002366d1cc198sm3785701wrz.41.2022.11.04.10.36.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 04 Nov 2022 10:36:39 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Helge Deller , Drew DeVault , =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v5 1/5] linux-user/strace: Constify struct flags Date: Fri, 4 Nov 2022 18:36:28 +0100 Message-Id: <20221104173632.1052-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221104173632.1052-1-philmd@linaro.org> References: <20221104173632.1052-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=philmd@linaro.org; helo=mail-wr1-x429.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org print_flags() takes a const pointer. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier --- linux-user/strace.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 9ae5a812cd..25c47f0316 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -945,7 +945,7 @@ print_syscall_ret_ioctl(CPUArchState *cpu_env, const struct syscallname *name, } #endif -UNUSED static struct flags access_flags[] = { +UNUSED static const struct flags access_flags[] = { FLAG_GENERIC(F_OK), FLAG_GENERIC(R_OK), FLAG_GENERIC(W_OK), @@ -953,7 +953,7 @@ UNUSED static struct flags access_flags[] = { FLAG_END, }; -UNUSED static struct flags at_file_flags[] = { +UNUSED static const struct flags at_file_flags[] = { #ifdef AT_EACCESS FLAG_GENERIC(AT_EACCESS), #endif @@ -963,14 +963,14 @@ UNUSED static struct flags at_file_flags[] = { FLAG_END, }; -UNUSED static struct flags unlinkat_flags[] = { +UNUSED static const struct flags unlinkat_flags[] = { #ifdef AT_REMOVEDIR FLAG_GENERIC(AT_REMOVEDIR), #endif FLAG_END, }; -UNUSED static struct flags mode_flags[] = { +UNUSED static const struct flags mode_flags[] = { FLAG_GENERIC(S_IFSOCK), FLAG_GENERIC(S_IFLNK), FLAG_GENERIC(S_IFREG), @@ -981,14 +981,14 @@ UNUSED static struct flags mode_flags[] = { FLAG_END, }; -UNUSED static struct flags open_access_flags[] = { +UNUSED static const struct flags open_access_flags[] = { FLAG_TARGET(O_RDONLY), FLAG_TARGET(O_WRONLY), FLAG_TARGET(O_RDWR), FLAG_END, }; -UNUSED static struct flags open_flags[] = { +UNUSED static const struct flags open_flags[] = { FLAG_TARGET(O_APPEND), FLAG_TARGET(O_CREAT), FLAG_TARGET(O_DIRECTORY), @@ -1019,7 +1019,7 @@ UNUSED static struct flags open_flags[] = { FLAG_END, }; -UNUSED static struct flags mount_flags[] = { +UNUSED static const struct flags mount_flags[] = { #ifdef MS_BIND FLAG_GENERIC(MS_BIND), #endif @@ -1044,7 +1044,7 @@ UNUSED static struct flags mount_flags[] = { FLAG_END, }; -UNUSED static struct flags umount2_flags[] = { +UNUSED static const struct flags umount2_flags[] = { #ifdef MNT_FORCE FLAG_GENERIC(MNT_FORCE), #endif @@ -1057,7 +1057,7 @@ UNUSED static struct flags umount2_flags[] = { FLAG_END, }; -UNUSED static struct flags mmap_prot_flags[] = { +UNUSED static const struct flags mmap_prot_flags[] = { FLAG_GENERIC(PROT_NONE), FLAG_GENERIC(PROT_EXEC), FLAG_GENERIC(PROT_READ), @@ -1068,7 +1068,7 @@ UNUSED static struct flags mmap_prot_flags[] = { FLAG_END, }; -UNUSED static struct flags mmap_flags[] = { +UNUSED static const struct flags mmap_flags[] = { FLAG_TARGET(MAP_SHARED), FLAG_TARGET(MAP_PRIVATE), FLAG_TARGET(MAP_ANONYMOUS), @@ -1092,7 +1092,7 @@ UNUSED static struct flags mmap_flags[] = { FLAG_END, }; -UNUSED static struct flags clone_flags[] = { +UNUSED static const struct flags clone_flags[] = { FLAG_GENERIC(CLONE_VM), FLAG_GENERIC(CLONE_FS), FLAG_GENERIC(CLONE_FILES), @@ -1136,7 +1136,7 @@ UNUSED static struct flags clone_flags[] = { FLAG_END, }; -UNUSED static struct flags msg_flags[] = { +UNUSED static const struct flags msg_flags[] = { /* send */ FLAG_GENERIC(MSG_CONFIRM), FLAG_GENERIC(MSG_DONTROUTE), @@ -1156,7 +1156,7 @@ UNUSED static struct flags msg_flags[] = { FLAG_END, }; -UNUSED static struct flags statx_flags[] = { +UNUSED static const struct flags statx_flags[] = { #ifdef AT_EMPTY_PATH FLAG_GENERIC(AT_EMPTY_PATH), #endif @@ -1178,7 +1178,7 @@ UNUSED static struct flags statx_flags[] = { FLAG_END, }; -UNUSED static struct flags statx_mask[] = { +UNUSED static const struct flags statx_mask[] = { /* This must come first, because it includes everything. */ #ifdef STATX_ALL FLAG_GENERIC(STATX_ALL), @@ -1226,7 +1226,7 @@ UNUSED static struct flags statx_mask[] = { FLAG_END, }; -UNUSED static struct flags falloc_flags[] = { +UNUSED static const struct flags falloc_flags[] = { FLAG_GENERIC(FALLOC_FL_KEEP_SIZE), FLAG_GENERIC(FALLOC_FL_PUNCH_HOLE), #ifdef FALLOC_FL_NO_HIDE_STALE @@ -1246,7 +1246,7 @@ UNUSED static struct flags falloc_flags[] = { #endif }; -UNUSED static struct flags termios_iflags[] = { +UNUSED static const struct flags termios_iflags[] = { FLAG_TARGET(IGNBRK), FLAG_TARGET(BRKINT), FLAG_TARGET(IGNPAR), @@ -1265,7 +1265,7 @@ UNUSED static struct flags termios_iflags[] = { FLAG_END, }; -UNUSED static struct flags termios_oflags[] = { +UNUSED static const struct flags termios_oflags[] = { FLAG_TARGET(OPOST), FLAG_TARGET(OLCUC), FLAG_TARGET(ONLCR), @@ -1349,7 +1349,7 @@ UNUSED static struct enums termios_cflags_CSIZE[] = { ENUM_END, }; -UNUSED static struct flags termios_cflags[] = { +UNUSED static const struct flags termios_cflags[] = { FLAG_TARGET(CSTOPB), FLAG_TARGET(CREAD), FLAG_TARGET(PARENB), @@ -1360,7 +1360,7 @@ UNUSED static struct flags termios_cflags[] = { FLAG_END, }; -UNUSED static struct flags termios_lflags[] = { +UNUSED static const struct flags termios_lflags[] = { FLAG_TARGET(ISIG), FLAG_TARGET(ICANON), FLAG_TARGET(XCASE), @@ -1380,7 +1380,7 @@ UNUSED static struct flags termios_lflags[] = { FLAG_END, }; -UNUSED static struct flags mlockall_flags[] = { +UNUSED static const struct flags mlockall_flags[] = { FLAG_TARGET(MCL_CURRENT), FLAG_TARGET(MCL_FUTURE), #ifdef MCL_ONFAULT From patchwork Fri Nov 4 17:36:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 621381 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp411728pvb; Fri, 4 Nov 2022 10:37:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7cDAxs/wWILIe1eudfPHY7YEVkIdb70ectCPRVVEMkETNqk8D3tcV4QJi6ucNiE7YPQA3j X-Received: by 2002:a05:6214:268a:b0:4bb:68c1:8216 with SMTP id gm10-20020a056214268a00b004bb68c18216mr33777346qvb.70.1667583437829; Fri, 04 Nov 2022 10:37:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667583437; cv=none; d=google.com; s=arc-20160816; b=FLyqj0v5ZopTcCTQScWigqXOwEyNF9gqwVHe8ByEnzVeaTnmF3fu+flnb/SNUPSFMk NhqjL5cPEoTUAsEMb2EHnaM4ufMKFc/rXKE7JgJjWF016CHT4eQr4/A2EuSpI7Hf/Bot q4w7UtE9BKIAkmsFxCen+ayVbj9NzKz8DzJ0ROXEbLMPC7YrdGdy6oOBqhgH1mDK9nI3 HdDzTg2XzYpdkHTWHx6eEHPyCSEzxW9DrowGVOjL5bofloNtmdXi+KYurNgwZimjI3ph LFdXoJHqa9eo/EGNC+GelBhGgHzDXzFK5bPqQ7w5OygyOdwzhQYpH25PPOkz9yA+SG9G AwPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender: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=ySa/ES1xlmucJALkQqyY4MyTUUQjejtiY/uWInOLY+4=; b=qH0wDksMVCRgUUIzE2OmInJGQbEYpc+8MfDEEiTWnGmCPf3ZiXdqjkaCEWannfQIV1 jkAf+FeSx0AecNoj7rGUk90vb1fTCJDgwmJuM1ebxO2c/n/3sZL7BcooWG7t+b0vM7Tv 14dVjrIqxsqs4cvYfs/ts/2kFXNh4U/TYYK7Q2CQCOkcVaNMRICfl/9dA2qp6Uawy7a8 LJucZpL3VvVp121qNurPeTM4dI5u1hoA/+6vLOKw7q3fEl/gsBGduI3FsJO0fP+EE+7Y n9UW1+bUGsjmke5scMlBxEZaCtaXTdhZ/juEXjbM1EdBRPM4daSe7RvvJ2gjz+Ay0OSq l+Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SK6pmIJR; 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 jv11-20020a05621429eb00b004bba4ec0df6si2808417qvb.61.2022.11.04.10.37.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Nov 2022 10:37:17 -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=SK6pmIJR; 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 1or0cc-0000HT-Td; Fri, 04 Nov 2022 13:36:50 -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 1or0cb-0000Eh-AZ for qemu-devel@nongnu.org; Fri, 04 Nov 2022 13:36:49 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1or0cZ-0003vm-Hh for qemu-devel@nongnu.org; Fri, 04 Nov 2022 13:36:48 -0400 Received: by mail-wm1-x331.google.com with SMTP id v124-20020a1cac82000000b003cf7a4ea2caso5858411wme.5 for ; Fri, 04 Nov 2022 10:36:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=ySa/ES1xlmucJALkQqyY4MyTUUQjejtiY/uWInOLY+4=; b=SK6pmIJRsk8psOxrmc2Va0Ka7wocLvkL/vtltbKUjsIiyAaTzQzGaFnryr8O50sVR+ oBMt1mrtkQiEukvXmJyWW4ZvsDReaRF11eTMOJjBhaHW3BZ0jVVjn0YWjk9ReaKlCLKA J6pki4HsFSIWAD6xUO2ULqv8CZic3PCzpPLAryOn4U8eVGuhjjntKP9aiHGJTiRDmSX1 zaPi8gt2nT3eRf8/pku+e0RfNq6DQOnEIuEtdMwz/bqInEk7Oj5Pza3JE6QpH4at25d2 rR7m+fthDAuL26QMeuHFKyhFqb0Cr27pJMADItClys10z/e3lQh1KAlCsD32qpPO2omO v7tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=ySa/ES1xlmucJALkQqyY4MyTUUQjejtiY/uWInOLY+4=; b=FuRrSRrWKF83y2LHQO6BXVh3p0r9m71hc9bAaVy1nksH6RFlS09qvWNqh+C0uhTz1r N1ICBfbV792fENCmCbKMzLi/CoUyFeijxRjAievyCwHoQRReYd8FBJlLO07rwcLPHMO/ MCK6tVBRH+44PclsdlslbhhSBoYxEemg2w+nVyNmVcbliZQO0/dvldndWM//kwe4VimU QnWswv9epGJ6kIbHmGaVqVXpzwD+MpJDUnsZCnKkoeMtpgGnLPydnSDSN42hGs+QSFox VVeHkmY/stdsalTBOTjurzEXxLuQpAgVH4FAotQLrao7e1H+DPD5hVOtnWY12HUjPSZt oq0Q== X-Gm-Message-State: ACrzQf1umsSfOQWP/M8wqQyNbGEFNCDvqmBcDujsbhOm7IvFw8qPLfuq kKxvLCGFaIBARvL6LF3Ufzzb1ibD9eC9Dw== X-Received: by 2002:a1c:c901:0:b0:3cf:6fdb:3367 with SMTP id f1-20020a1cc901000000b003cf6fdb3367mr20427783wmb.119.1667583405907; Fri, 04 Nov 2022 10:36:45 -0700 (PDT) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id m15-20020a056000024f00b002365b759b65sm3747615wrz.86.2022.11.04.10.36.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 04 Nov 2022 10:36:45 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Helge Deller , Drew DeVault , =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v5 2/5] linux-user/strace: Extract print_execve_argv() from print_execve() Date: Fri, 4 Nov 2022 18:36:29 +0100 Message-Id: <20221104173632.1052-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221104173632.1052-1-philmd@linaro.org> References: <20221104173632.1052-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Drew DeVault In order to add print_execveat() which re-use common code from print_execve(), extract print_execve_argv() from it. Signed-off-by: Drew DeVault Message-Id: <20221104081015.706009-1-sir@cmpwn.com> [PMD: Split of bigger patch, filled description, fixed style] Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier --- linux-user/strace.c | 71 +++++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 25c47f0316..3d11d2f759 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -616,38 +616,6 @@ print_semctl(CPUArchState *cpu_env, const struct syscallname *name, } #endif -static void -print_execve(CPUArchState *cpu_env, const struct syscallname *name, - abi_long arg1, abi_long arg2, abi_long arg3, - abi_long arg4, abi_long arg5, abi_long arg6) -{ - abi_ulong arg_ptr_addr; - char *s; - - if (!(s = lock_user_string(arg1))) - return; - qemu_log("%s(\"%s\",{", name->name, s); - unlock_user(s, arg1, 0); - - for (arg_ptr_addr = arg2; ; arg_ptr_addr += sizeof(abi_ulong)) { - abi_ulong *arg_ptr, arg_addr; - - arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1); - if (!arg_ptr) - return; - arg_addr = tswapal(*arg_ptr); - unlock_user(arg_ptr, arg_ptr_addr, 0); - if (!arg_addr) - break; - if ((s = lock_user_string(arg_addr))) { - qemu_log("\"%s\",", s); - unlock_user(s, arg_addr, 0); - } - } - - qemu_log("NULL})"); -} - #ifdef TARGET_NR_ipc static void print_ipc(CPUArchState *cpu_env, const struct syscallname *name, @@ -1969,6 +1937,45 @@ print_execv(CPUArchState *cpu_env, const struct syscallname *name, } #endif +static void +print_execve_argv(abi_long argv, int last) +{ + abi_ulong arg_ptr_addr; + char *s; + + qemu_log("{"); + for (arg_ptr_addr = argv; ; arg_ptr_addr += sizeof(abi_ulong)) { + abi_ulong *arg_ptr, arg_addr; + + arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1); + if (!arg_ptr) { + return; + } + arg_addr = tswapal(*arg_ptr); + unlock_user(arg_ptr, arg_ptr_addr, 0); + if (!arg_addr) { + break; + } + s = lock_user_string(arg_addr); + if (s) { + qemu_log("\"%s\",", s); + unlock_user(s, arg_addr, 0); + } + } + qemu_log("NULL}%s", get_comma(last)); +} + +static void +print_execve(CPUArchState *cpu_env, const struct syscallname *name, + abi_long arg1, abi_long arg2, abi_long arg3, + abi_long arg4, abi_long arg5, abi_long arg6) +{ + print_syscall_prologue(name); + print_string(arg1, 0); + print_execve_argv(arg2, 1); + print_syscall_epilogue(name); +} + #if defined(TARGET_NR_faccessat) || defined(TARGET_NR_faccessat2) static void print_faccessat(CPUArchState *cpu_env, const struct syscallname *name, From patchwork Fri Nov 4 17:36:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 621383 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp411844pvb; Fri, 4 Nov 2022 10:37:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7zUftMbvxzQqCT2b2a8ruFqixgzqOwtzeTwmAzmhTkAQ4S50oi5OvsFMp3MM+UvVOvHbgu X-Received: by 2002:ac8:7f48:0:b0:3a5:4234:8a18 with SMTP id g8-20020ac87f48000000b003a542348a18mr14665119qtk.340.1667583452154; Fri, 04 Nov 2022 10:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667583452; cv=none; d=google.com; s=arc-20160816; b=f2viE4fpuEpemm0kO7/Jf13MC4TXyTNZm3yqQYFDw1fH1BVHuu40+DIQihdJknCXnx uWvb7GpApDue0KdZeFRPinqKh0pUMnhcAltjmZSHQr3dlKiVn68O9kGMEPOGRrfJN7TQ R9lZ+Qyw+J6hr8xUP+pm+4VSsFinQXkYNTdei3FkTrCodbWek4DyiX2Il4yGXQLTfHI8 cobUlJU6b02FPOn5Dw4GSIYbMHT3B8GTsTXoGaBrnJxwHyxZEqZFHVhV3ASvCAcObHFm FHzZ3HKds8oqZ5QXVy/NAx9PQnA8gLJO31VJoIAqqii5j9TiX/1z4I2nQ9KUl9U+XdQy 4DmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender: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=N+83DGVTzGZnIoL+PWZmwCaL/Wjexo+oA9y1TGSpj+Y=; b=ou//3UMZH1UvJj0aVWQgB5zlPbWP20/rXA/h9sBkLvNFHFqk2v+FZd+nEFEqhSe3/J Cbprvh8wHSYUEDnURlnEfyvHZBL1Shp+ntnVPJp5CcZI+jYsIjW3wx99FHKgGxk8tt99 MQstsZZD6MPUBRCeKConQ2YrRXhDlB+lJJPMiuthk+/7z2Oxl5rI7F7IdWTfkJgbvFT/ EqmQ8qoFLnKXzpy1/DqVliw8TA55p52smqmkMK9xHfWOma99ABDbV0Onl6ghL+/I/ME+ uA4Wzm/cbtRKz4N/3VNPA5sPSZ7OiunK31Sh79DjOMoe65xvbCjs7/O5fEequgix1xkP +iUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TiHz2TQN; 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 fq12-20020a056214258c00b004bbae7f331esi3032589qvb.199.2022.11.04.10.37.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Nov 2022 10:37:32 -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=TiHz2TQN; 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 1or0cj-0000Mi-4F; Fri, 04 Nov 2022 13:36:57 -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 1or0ch-0000Ls-AM for qemu-devel@nongnu.org; Fri, 04 Nov 2022 13:36:55 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1or0ce-0003w4-H0 for qemu-devel@nongnu.org; Fri, 04 Nov 2022 13:36:55 -0400 Received: by mail-wr1-x42b.google.com with SMTP id o4so8041108wrq.6 for ; Fri, 04 Nov 2022 10:36:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=N+83DGVTzGZnIoL+PWZmwCaL/Wjexo+oA9y1TGSpj+Y=; b=TiHz2TQNPQvcMplUXUSZZgHPYRtQ39YAmL0Z7xong3kRTMGXtw5v9HxHXrw1CiaiA1 OrBuvlW1YcdKuxkiH6Q2D8+cOWXhzL3IQcdu3mgEmvzmcivEc8R9qNSPce6XtFCR0hKL TXT01QxQrSSvRvHBlKCJ18u8wtUmHsihD2H0ykX1nsVQBhCDsJrfG7jFod3JxcE/KfWf w9V2d3nXmvFUO+cDD8o/vUpjT4PEx+a4ewRFvD0YWYTaymisJ0ISY5iC6wxkDdo6AYEi SzE91R/vhKMWDm3S8pKBRSmMiltmN1GsTJ5bJH+St6u9CwYuSVW17VFy1bkG4km8YlAA f0sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=N+83DGVTzGZnIoL+PWZmwCaL/Wjexo+oA9y1TGSpj+Y=; b=Sz1RPLx/jRJb/BaDN2LqLyd4TjK2lwpHHaeeFCD4QWXzmqHHhLZAAgzj5b60CB2sVk qVmAVS/6+ARalRyMyGlPhgVxpEC2kMf975B4eOksS/Q1LwD0PDFHej+EwWx5NZhIHYjX z/L+TfYxXg8b5xomqEpBw1/Lf/kQtkt8VmSg83kgJXub9QfNjlw0JVkAx4sGMaSTnmJq fhZQbnVy9XUfcurnYAwv1NqGaPwcxzYBKegM6Z8mAbPeYw2qNko17/8lG+FOs9y1jF+a Al2+QVD4YqvVuXh32q98KaCMu5RCdaUbxkC8UtT5rM00FX9tOlfTYPMJSXs300oM9XW/ Sikg== X-Gm-Message-State: ACrzQf3cdAHVUGsaSesFESJ25TA66h2ApoQXDfhbMOR8BdxfpOLQfTcQ 3TkmjoxKTA5p4YaLEE9MmpMHEgv9OC06xQ== X-Received: by 2002:adf:a348:0:b0:236:beb8:9698 with SMTP id d8-20020adfa348000000b00236beb89698mr19540285wrb.507.1667583410788; Fri, 04 Nov 2022 10:36:50 -0700 (PDT) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id q5-20020adff945000000b0022ae0965a8asm3809663wrr.24.2022.11.04.10.36.49 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 04 Nov 2022 10:36:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Helge Deller , Drew DeVault , =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v5 3/5] linux-user/strace: Add output for execveat() syscall Date: Fri, 4 Nov 2022 18:36:30 +0100 Message-Id: <20221104173632.1052-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221104173632.1052-1-philmd@linaro.org> References: <20221104173632.1052-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=philmd@linaro.org; helo=mail-wr1-x42b.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Drew DeVault Signed-off-by: Drew DeVault Message-Id: <20221104081015.706009-1-sir@cmpwn.com> Suggested-by: Helge Deller [PMD: Split of bigger patch] Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier --- linux-user/strace.c | 23 +++++++++++++++++++++++ linux-user/strace.list | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 3d11d2f759..7bccb4f0c0 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1104,6 +1104,16 @@ UNUSED static const struct flags clone_flags[] = { FLAG_END, }; +UNUSED static const struct flags execveat_flags[] = { +#ifdef AT_EMPTY_PATH + FLAG_GENERIC(AT_EMPTY_PATH), +#endif +#ifdef AT_SYMLINK_NOFOLLOW + FLAG_GENERIC(AT_SYMLINK_NOFOLLOW), +#endif + FLAG_END, +}; + UNUSED static const struct flags msg_flags[] = { /* send */ FLAG_GENERIC(MSG_CONFIRM), @@ -1976,6 +1986,19 @@ print_execve(CPUArchState *cpu_env, const struct syscallname *name, print_syscall_epilogue(name); } +static void +print_execveat(CPUArchState *cpu_env, const struct syscallname *name, + abi_long arg1, abi_long arg2, abi_long arg3, + abi_long arg4, abi_long arg5, abi_long arg6) +{ + print_syscall_prologue(name); + print_at_dirfd(arg1, 0); + print_string(arg2, 0); + print_execve_argv(arg3, 0); + print_flags(execveat_flags, arg5, 1); + print_syscall_epilogue(name); +} + #if defined(TARGET_NR_faccessat) || defined(TARGET_NR_faccessat2) static void print_faccessat(CPUArchState *cpu_env, const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index 3a898e2532..bb21c05414 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -164,7 +164,7 @@ { TARGET_NR_execve, "execve" , NULL, print_execve, NULL }, #endif #ifdef TARGET_NR_execveat -{ TARGET_NR_execveat, "execveat" , NULL, NULL, NULL }, +{ TARGET_NR_execveat, "execveat" , NULL, print_execveat, NULL }, #endif #ifdef TARGET_NR_exec_with_loader { TARGET_NR_exec_with_loader, "exec_with_loader" , NULL, NULL, NULL }, From patchwork Fri Nov 4 17:36:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 621382 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp411734pvb; Fri, 4 Nov 2022 10:37:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Al7/58Cnhm7G6vF/7s/+FgNNMnp/q4zHsvBeHDJRe74NgtzNsndZ+ypSt/uYP2daDTKmE X-Received: by 2002:ad4:5bac:0:b0:4bb:db4d:b60f with SMTP id 12-20020ad45bac000000b004bbdb4db60fmr30414046qvq.105.1667583438351; Fri, 04 Nov 2022 10:37:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667583438; cv=none; d=google.com; s=arc-20160816; b=QOZjT0qDB2lQjjPwU/YHeAGVjWHnvPQp8RG0vSfsA8Jk3/v51LC1GavjLmbSvvofZ9 nRmNr7H4g1HqGJGoNjxtJo4QSrh+F1vQIR4nkjmBjRfgWtXUkELZdgDfEA9XBTrRtXKS 4mC+GtbrFTmVbFNqMdIkBWJMFN8B/knWqftULfst2inF7R3AOz5eCaFbchZDglarpBhh X+7pY6P4ORdoTl599sq/i7FNIDSA3KIqhand8JSBz30vrCl2nFFPS8dh5D3s4OGhsWiC Nb/qFiOzmRaw7Bw02NTU60VFH04BwQa6c28Jjdc8ohSPbHsWjC/9ekzftTl8t7X5mJ1F NqCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender: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=MdSw8mOeJR96KDNysclJBr9Hm/Bb8SVdgNCy0HQjHtE=; b=EbjKbLpZBxux7pdiZzMvjtkB1MmCSXGV0MAlxI9QtBHfYmDfyJO9+nSApEoy+FlQBv OW45yAbhCCqYBIGtl3VoWlO6Je60juShmLX37HcVoi0LnYAtWa2RRJV9RGY2V6igU1BK rsUBDXuKMtOk8vcJnbvDc6qxpZc4Chv5/ErU7y4W+C+m/shPPoJIVdB8b7MQAAozdQqw D6dI/pi1BlEtEL1TMOGZvGtimz9EB6BQOAX2rYKHOM2wHFwQUTjxawVYDqGowxNKjM2s 8XDIZtIXaPUTuSiUDRV7RUHmrqZsRJtdZKcr1FVZlYK1BYulzlPrs5XCun+RijxXTPmQ dVAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ApV3fvhO; 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 bp19-20020a05620a459300b006fa99e86c44si1325516qkb.550.2022.11.04.10.37.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Nov 2022 10:37:18 -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=ApV3fvhO; 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 1or0co-0000PI-Nt; Fri, 04 Nov 2022 13:37:02 -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 1or0cl-0000OB-Gd for qemu-devel@nongnu.org; Fri, 04 Nov 2022 13:36:59 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1or0cj-0003wR-PJ for qemu-devel@nongnu.org; Fri, 04 Nov 2022 13:36:59 -0400 Received: by mail-wr1-x42d.google.com with SMTP id y16so7998229wrt.12 for ; Fri, 04 Nov 2022 10:36:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=MdSw8mOeJR96KDNysclJBr9Hm/Bb8SVdgNCy0HQjHtE=; b=ApV3fvhO0z0wJA54VM3cu8/iVvL/y423jAd1iuaR34yju0bFv42k/rpkiN7huklYOw iTr8GRIvAJc4ho9bJ2AZdGKizqAMOQGzaOxDSvuDRKwqI/+rHHo6bQ2HYL7P8gIe4dlA QkHdIejjlx5CvwUHJ3MtL3nC21WmHbuB3f8CaAOBtZII4KVLnUqTxes7sK4HU0Rvx/GH oF9tUExgH0zFosksMHmkK/+1ZDneGH21GtEATfj7xaObpCfR4BO0Dr3sLQyzV0NqjsdH r2KDCH9TK8/JfUaeY3FoparuL3W6fYN9LYg6FsnSr6mfdb1SrGHfmWNW+XjmVocCdLKC HM7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=MdSw8mOeJR96KDNysclJBr9Hm/Bb8SVdgNCy0HQjHtE=; b=fF3ti/2DWrqInHmcLtsnq9L8qzmIiAwC22TWoar05tsaezYBbQ31AZlyIumfkj36b5 S9aWA2cERfCFQyrLDCIrEosN+X2c7SjjzpoReJFRV0QcQA5dyPPFUi55hYj2M4fg/Ax7 uzM4aqWhKXYKD1cS2NAmYAkSuUDa2bvau6htA+N113FvFIlEl+dJh9X5e0/7XvEaO4dV v+SQas2QnjkliJu8XxTUGs+vffKWGDdrdC91tWQhlE0CB+9vGgMhnKefF4POB71S8gns SA5G4AlyGauApC3vykx1URCwar00Dx7HAtvFtrqFcEotDDCqX6yAZBsqJWKkxDyLnv1I bMsQ== X-Gm-Message-State: ACrzQf3Cc3/0qVla08oV2NmdVHbvPUTePCgClbMy5R9x3rFytF59mc8S wIdv0klH3XaD8LzaabUL46sTIHy+16hLcw== X-Received: by 2002:a5d:4e88:0:b0:236:590:f5a9 with SMTP id e8-20020a5d4e88000000b002360590f5a9mr21858218wru.126.1667583415810; Fri, 04 Nov 2022 10:36:55 -0700 (PDT) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id n1-20020a1c7201000000b003c6c5a5a651sm13610wmc.28.2022.11.04.10.36.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 04 Nov 2022 10:36:55 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Helge Deller , Drew DeVault , =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v5 4/5] linux-user/syscall: Extract do_execve() from do_syscall1() Date: Fri, 4 Nov 2022 18:36:31 +0100 Message-Id: <20221104173632.1052-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221104173632.1052-1-philmd@linaro.org> References: <20221104173632.1052-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=philmd@linaro.org; helo=mail-wr1-x42d.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Drew DeVault execve() is a particular case of execveat(). In order to add do_execveat(), first factor do_execve() out. Signed-off-by: Drew DeVault Message-Id: <20221104081015.706009-1-sir@cmpwn.com> [PMD: Split of bigger patch, filled description, fixed style] Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier --- linux-user/syscall.c | 211 +++++++++++++++++++++++-------------------- 1 file changed, 114 insertions(+), 97 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 24b25759be..c3ac6bb4d2 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8357,6 +8357,119 @@ static int do_openat(CPUArchState *cpu_env, int dirfd, const char *pathname, int return safe_openat(dirfd, path(pathname), flags, mode); } +static int do_execve(CPUArchState *cpu_env, + abi_long pathname, abi_long guest_argp, + abi_long guest_envp) +{ + int ret; + char **argp, **envp; + int argc, envc; + abi_ulong gp; + abi_ulong addr; + char **q; + void *p; + + argc = 0; + + for (gp = guest_argp; gp; gp += sizeof(abi_ulong)) { + if (get_user_ual(addr, gp)) { + return -TARGET_EFAULT; + } + if (!addr) { + break; + } + argc++; + } + envc = 0; + for (gp = guest_envp; gp; gp += sizeof(abi_ulong)) { + if (get_user_ual(addr, gp)) { + return -TARGET_EFAULT; + } + if (!addr) { + break; + } + envc++; + } + + argp = g_new0(char *, argc + 1); + envp = g_new0(char *, envc + 1); + + for (gp = guest_argp, q = argp; gp; gp += sizeof(abi_ulong), q++) { + if (get_user_ual(addr, gp)) { + goto execve_efault; + } + if (!addr) { + break; + } + *q = lock_user_string(addr); + if (!*q) { + goto execve_efault; + } + } + *q = NULL; + + for (gp = guest_envp, q = envp; gp; gp += sizeof(abi_ulong), q++) { + if (get_user_ual(addr, gp)) { + goto execve_efault; + } + if (!addr) { + break; + } + *q = lock_user_string(addr); + if (!*q) { + goto execve_efault; + } + } + *q = NULL; + + /* + * Although execve() is not an interruptible syscall it is + * a special case where we must use the safe_syscall wrapper: + * if we allow a signal to happen before we make the host + * syscall then we will 'lose' it, because at the point of + * execve the process leaves QEMU's control. So we use the + * safe syscall wrapper to ensure that we either take the + * signal as a guest signal, or else it does not happen + * before the execve completes and makes it the other + * program's problem. + */ + p = lock_user_string(pathname); + if (!p) { + goto execve_efault; + } + + if (is_proc_myself(p, "exe")) { + ret = get_errno(safe_execve(exec_path, argp, envp)); + } else { + ret = get_errno(safe_execve(p, argp, envp)); + } + + unlock_user(p, pathname, 0); + + goto execve_end; + +execve_efault: + ret = -TARGET_EFAULT; + +execve_end: + for (gp = guest_argp, q = argp; *q; gp += sizeof(abi_ulong), q++) { + if (get_user_ual(addr, gp) || !addr) { + break; + } + unlock_user(*q, addr, 0); + } + for (gp = guest_envp, q = envp; *q; gp += sizeof(abi_ulong), q++) { + if (get_user_ual(addr, gp) || !addr) { + break; + } + unlock_user(*q, addr, 0); + } + + g_free(argp); + g_free(envp); + return ret; +} + #define TIMER_MAGIC 0x0caf0000 #define TIMER_MAGIC_MASK 0xffff0000 @@ -8867,103 +8980,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, return ret; #endif case TARGET_NR_execve: - { - char **argp, **envp; - int argc, envc; - abi_ulong gp; - abi_ulong guest_argp; - abi_ulong guest_envp; - abi_ulong addr; - char **q; - - argc = 0; - guest_argp = arg2; - for (gp = guest_argp; gp; gp += sizeof(abi_ulong)) { - if (get_user_ual(addr, gp)) - return -TARGET_EFAULT; - if (!addr) - break; - argc++; - } - envc = 0; - guest_envp = arg3; - for (gp = guest_envp; gp; gp += sizeof(abi_ulong)) { - if (get_user_ual(addr, gp)) - return -TARGET_EFAULT; - if (!addr) - break; - envc++; - } - - argp = g_new0(char *, argc + 1); - envp = g_new0(char *, envc + 1); - - for (gp = guest_argp, q = argp; gp; - gp += sizeof(abi_ulong), q++) { - if (get_user_ual(addr, gp)) - goto execve_efault; - if (!addr) - break; - if (!(*q = lock_user_string(addr))) - goto execve_efault; - } - *q = NULL; - - for (gp = guest_envp, q = envp; gp; - gp += sizeof(abi_ulong), q++) { - if (get_user_ual(addr, gp)) - goto execve_efault; - if (!addr) - break; - if (!(*q = lock_user_string(addr))) - goto execve_efault; - } - *q = NULL; - - if (!(p = lock_user_string(arg1))) - goto execve_efault; - /* Although execve() is not an interruptible syscall it is - * a special case where we must use the safe_syscall wrapper: - * if we allow a signal to happen before we make the host - * syscall then we will 'lose' it, because at the point of - * execve the process leaves QEMU's control. So we use the - * safe syscall wrapper to ensure that we either take the - * signal as a guest signal, or else it does not happen - * before the execve completes and makes it the other - * program's problem. - */ - if (is_proc_myself(p, "exe")) { - ret = get_errno(safe_execve(exec_path, argp, envp)); - } else { - ret = get_errno(safe_execve(p, argp, envp)); - } - unlock_user(p, arg1, 0); - - goto execve_end; - - execve_efault: - ret = -TARGET_EFAULT; - - execve_end: - for (gp = guest_argp, q = argp; *q; - gp += sizeof(abi_ulong), q++) { - if (get_user_ual(addr, gp) - || !addr) - break; - unlock_user(*q, addr, 0); - } - for (gp = guest_envp, q = envp; *q; - gp += sizeof(abi_ulong), q++) { - if (get_user_ual(addr, gp) - || !addr) - break; - unlock_user(*q, addr, 0); - } - - g_free(argp); - g_free(envp); - } - return ret; + return do_execve(cpu_env, arg1, arg2, arg3); case TARGET_NR_chdir: if (!(p = lock_user_string(arg1))) return -TARGET_EFAULT; From patchwork Fri Nov 4 17:36:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 621384 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp411846pvb; Fri, 4 Nov 2022 10:37:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4fOPUQGCRwgaZ8GjgPO3CRdQIYdsFhL6PVYOMA8VMLgfYCbYsvrw6IdNxzQ6YXpfEx0Au/ X-Received: by 2002:ac8:4e41:0:b0:39c:f205:f954 with SMTP id e1-20020ac84e41000000b0039cf205f954mr29577622qtw.134.1667583452202; Fri, 04 Nov 2022 10:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667583452; cv=none; d=google.com; s=arc-20160816; b=px2Y2gSY8I/OZHuLaid+v7acpjanzzSnXVD3kLb9UnrDfy2M0bSBHUJuMQGU1j3U1A 6pbG0zEuI02kxYuXrwEuTCaKMa0MqmAkpxYsZIonOHqrtDJ7mI42etjRuRgki1gwMahJ d/s/1C0w9+66QjRa60rflzRihYAlfWpvnqOYdaz/LtrqIkH5SGVNwuzFNVcteC4DS/s/ h0Qw0ZU2fYjRtyBv2kQ+RktGenli8ce6U0Hb8AHB8n2VXhXSj4r32oYUDl28+v1WQK2Z BYRzTWrrQYl2hw+kBE6HbpksHWN5Gd5JK126WzVE3DgsKHb3fxxdq3YqR8Bqo+MvlW4A pB9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender: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=qQYxV3PJZu2Jr0ktEDFDlqlPTXyHP+yOYwY1EEXlXv0=; b=hbtkERlX8sp588PUB5L/sBneb69pkM7aiEta7lBJhc6pGBjFt9Fol90nA8YrMbuB+O M9v5XI7jbEiLn0JQ1JogAj51L4M5Lh4qv1HdfVrcP4AOYWxfWO2TV5ILKBsV9hAM9god kJuYhHRhFjdSYahee3gMCb/HA91qlvSoK9AdC6j+8oKfoeJSO9vFtWAR+7L7aT10w0h8 BMVjGEMZ1B7r6gQZiJJI/y1IippYWiIs2KHLRTbD/yjTEWUEuShbFqQRbr/36TkbGqAj wu77KorY21R94y8VGt1Xk2Xf5lytJG/9jXI+BJEblstfxJ1tg2H5y69B7GSgB8pNE6z3 WKfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ec7kzmQR; 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 ga6-20020a05622a590600b003a51d524221si3232832qtb.300.2022.11.04.10.37.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Nov 2022 10:37:32 -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=ec7kzmQR; 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 1or0cz-0000X3-D2; Fri, 04 Nov 2022 13:37:13 -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 1or0cr-0000QJ-Mc for qemu-devel@nongnu.org; Fri, 04 Nov 2022 13:37:10 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1or0cp-0003we-Qq for qemu-devel@nongnu.org; Fri, 04 Nov 2022 13:37:05 -0400 Received: by mail-wr1-x42c.google.com with SMTP id a14so8029148wru.5 for ; Fri, 04 Nov 2022 10:37:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=qQYxV3PJZu2Jr0ktEDFDlqlPTXyHP+yOYwY1EEXlXv0=; b=ec7kzmQR+B8Z/PKE7Z6Hy/nquPiUIrZMgL+G04C2ABvi82mVwtKoU5VArrrlMehDEu tIBxcC8tNRL/k+a5irQE6oGl2XdTqccDeOs8ryGAEEgn8+F4medLoFCcXYp5sbFcgsUf lcx+i1Zx4ZPEwYSKg3+0HOULUV2LB+qRo0YKMYTMfm8o8ks3hCVC8IJdkObF15Kwp3KR 9Ix+VCLbNYy4/HBE4oWnTPkwSqYemQcIZpjzhQpKuNvRQd0iLzZiZR6Szi0DCcs6k/Hp lPmbY0Fk3C0Ix9M6oa7uoY5LdQcb9zajLnIkL3O5p3C2dP5Rhcuh/sT2u6YHJZ6+IA+D fdoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=qQYxV3PJZu2Jr0ktEDFDlqlPTXyHP+yOYwY1EEXlXv0=; b=1DyUy4aYGAG3RmC+qeORbZZOK9Fk7OvAygqt3kABFWfKzLYV2FKPVOFyv6BSG1pKEj 6+mvSFojnZhua8qNqN0enfHAbrCaM5Kit4CDQTHT/am8capstQ0qfT6EeVdBAyl/IUfI 5DL8s2K93zu+CMixyUnu7pBBjtrQj+q6ktegGclNm0aV79MVQD06MMf7WmELi/O/X1+g SRqIiDfwDtghK7ZG8a9tYLDKKwjwUl+TBJmc0GrHoNOnlwXafLkBJUr8JHFG6ulfZ2Zk SrNJvQcs2+d7MknrNx1gZdvbwQyJDGfXUOGimPp3fGuVmI5c5BARNNEq2ibmJSDI68nw R9hw== X-Gm-Message-State: ACrzQf0s3y1BpkAHa3SUJU+ox5mEJDb3Cf6NV4v8Wg2hcrkPsNnEyRBj 9B0Wq2gksMP1UpS5hjf6QdW4x20wfwUz5g== X-Received: by 2002:a05:6000:609:b0:236:8fa3:9028 with SMTP id bn9-20020a056000060900b002368fa39028mr22917848wrb.133.1667583421013; Fri, 04 Nov 2022 10:37:01 -0700 (PDT) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id l22-20020a05600c089600b003c6bbe910fdsm3999636wmp.9.2022.11.04.10.37.00 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 04 Nov 2022 10:37:00 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Helge Deller , Drew DeVault , =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v5 5/5] linux-user/syscall: Implement execveat() Date: Fri, 4 Nov 2022 18:36:32 +0100 Message-Id: <20221104173632.1052-6-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221104173632.1052-1-philmd@linaro.org> References: <20221104173632.1052-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=philmd@linaro.org; helo=mail-wr1-x42c.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Drew DeVault References: https://gitlab.com/qemu-project/qemu/-/issues/1007 Signed-off-by: Drew DeVault Reviewed-by: Laurent Vivier Message-Id: <20221104081015.706009-1-sir@cmpwn.com> Signed-off-by: Philippe Mathieu-Daudé --- linux-user/syscall.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c3ac6bb4d2..c267db9542 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -696,7 +696,8 @@ safe_syscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, \ #endif safe_syscall5(int, waitid, idtype_t, idtype, id_t, id, siginfo_t *, infop, \ int, options, struct rusage *, rusage) -safe_syscall3(int, execve, const char *, filename, char **, argv, char **, envp) +safe_syscall5(int, execveat, int, dirfd, const char *, filename, + char **, argv, char **, envp, int, flags) #if defined(TARGET_NR_select) || defined(TARGET_NR__newselect) || \ defined(TARGET_NR_pselect6) || defined(TARGET_NR_pselect6_time64) safe_syscall6(int, pselect6, int, nfds, fd_set *, readfds, fd_set *, writefds, \ @@ -8357,9 +8358,9 @@ static int do_openat(CPUArchState *cpu_env, int dirfd, const char *pathname, int return safe_openat(dirfd, path(pathname), flags, mode); } -static int do_execve(CPUArchState *cpu_env, +static int do_execveat(CPUArchState *cpu_env, int dirfd, abi_long pathname, abi_long guest_argp, - abi_long guest_envp) + abi_long guest_envp, int flags) { int ret; char **argp, **envp; @@ -8439,9 +8440,9 @@ static int do_execve(CPUArchState *cpu_env, } if (is_proc_myself(p, "exe")) { - ret = get_errno(safe_execve(exec_path, argp, envp)); + ret = get_errno(safe_execveat(dirfd, exec_path, argp, envp, flags)); } else { - ret = get_errno(safe_execve(p, argp, envp)); + ret = get_errno(safe_execveat(dirfd, p, argp, envp, flags)); } unlock_user(p, pathname, 0); @@ -8979,8 +8980,10 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, unlock_user(p, arg2, 0); return ret; #endif + case TARGET_NR_execveat: + return do_execveat(cpu_env, arg1, arg2, arg3, arg4, arg5); case TARGET_NR_execve: - return do_execve(cpu_env, arg1, arg2, arg3); + return do_execveat(cpu_env, AT_FDCWD, arg1, arg2, arg3, 0); case TARGET_NR_chdir: if (!(p = lock_user_string(arg1))) return -TARGET_EFAULT;