From patchwork Sat Oct 5 23:33:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 833023 Delivered-To: patch@linaro.org Received: by 2002:adf:8b52:0:b0:367:895a:4699 with SMTP id v18csp1380223wra; Sat, 5 Oct 2024 16:35:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU1FXHetj1Hjngho/rbYgjQaRiI2U01vkhi2vbIqXqpLnNpKBKcx99vNbKzlKRxAR7HfYujvA==@linaro.org X-Google-Smtp-Source: AGHT+IFkSRIYD3ssVijspF1hPjlWAt4DZj8qVl13OPQBR+1JE7lfnMAgykyftKon4La5T0AJG5l6 X-Received: by 2002:ac8:57cd:0:b0:458:3735:da3c with SMTP id d75a77b69052e-45d9bb27cfemr110941191cf.50.1728171348677; Sat, 05 Oct 2024 16:35:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728171348; cv=none; d=google.com; s=arc-20240605; b=ax/EBl2hDfuKPhIukGX5hAFNn0FvE3i8Y6Y2fYCBfmsSCgTjw5KGi6SW/ndGt8Zz/4 E2C5QZOJml0AeySVpsqd/TMPOImgps9+RYKSYdkxVTeGVxmutqG9/3SNlkElcGeTkzY7 VYdQsMlxJKG0EI76fWaW+XBT8Xm/S+eGcwD3GtSAfidQeAY/f8SrFNU/6YwyBbkH82nV Wb2/26weNpxwDWaCn9ySIi6VOLkC73Nmhp/qaxNKOwwvtbt+QUD41wzWRgLXLE/OGLup c77HHAr1f69ZVK1x6JYQ376M7riC2wB3d9/wzgxVKWg7lkBhTTYnb9xPMGBBX1pxYxlI 3SIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=K+Rj8O/QK6Pa3filkPJ4FZfJms9lNPKqXWSFkDZyfyA=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=gJ92SR7qmI5PlzuHfwOP3gBggfJXKkigAPsnf+xX5xUtFndsbe/wyz6OEKZurbNVhS xacYf2tqzRaCnpEPQi3JU4UvwRsCFjQ9TpSn8E3KGrDekri0s/hpYWqX7SNJ849+2A8T 97oY/PP8Mysvsa4NRcji+lF/WCYvQeXp4X2maTBrdLmudRgQ9eFkW7JpexUbOyOG8UMV QpZQPpLAYCDkx9t1jK1jtE+C4hJTvOknJliMV3CsTdsplsYJOg5M6fh8bEdUjvbaec60 xmS1rTSqv+XwUMcTGDWbczpCUb5qUdJL+8/GyPz4+vW+A5JBcqdrsEUPFBwV89QI2gHf ELRg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qNVyiSfa; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-45da74ac816si30297821cf.32.2024.10.05.16.35.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 Oct 2024 16:35:48 -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=qNVyiSfa; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sxEHW-00069N-8F; Sat, 05 Oct 2024 19:33: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 1sxEHU-00068h-8M for qemu-devel@nongnu.org; Sat, 05 Oct 2024 19:33:48 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sxEHS-0004Cj-Nq for qemu-devel@nongnu.org; Sat, 05 Oct 2024 19:33:48 -0400 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-2e0afd945d4so2449978a91.0 for ; Sat, 05 Oct 2024 16:33:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728171225; x=1728776025; darn=nongnu.org; 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=K+Rj8O/QK6Pa3filkPJ4FZfJms9lNPKqXWSFkDZyfyA=; b=qNVyiSfaRi3Y/cYV+SDPZHCAlHBCde4o0ZLjBhvCEIB0OhHrxbVuli7ks+v1F5up/Q y/WQSlmElVvnZ4v3dRXpS7e90A0LBfzHz6EkUljbmodOLVHl1ISEaP7yCR23663wfzpN fJ9uoTwyj/OWne84tFZkMyxGV49ID5zqdst4fPzMaDIrqswAhdxLXosv1cLYgj9ygpUT W/I4aBl5C3n4tzB64d1eMbXhOW7UU5DtdrGql4sTA+M/1dB7pTsaQIlIIsgZaTLBNPI8 uvxX2qEAmTxsBCnUstqkhEyYraZ6WlNOPXS8FfPffdSMlJwRGwDCloKXSrJPbKqTfi3N KWTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728171225; x=1728776025; 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=K+Rj8O/QK6Pa3filkPJ4FZfJms9lNPKqXWSFkDZyfyA=; b=R5jNRAviuyh4zl/fOzKT6Rlfjpqk9eVAFj/XZihplPc9zMlPneQFsXAtseSNFMKvfk 2HTFU6MFfdPdtoQO0aUl1JPz1E03gDkDunLNOANS/smWjOmlB5nTxM6IcXOT752FN11T bm0UmeveQUw8k1mTm/gM08x7Xu6sePThadrucn34yjO9nA+HLuGditQqkzehylE0IaLu Dy78vOSkUP7wrTMhrP7pCkd92fmT3jJwNmG3NGE+pAc3ISP9MOsuntB8kPr5UrRufuFa IuWCX4xl4Qe0eKRSPG1uX+2m8M8hQ8A/9wOMTQ5SBL9ggpLclXAjkTqF5P2qp39Hl0Wg /zSg== X-Gm-Message-State: AOJu0YxQd01g154fYgFW0r1Gwwo3gdXo4YuFCY7SPP+E1pCo/cvELZib 4na2bXlAloicXTphXKOSwPtF8sardmMnJ9mCZTxTmDfJvxpKQwSVWJQaBtwCGU2feMh2zatsv2Y V X-Received: by 2002:a17:90a:7c01:b0:2d8:cd04:c8f0 with SMTP id 98e67ed59e1d1-2e1e63bf1b6mr9119509a91.39.1728171225317; Sat, 05 Oct 2024 16:33:45 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20b129cc2sm2394600a91.51.2024.10.05.16.33.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 16:33:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 01/10] linux-user/flatload: Take mmap_lock in load_flt_binary() Date: Sat, 5 Oct 2024 16:33:34 -0700 Message-ID: <20241005233343.503426-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005233343.503426-1-richard.henderson@linaro.org> References: <20241005233343.503426-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé load_flt_binary() calls load_flat_file() -> page_set_flags(). page_set_flags() must be called with the mmap_lock held, otherwise it aborts: $ qemu-arm -L stm32/lib/ stm32/bin/busybox qemu-arm: ../accel/tcg/user-exec.c:505: page_set_flags: Assertion `have_mmap_lock()' failed. Aborted (core dumped) Fix by taking the lock in load_flt_binary(). Fixes: fbd3c4cff6 ("linux-user/arm: Mark the commpage executable") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2525 Suggested-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-ID: <20240822095045.72643-3-philmd@linaro.org> Signed-off-by: Richard Henderson --- linux-user/flatload.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/linux-user/flatload.c b/linux-user/flatload.c index 04d8138d12..0e4be5bf44 100644 --- a/linux-user/flatload.c +++ b/linux-user/flatload.c @@ -487,7 +487,10 @@ int load_flt_binary(struct linux_binprm *bprm, struct image_info *info) stack_len += (bprm->envc + 1) * 4; /* the envp array */ + mmap_lock(); res = load_flat_file(bprm, libinfo, 0, &stack_len); + mmap_unlock(); + if (is_error(res)) { return res; } From patchwork Sat Oct 5 23:33:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 833024 Delivered-To: patch@linaro.org Received: by 2002:adf:8b52:0:b0:367:895a:4699 with SMTP id v18csp1380256wra; Sat, 5 Oct 2024 16:36:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWpM6w1QbpeRoiVa0A9w74AWpn/VPuS5skzAA3XnrbvEGAjLwqqCoIdHDQ/Bq415NXDpRQ06A==@linaro.org X-Google-Smtp-Source: AGHT+IFZAfqGdR21xYpeX9PZOTuNLWMaNSxQ5h4HOfT9rO7oInk4M+wneqEbmWLmUwPJwTBwBkzL X-Received: by 2002:a05:620a:4713:b0:7a9:b814:4aa4 with SMTP id af79cd13be357-7ae6f48ba14mr1248326185a.43.1728171360256; Sat, 05 Oct 2024 16:36:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728171360; cv=none; d=google.com; s=arc-20240605; b=gQcevlzhleaOmiuiubc4xJoJ0rEVwUjD6CX6BHwx+fPrZ6oTZMvsNHOVLhrq88LinG 8LQSt3O7uCT9lfwKas2j9tHfLIkaHuDYQmUuLfSsM4flgfwd4EfnsK0lkjodYoi7dSqP bmXWlfPmUP13u/1/EbS2CgtisjMV7X9d6eONWGQ0LoyW8UpvUA64wzEqKdq46qoszQeP ihdbm6Kna825PTpR7446KvdeimkUfKSUnhLfQp8OWFxfaiXrIweVWHQvwMiN5SIFXmOw cU0JoLYDFpALLghB2ZpA1Z8i+nLvRkoa7amrV1aAFvxtJxV08lGlTjye0ySRP6evFO8j NLIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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:to:from :dkim-signature; bh=iSrAwBk5bZNjn8Zy9dmgJJyBe5UY35yHEd3GQKBCY9s=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=W1PafzIKMCwXmWHpPFntO9MgmTlqhyhnIPLB3U85Q3tUsC0rHDZ01IdOwjuK+pQaCO n9dc1Xrc+aqkUh3aQ1gSUdgcPUlpLuy95GgJ5Cx2e9mIcpA30lDDOWVXTs3R/ABjREon 1KQSy/ezlcE33Nki1ZJbY1x+kJBzOcCRsMc0qfF1RR0+LOscMFDdILiCziM1ac/hy6YB efxNIT3djNFOncohMk2QMxd10zWtpFjPbS65ZOZurMOjAc1GTFul7vz8Nidf3kfgAV6o DqXbbgNHyFiBGmdQZSqihEQs+BrRIwMy1h5PwebBJglInzsk8YLqboVOONSp8u8VcEfo jUpw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vX1IofKs; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7ae75661807si277978785a.268.2024.10.05.16.36.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 Oct 2024 16:36:00 -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=vX1IofKs; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sxEHW-00069Z-QR; Sat, 05 Oct 2024 19:33: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 1sxEHV-000696-7i for qemu-devel@nongnu.org; Sat, 05 Oct 2024 19:33:49 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sxEHT-0004Cn-Gs for qemu-devel@nongnu.org; Sat, 05 Oct 2024 19:33:49 -0400 Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-2e221a7e7baso306037a91.0 for ; Sat, 05 Oct 2024 16:33:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728171226; x=1728776026; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=iSrAwBk5bZNjn8Zy9dmgJJyBe5UY35yHEd3GQKBCY9s=; b=vX1IofKsRV/7IAjSeG7ywlmW0XpG/kDofsnXgLzMWL7o9ecSupAYSvZAFu1/Qkr5pL qUJLkP7Owy3iU8qurguln5Y7hZwrZtRc/pRZDEq3K2DzUekMppCM4PRzLyFlvdfY7xph kdeZ8ntM0pYi4dUkmB1tQUsx2w6+RLOaxUrn2A4WIJhAh7eXcQgkmwjo9x1YeN4fVZlR ep22mMIxZNog9bH61dFruruqj4J/Q4DTNHNOVQivqp/g8GW4fmbVu85EIvImmCw1RUYj ObRYh7bkhvov8uj2xqwTTk2RJsPcHdqSSJdy7aw0Sjrk0VDkNicO4yCmB/mEYlzIkmSN OSFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728171226; x=1728776026; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iSrAwBk5bZNjn8Zy9dmgJJyBe5UY35yHEd3GQKBCY9s=; b=HEPPjnvTIAHqI8MvMpjxCKaEYs8OmFWl+zTLBM0V5EjlYPRuB2HIGJ96fB9CAxm+c+ BKkyK+x+duVWQXzcIlK7QVSx8YOy+MWMJdWqGy5+1/Ob4FgZz4eMxEBDHRy1NeAJvrhl +/6rblQOt6gwI80/kTSS27KiIpIB+rIIYs5RYeVQRtZzySV+8HycLStcJI+o3RpfyXNB sTD5/FGVEmTq4Ch9Lfca837LWNAP+KRYvCy8eYUd/+9jzF+EkoFs1uY+HzaupK0Nyx9K HMYXweprGnobdAAFxW1sw2mCW/unEHuJIhukSyKDMuPoYngxKeSQTQuelEedyINlRaty /HVw== X-Gm-Message-State: AOJu0YyaaHwAaefiLzztkzrW/P1C2CrDjwW05oHuPEmZnTiL/L6Y3mFy yOxsE8NPnxYxfy8SpXTFoqJ2nLS4r75kGPHBHpx6N6/5hmLdwAPZ7XXdiJaaay01YmW/UMquuit g X-Received: by 2002:a17:90b:206:b0:2e0:8e36:11f with SMTP id 98e67ed59e1d1-2e1e6211ba2mr8684086a91.4.1728171226049; Sat, 05 Oct 2024 16:33:46 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20b129cc2sm2394600a91.51.2024.10.05.16.33.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 16:33:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 02/10] linux-user: Fix parse_elf_properties GNU0_MAGIC check Date: Sat, 5 Oct 2024 16:33:35 -0700 Message-ID: <20241005233343.503426-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005233343.503426-1-richard.henderson@linaro.org> References: <20241005233343.503426-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Comparing a string of 4 bytes only works in little-endian. Adjust bulk bswap to only apply to the note payload. Perform swapping of the note header manually; the magic is defined so that it does not need a runtime swap. Fixes: 83f990eb5adb ("linux-user/elfload: Parse NT_GNU_PROPERTY_TYPE_0 notes") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2596 Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- linux-user/elfload.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 0678c9d506..52c88a68a9 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3121,11 +3121,11 @@ static bool parse_elf_properties(const ImageSource *src, } /* - * The contents of a valid PT_GNU_PROPERTY is a sequence - * of uint32_t -- swap them all now. + * The contents of a valid PT_GNU_PROPERTY is a sequence of uint32_t. + * Swap most of them now, beyond the header and namesz. */ #ifdef BSWAP_NEEDED - for (int i = 0; i < n / 4; i++) { + for (int i = 4; i < n / 4; i++) { bswap32s(note.data + i); } #endif @@ -3135,15 +3135,15 @@ static bool parse_elf_properties(const ImageSource *src, * immediately follows nhdr and is thus at the 4th word. Further, all * of the inputs to the kernel's round_up are multiples of 4. */ - if (note.nhdr.n_type != NT_GNU_PROPERTY_TYPE_0 || - note.nhdr.n_namesz != NOTE_NAME_SZ || + if (tswap32(note.nhdr.n_type) != NT_GNU_PROPERTY_TYPE_0 || + tswap32(note.nhdr.n_namesz) != NOTE_NAME_SZ || note.data[3] != GNU0_MAGIC) { error_setg(errp, "Invalid note in PT_GNU_PROPERTY"); return false; } off = sizeof(note.nhdr) + NOTE_NAME_SZ; - datasz = note.nhdr.n_descsz + off; + datasz = tswap32(note.nhdr.n_descsz) + off; if (datasz > n) { error_setg(errp, "Invalid note size in PT_GNU_PROPERTY"); return false; From patchwork Sat Oct 5 23:33:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 833019 Delivered-To: patch@linaro.org Received: by 2002:adf:8b52:0:b0:367:895a:4699 with SMTP id v18csp1380022wra; Sat, 5 Oct 2024 16:34:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW5ld8cEM1pkf3c79rfaexf/LlCvjZG/mPrTVuRYIpc1Ess+nsksmFwBM7c/HP9gvV0kO9lEg==@linaro.org X-Google-Smtp-Source: AGHT+IH4Lu5VocuTf22ZIMmc4EuZMr0PTHLTS1wCQoZ9nuFWr7A6hzX3XESndDQ+/W4jrSXjq3t7 X-Received: by 2002:a05:622a:38d:b0:458:31de:391 with SMTP id d75a77b69052e-45d9babe9a7mr119331281cf.29.1728171277570; Sat, 05 Oct 2024 16:34:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728171277; cv=none; d=google.com; s=arc-20240605; b=POvV/4HqUHEaTvXyQgG4i3QNqm5JaTfyJ0lsAC+qbuUjfqMyqUyPy0bnAc2wHKdJwW W+80UXVN5E7nE0/sKm68yJ5BEYnr9OB8N0Er3zSAmzrGwy2N3w4L1scMdCzyAHl5fK2Z cNbaUMlKNAshMDAtGYt6xpDwBstUsCpLJ0cI2GxX/HBt/m5JvxBkJTGaQk5+o4SGt6ZX 0MiZWGBTlVE+zpJaXk83gjvu3Zol8r+Lh3NJU6wA3WSWo//c2SerrR5PH7/XF84poqG5 k6S69gCzrQ0YKOwmSYx30AkE0iRlvSnuCzmpL65Zu/HDQf+waeqXB73aGNJMbu3DStFJ jGNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=ieyGc0lcP2qslY/k/Zc8iH5sBXnxr9bzsD8Ux8bqk8s=; fh=of+la8jmJ2Dc/4DAjCaKf6wjDIIBzGsJJ3uZlVxhrNo=; b=cFwJnUT8M4P7MgQRqfpBq66TE4OMR/8PTB1uWuzMPVA70bXqYQyXYpx+Q+ayLY4Tvz MVlwzKP1hLgpNmQRzehaJabhYoLz1QJv5vrSw5PSDAQWjIYep9kMP6WL/ArbuZD4HCSq yC+dHXLi9KRhT9GREr8aq0iI1uynd8FVo9Htg+CkJoswz1knRaBt0e4WXaDBGYW64+T5 JhQW2yeLBABPHvpSDVjf8Z7CwJY1/ZsAhN1bQaZ6ejEK/fFH84i4d0bkUp8WfTOdUN/8 BiPRGzKZbII5FWQNtZo0fCkkhDhVQbklYJmSgnurvsuEJb7FR+lFqP/QelSZEMjQ4PrE rnXw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PLAh1KFJ; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-45da76d5c44si30663761cf.737.2024.10.05.16.34.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 Oct 2024 16:34: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=PLAh1KFJ; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sxEHZ-0006As-8a; Sat, 05 Oct 2024 19:33:53 -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 1sxEHW-00069a-LA for qemu-devel@nongnu.org; Sat, 05 Oct 2024 19:33:50 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sxEHU-0004Cv-KK for qemu-devel@nongnu.org; Sat, 05 Oct 2024 19:33:50 -0400 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-2e0c7eaf159so2624836a91.1 for ; Sat, 05 Oct 2024 16:33:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728171227; x=1728776027; darn=nongnu.org; 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=ieyGc0lcP2qslY/k/Zc8iH5sBXnxr9bzsD8Ux8bqk8s=; b=PLAh1KFJSIF0hmeasz57/5TzduwtoiLnNLHfEU8iz1CVbJuTpHLO9y2VDeNeKlgWVo /UBzN8bhYl7PnAeawC3dQhgfiyLND1qxYxjakBwoOiDNNipd0sLaHx1AyiTM8GYHvGhi KtaqptkMIgtBmT0pMDrSiebiQPc9SS1sGkiEt2m9GpsHmFc+D4AKuotKZkifAwhsv3l3 SN5wUviNOKPiRm0Y/7ULZ9/F5nYn1TDEJgm1N9MkPBzdQirr6g4egd7kMioi4K1IbrkK jBzrbwiBI291TR/ywNuOiX+KUc5qd5IcxNIjW7amfOMJ9MBbACEj1hf7to6GlBYuf9+N qd1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728171227; x=1728776027; 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=ieyGc0lcP2qslY/k/Zc8iH5sBXnxr9bzsD8Ux8bqk8s=; b=EBG+jtmmSFvkwR6l4NuBdAhuAqnsk363SRIRlCopxQBhxCszGyPGKh5is+E5zRmAX2 ahDmKD0j9vPd1pI3lKFbxyuo7jHIR8cMv+UHRoH9+aTkrEYORgkI/3xUcReqxBCUcq/H 93vV+TLC6mz7pP8JWN4iwkPN8j+eTdtoA/h5TrR/dSgzmSiFdHf6QnGMwKVS21ds/Dfv +Rg/JZuy3nZZWbEI++6G1cOvP+c7CUiZ6RFpM6XFGmFfvr7wEmQ0Ido1c9+BsN+C4yu2 LeLLQMVDnxRaC7pO5wS22S2vRfOQjGYyd2BlfuLI/hHeD2f4/v6RaRStnnYacAepQUEU lv2w== X-Gm-Message-State: AOJu0Yzq3tgfDvjDOnMHXgCpSV62e83GoOq2J5OG/mwU6K8UMt4NdA6A p8jkb5q5vu+I8S55OrjIDo/KOxfit4U93yUD9p6hmfaTtyhc3RHH5P5LYX0hLQ3bKu3MXl5DmGI s X-Received: by 2002:a17:90a:3fcf:b0:2dd:6969:2096 with SMTP id 98e67ed59e1d1-2e1e63676dcmr8120939a91.38.1728171227000; Sat, 05 Oct 2024 16:33:47 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20b129cc2sm2394600a91.51.2024.10.05.16.33.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 16:33:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Michael Vogt , Laurent Vivier Subject: [PATCH 03/10] linux-user: add openat2 support in linux-user Date: Sat, 5 Oct 2024 16:33:36 -0700 Message-ID: <20241005233343.503426-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005233343.503426-1-richard.henderson@linaro.org> References: <20241005233343.503426-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Michael Vogt This commit adds support for the `openat2()` syscall in the `linux-user` userspace emulator. It is implemented by extracting a new helper `maybe_do_fake_open()` out of the exiting `do_guest_openat()` and share that with the new `do_guest_openat2()`. Unfortunately we cannot just make do_guest_openat2() a superset of do_guest_openat() because the openat2() syscall is stricter with the argument checking and will return an error for invalid flags or mode combinations (which open()/openat() will ignore). The implementation is similar to SYSCALL_DEFINE(openat2), i.e. a new `copy_struct_from_user()` is used that works the same as the kernels version to support backwards-compatibility for struct syscall argument. Instead of including openat2.h we create a copy of `open_how` as `open_how_ver0` to ensure that if the structure grows we can log a LOG_UNIMP warning. Note that in this commit using openat2() for a "faked" file in /proc will honor the "resolve" flags for RESOLVE_NO_{MAGIC,SYM}LINKS for path based access to /proc/self/exe (which is the only magic link we support for faked files). Note it will not catch special access via e.g. dirfd. This is not great but it seems similar to the exiting behavior when openat() is called with a dirfd to "/proc". Here too the fake file lookup may not catch the special file because no dirfd is used to determine if the path is in /proc. Signed-off-by: Michael Vogt Buglink: https://github.com/osbuild/bootc-image-builder/issues/619 Reviewed-by: Laurent Vivier Message-ID: <1c2c8c9db3731ed4c6fd9b10c63637c3e4caf8f5.1727795334.git.mvogt@redhat.com> Signed-off-by: Richard Henderson --- linux-user/syscall_defs.h | 13 +++++ linux-user/syscall.c | 105 +++++++++++++++++++++++++++++++++++++- 2 files changed, 116 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index e08d088740..de5091c977 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2748,4 +2748,17 @@ struct target_sched_param { abi_int sched_priority; }; +/* from kernel's include/uapi/linux/openat2.h */ +struct target_open_how_ver0 { + abi_ullong flags; + abi_ullong mode; + abi_ullong resolve; +}; +#ifndef RESOLVE_NO_MAGICLINKS +#define RESOLVE_NO_MAGICLINKS 0x02 +#endif +#ifndef RESOLVE_NO_SYMLINKS +#define RESOLVE_NO_SYMLINKS 0x04 +#endif + #endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a666986189..2febc3bc3f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -602,6 +602,34 @@ static int check_zeroed_user(abi_long addr, size_t ksize, size_t usize) return 1; } +/* + * Copies a target struct to a host struct, in a way that guarantees + * backwards-compatibility for struct syscall arguments. + * + * Similar to kernels uaccess.h:copy_struct_from_user() + */ +static int +copy_struct_from_user(void *dst, size_t ksize, abi_ptr src, size_t usize) +{ + size_t size = MIN(ksize, usize); + size_t rest = MAX(ksize, usize) - size; + + /* Deal with trailing bytes. */ + if (usize < ksize) { + memset(dst + size, 0, rest); + } else if (usize > ksize) { + int ret = check_zeroed_user(src, ksize, usize); + if (ret <= 0) { + return ret ?: -TARGET_E2BIG; + } + } + /* Copy the interoperable parts of the struct. */ + if (copy_from_user(dst, src, size)) { + return -TARGET_EFAULT; + } + return 0; +} + #define safe_syscall0(type, name) \ static type safe_##name(void) \ { \ @@ -653,6 +681,15 @@ safe_syscall3(ssize_t, read, int, fd, void *, buff, size_t, count) safe_syscall3(ssize_t, write, int, fd, const void *, buff, size_t, count) safe_syscall4(int, openat, int, dirfd, const char *, pathname, \ int, flags, mode_t, mode) + +struct open_how_ver0 { + __u64 flags; + __u64 mode; + __u64 resolve; +}; +safe_syscall4(int, openat2, int, dirfd, const char *, pathname, \ + const struct open_how_ver0 *, how, size_t, size) + #if defined(TARGET_NR_wait4) || defined(TARGET_NR_waitpid) safe_syscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, \ struct rusage *, rusage) @@ -8332,8 +8369,9 @@ static int open_net_route(CPUArchState *cpu_env, int fd) } #endif -int do_guest_openat(CPUArchState *cpu_env, int dirfd, const char *fname, - int flags, mode_t mode, bool safe) +static int maybe_do_fake_open(CPUArchState *cpu_env, int dirfd, + const char *fname, int flags, mode_t mode, + int openat2_resolve, bool safe) { g_autofree char *proc_name = NULL; const char *pathname; @@ -8370,6 +8408,12 @@ int do_guest_openat(CPUArchState *cpu_env, int dirfd, const char *fname, } if (is_proc_myself(pathname, "exe")) { + /* Honor openat2 resolve flags */ + if ((openat2_resolve & RESOLVE_NO_MAGICLINKS) || + (openat2_resolve & RESOLVE_NO_SYMLINKS)) { + errno = ELOOP; + return -1; + } if (safe) { return safe_openat(dirfd, exec_path, flags, mode); } else { @@ -8416,6 +8460,17 @@ int do_guest_openat(CPUArchState *cpu_env, int dirfd, const char *fname, return fd; } + return -2; +} + +int do_guest_openat(CPUArchState *cpu_env, int dirfd, const char *pathname, + int flags, mode_t mode, bool safe) +{ + int fd = maybe_do_fake_open(cpu_env, dirfd, pathname, flags, mode, 0, safe); + if (fd > -2) { + return fd; + } + if (safe) { return safe_openat(dirfd, path(pathname), flags, mode); } else { @@ -8423,6 +8478,49 @@ int do_guest_openat(CPUArchState *cpu_env, int dirfd, const char *fname, } } + +static int do_openat2(CPUArchState *cpu_env, abi_long dirfd, + abi_ptr guest_pathname, abi_ptr guest_open_how, + abi_ulong guest_size) +{ + struct open_how_ver0 how = {0}; + char *pathname; + int ret; + + if (guest_size < sizeof(struct target_open_how_ver0)) { + return -TARGET_EINVAL; + } + ret = copy_struct_from_user(&how, sizeof(how), guest_open_how, guest_size); + if (ret) { + if (ret == -TARGET_E2BIG) { + qemu_log_mask(LOG_UNIMP, + "Unimplemented openat2 open_how size: " + TARGET_ABI_FMT_lu "\n", guest_size); + } + return ret; + } + pathname = lock_user_string(guest_pathname); + if (!pathname) { + return -TARGET_EFAULT; + } + + how.flags = target_to_host_bitmask(tswap64(how.flags), fcntl_flags_tbl); + how.mode = tswap64(how.mode); + how.resolve = tswap64(how.resolve); + int fd = maybe_do_fake_open(cpu_env, dirfd, pathname, how.flags, how.mode, + how.resolve, true); + if (fd > -2) { + ret = get_errno(fd); + } else { + ret = get_errno(safe_openat2(dirfd, pathname, &how, + sizeof(struct open_how_ver0))); + } + + fd_trans_unregister(ret); + unlock_user(pathname, guest_pathname, 0); + return ret; +} + ssize_t do_guest_readlink(const char *pathname, char *buf, size_t bufsiz) { ssize_t ret; @@ -9195,6 +9293,9 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, fd_trans_unregister(ret); unlock_user(p, arg2, 0); return ret; + case TARGET_NR_openat2: + ret = do_openat2(cpu_env, arg1, arg2, arg3, arg4); + return ret; #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) case TARGET_NR_name_to_handle_at: ret = do_name_to_handle_at(arg1, arg2, arg3, arg4, arg5); From patchwork Sat Oct 5 23:33:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 833018 Delivered-To: patch@linaro.org Received: by 2002:adf:8b52:0:b0:367:895a:4699 with SMTP id v18csp1380017wra; Sat, 5 Oct 2024 16:34:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVi/vIDwmX1DtVk9Wv8sevdSpbcmkc5xFenYrIcgNkJ5H8q/HTmSJQMVhcDHFv8QRDfaBLTwg==@linaro.org X-Google-Smtp-Source: AGHT+IFakBK0F4Z+hMyZc/ZAKL6kt7rV1ZwxtahC0PmsT+T8Rb4OL5Yc7FgfvQNMUHFwsW7MVIuq X-Received: by 2002:a05:622a:1985:b0:45d:8be9:b0e6 with SMTP id d75a77b69052e-45d9baed538mr120876531cf.43.1728171277203; Sat, 05 Oct 2024 16:34:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728171277; cv=none; d=google.com; s=arc-20240605; b=T0CnGOJVwN+LpOJiLikWtHOBxiGw6dkwdFX1+o7lkb0PH2X4pNWw/Un7ELjkb49eRA ieGeH66QorzwAUGZLnbrydQhl7BOFx/9uQ7IH/tIAz/p+aqhhKv/VoCUSVmHvUmZW0pe U1Nkv3NPHDnqdiQ00hftptefGEGUqGBWgpZKIl0qRTl+ZEpbQ4jCkNxNft+z5D8+wZd+ GbnExUjnahhSelhyV1A6OYNdzHeqmVIUexz7nPWLl7DRA9QDhCip9m6kShK5XrkJG8sj UL/k5n4FFsjxAYWjfel5IvcEWZlVq6xi0jf+pELhHIaEQ8FtaO2oEcUeCmFqhHkoNPVK rgLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=AL3SBfbgObr8NPSxnJHCyhyRw8f0bsHDxC2e9NdNe78=; fh=of+la8jmJ2Dc/4DAjCaKf6wjDIIBzGsJJ3uZlVxhrNo=; b=Y/NTgE5uyDjrZDrbtaJqa3F2K8PsJffXP9xhXECuy4KoJ2lK+BRfOFrpP04MlZPZHp 1C6fZwy/dmtQwmaFmCJm9GCSa7w4w53f2+dlBZxFdk8DbUn92RavnajRuYWcHVpceMco X3DJwRofiinYrmVjyvjP27CkdEcbATRR9+SdcVbp46fs+qLs85Pl/bt1wmIcUe616v07 wAjgYfclUaRqSk3ddPMoH7QETHR6oLAslzPtdIyCymX/FHnaZLyNfWdmD/J9ZbHUyB+U 0Z0LJxDh4g3sfVTTj9/qHYzrqPgS4+mtGDgkg9EC03eFs7FmPJlIoWMXkVCtB+2XfTfL 6ftw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FDeyFb3r; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-45da769837dsi30526101cf.554.2024.10.05.16.34.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 Oct 2024 16:34: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=FDeyFb3r; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sxEHY-0006Am-SO; Sat, 05 Oct 2024 19:33:52 -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 1sxEHX-0006AL-Q9 for qemu-devel@nongnu.org; Sat, 05 Oct 2024 19:33:51 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sxEHV-0004DB-Tq for qemu-devel@nongnu.org; Sat, 05 Oct 2024 19:33:51 -0400 Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-2e07d91f78aso2440202a91.1 for ; Sat, 05 Oct 2024 16:33:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728171228; x=1728776028; darn=nongnu.org; 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=AL3SBfbgObr8NPSxnJHCyhyRw8f0bsHDxC2e9NdNe78=; b=FDeyFb3r7aEpTP7U1nUz+zm5xXIesOFPrEFQZnxbCkNDXTTxQhkkDe1bfM0VYCgsv3 nda1MYe1uwWDmIb5cK6yXC2vpTPeghzJUHm9tg4hNA3WKyhrMu20t99F+PH6lKhk0W9o f4t7KNuG1yqfhc06c5Xk06fqHyRaO1AJFKwfLu2VX3EA4MwpmSwXJDeaZmqmM+RPj+Ev jM10nKAf/nNiGKJQEiMl/6htxXz3vzhc4/DjEmE7tffsZrmpHczc6ZTYRhJWZ7L+GkP9 eQiZPG/o7JpknxFLx2NGeYErNqDZREvtrDfwYzGjjnTdzO9VDQr/SlWsjRc3/+LhFdw9 VHHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728171228; x=1728776028; 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=AL3SBfbgObr8NPSxnJHCyhyRw8f0bsHDxC2e9NdNe78=; b=P/owWVmrQHMRGe0yroLnEcsYqCva9nn7k5J+1G/4wJmguYIlgitUkfMSx5vCEONDHb vEnWFFVLjkgq/9By6WYROo8YmSdFoCQntSCSFaqNBla16nfn/TbcCnFULCGQNqD9SNpZ 9osbzUiiG3ms6oZ6KsOBWi6ISLtlxn6NYtXAD8dRxg2y9SltZZYuaC2PC4AJeELjVpHL 3m8C9TljM9d0IHwi0SM/qpOVq5stGM9p4NhrN1vFUtLPjd9IibYy6jVnaUZ3F87xiJSx gLCcrTtmsvUGFOeZqqj0Eh/pNEOwaVrY0X0LYdIc85aBNN5X+/xP9irh1uiMwz9kcFgv E0og== X-Gm-Message-State: AOJu0Yzf3cN6RdFNhcTEUy3ijoR2FPzoUjDMVonDiHzR/sVyvpwnLXvk 5Oq9F+P6Gd5W/8lceN+AxlqlDiwBWfzFXmR3dSIdc0g0jarRPbJ2TX1Ar21q5STWP0cCc/Bb5of e X-Received: by 2002:a17:90a:7c01:b0:2d8:cd04:c8f0 with SMTP id 98e67ed59e1d1-2e1e63bf1b6mr9119591a91.39.1728171228171; Sat, 05 Oct 2024 16:33:48 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20b129cc2sm2394600a91.51.2024.10.05.16.33.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 16:33:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Michael Vogt , Laurent Vivier Subject: [PATCH 04/10] linux-user: add strace support for openat2 Date: Sat, 5 Oct 2024 16:33:37 -0700 Message-ID: <20241005233343.503426-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005233343.503426-1-richard.henderson@linaro.org> References: <20241005233343.503426-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Michael Vogt This commit adds support for the `openat2()` to `QEMU_STRACE`. It will use the `openat2.h` header if available to create user readable flags for the `resolve` argument but does not require the header otherwise. It also makes `copy_struct_from_user()` available via `qemu.h` and `open_how_ver0` via `syscall_defs.h` so that strace.c can use them. Signed-off-by: Michael Vogt Reviewed-by: Laurent Vivier Message-ID: [rth: Add braces around the expanded how structure, like strace(3)] Signed-off-by: Richard Henderson --- linux-user/qemu.h | 9 ++++++++ linux-user/syscall_defs.h | 5 +++++ linux-user/strace.c | 47 +++++++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 8 +------ linux-user/strace.list | 3 +++ meson.build | 1 + 6 files changed, 66 insertions(+), 7 deletions(-) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 2e90a97175..98ad848ab2 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -313,6 +313,15 @@ static inline bool access_ok(CPUState *cpu, int type, int copy_from_user(void *hptr, abi_ulong gaddr, ssize_t len); int copy_to_user(abi_ulong gaddr, void *hptr, ssize_t len); +/* + * copy_struct_from_user() copies a target struct to a host struct, in + * a way that guarantees backwards-compatibility for struct syscall + * arguments. + * + * Similar to kernels uaccess.h:copy_struct_from_user() + */ +int copy_struct_from_user(void *dst, size_t ksize, abi_ptr src, size_t usize); + /* Functions for accessing guest memory. The tget and tput functions read/write single values, byteswapping as necessary. The lock_user function gets a pointer to a contiguous area of guest memory, but does not perform diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index de5091c977..0ade83745e 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2749,6 +2749,11 @@ struct target_sched_param { }; /* from kernel's include/uapi/linux/openat2.h */ +struct open_how_ver0 { + __u64 flags; + __u64 mode; + __u64 resolve; +}; struct target_open_how_ver0 { abi_ullong flags; abi_ullong mode; diff --git a/linux-user/strace.c b/linux-user/strace.c index b4d1098170..d3cdd09dc1 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -13,6 +13,9 @@ #include #include #include +#ifdef HAVE_OPENAT2_H +#include +#endif #include #include "qemu.h" #include "user-internals.h" @@ -1063,6 +1066,18 @@ UNUSED static const struct flags open_flags[] = { FLAG_END, }; +UNUSED static const struct flags openat2_resolve_flags[] = { +#ifdef HAVE_OPENAT2_H + FLAG_GENERIC(RESOLVE_NO_XDEV), + FLAG_GENERIC(RESOLVE_NO_MAGICLINKS), + FLAG_GENERIC(RESOLVE_NO_SYMLINKS), + FLAG_GENERIC(RESOLVE_BENEATH), + FLAG_GENERIC(RESOLVE_IN_ROOT), + FLAG_GENERIC(RESOLVE_CACHED), +#endif + FLAG_END, +}; + UNUSED static const struct flags mount_flags[] = { #ifdef MS_BIND FLAG_GENERIC(MS_BIND), @@ -3483,6 +3498,38 @@ print_openat(CPUArchState *cpu_env, const struct syscallname *name, } #endif +#ifdef TARGET_NR_openat2 +static void +print_openat2(CPUArchState *cpu_env, const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + struct open_how_ver0 how; + + print_syscall_prologue(name); + print_at_dirfd(arg0, 0); + print_string(arg1, 0); + + if ((abi_ulong)arg3 >= sizeof(struct target_open_how_ver0) && + copy_struct_from_user(&how, sizeof(how), arg2, arg3) == 0) { + how.flags = tswap64(how.flags); + how.mode = tswap64(how.mode); + how.resolve = tswap64(how.resolve); + qemu_log("{"); + print_open_flags(how.flags, 0); + if (how.flags & TARGET_O_CREAT) { + print_file_mode(how.mode, 0); + } + print_flags(openat2_resolve_flags, how.resolve, 1); + qemu_log("},"); + } else { + print_pointer(arg2, 0); + } + print_raw_param(TARGET_ABI_FMT_lu, arg3, 1); + print_syscall_epilogue(name); +} +#endif + #ifdef TARGET_NR_pidfd_send_signal static void print_pidfd_send_signal(CPUArchState *cpu_env, const struct syscallname *name, diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 2febc3bc3f..1354e75694 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -608,8 +608,7 @@ static int check_zeroed_user(abi_long addr, size_t ksize, size_t usize) * * Similar to kernels uaccess.h:copy_struct_from_user() */ -static int -copy_struct_from_user(void *dst, size_t ksize, abi_ptr src, size_t usize) +int copy_struct_from_user(void *dst, size_t ksize, abi_ptr src, size_t usize) { size_t size = MIN(ksize, usize); size_t rest = MAX(ksize, usize) - size; @@ -682,11 +681,6 @@ safe_syscall3(ssize_t, write, int, fd, const void *, buff, size_t, count) safe_syscall4(int, openat, int, dirfd, const char *, pathname, \ int, flags, mode_t, mode) -struct open_how_ver0 { - __u64 flags; - __u64 mode; - __u64 resolve; -}; safe_syscall4(int, openat2, int, dirfd, const char *, pathname, \ const struct open_how_ver0 *, how, size_t, size) diff --git a/linux-user/strace.list b/linux-user/strace.list index dfd4237d14..ef658224fc 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -715,6 +715,9 @@ #ifdef TARGET_NR_openat { TARGET_NR_openat, "openat" , NULL, print_openat, NULL }, #endif +#ifdef TARGET_NR_openat2 +{ TARGET_NR_openat2, "openat2" , NULL, print_openat2, NULL }, +#endif #ifdef TARGET_NR_osf_adjtime { TARGET_NR_osf_adjtime, "osf_adjtime" , NULL, NULL, NULL }, #endif diff --git a/meson.build b/meson.build index 10464466ff..77cb5c41d8 100644 --- a/meson.build +++ b/meson.build @@ -2488,6 +2488,7 @@ config_host_data.set('CONFIG_LINUX_MAGIC_H', cc.has_header('linux/magic.h')) config_host_data.set('CONFIG_VALGRIND_H', cc.has_header('valgrind/valgrind.h')) config_host_data.set('HAVE_BTRFS_H', cc.has_header('linux/btrfs.h')) config_host_data.set('HAVE_DRM_H', cc.has_header('libdrm/drm.h')) +config_host_data.set('HAVE_OPENAT2_H', cc.has_header('linux/openat2.h')) config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h')) config_host_data.set('HAVE_SYS_DISK_H', cc.has_header('sys/disk.h')) config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h')) From patchwork Sat Oct 5 23:33:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 833025 Delivered-To: patch@linaro.org Received: by 2002:adf:8b52:0:b0:367:895a:4699 with SMTP id v18csp1380263wra; Sat, 5 Oct 2024 16:36:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXfqOBqJyfcmqUu1IS5BJCzKVqwWSq10HgvN5A5khxLO3Rh4JZQC7K1Wg8y6A+43fYJnIlc8A==@linaro.org X-Google-Smtp-Source: AGHT+IFbig4yRxz9MIN378KphPxztoC9fFpC1OPEiWRukCZAtFEeJd2bQFj7QXChE2npykgoMaKi X-Received: by 2002:ac8:5809:0:b0:45d:8684:4324 with SMTP id d75a77b69052e-45d9bb3a95cmr124044811cf.58.1728171361740; Sat, 05 Oct 2024 16:36:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728171361; cv=none; d=google.com; s=arc-20240605; b=BoFRoFaI55y3zvP2nRSgVR2si89WWBaX/36BLjPhNs6lSB+pJe7ShrXdAX+BxEqlub tQyCUYIU0QElHPR5ookZ+cOoGx36F01jC83L8b//gKzN5eGvyf1ZtRcWAorfTjq/tvsa PI6kND/DVqWdBhLAk2Lh3fjCRQJ3tiIRb6pZqwSyNREig5KM8pm4DnFyifVbMBwXmqJx WAKBKenAN+4Ye6qZvsc8GHYmam+LO2Je6Jyzv3f+c/UhquhPDbBXlCt2jCqk9S+nO6LI fLwrhVcPKhWCFBPKcbzsmiBNMhW2t3c6KzWS3WaZlLOfjerbzv5nZzzPWGpVNvwVetpW 5AKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=o3MlKySkLCqcubwj2AlCHtEZtre6EurFM45v8Ib7p+Y=; fh=o2XzhdKG+B45MJCghEfnYoypmHvLX2hd4SL6yXeiyXI=; b=GbBR8+/fW4sB1xE6Q0enxNsc28Iid3xuaDoYLe6iC364l5My2fLspoHOTHjo+4xcdT /NB/Ry90dHgKwxVXElEcRkGPZm6OSB8LkfjAqqw0avASrER7Fe75aWZSTV8oupJp2bix gQXqXdJ9RCithMO6ziGXLTrkaCgIvmXcsErOY3RLkHVzqlRd4iYS9ODw90D6H4qyGxpn zX/cC4ph1JURz/CaB3QftAm+E0w03XzUyUHPK5oURlSy6FTFjVFcqa61E5ZEc5Y1gFDw qKS4s+IW+EA3BdY0gjogM9yKp0MuEL3KwbeQxSCmr1O47ZZm8C6DtI4FdJ0ZUZRiBK6h tGQw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EcBr3RRO; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-45da75e418bsi29271351cf.330.2024.10.05.16.36.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 Oct 2024 16:36:01 -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=EcBr3RRO; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sxEHa-0006BY-IW; Sat, 05 Oct 2024 19:33:54 -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 1sxEHY-0006AT-3b for qemu-devel@nongnu.org; Sat, 05 Oct 2024 19:33:52 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sxEHW-0004DL-Av for qemu-devel@nongnu.org; Sat, 05 Oct 2024 19:33:51 -0400 Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-2e082bf1c7fso2329947a91.3 for ; Sat, 05 Oct 2024 16:33:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728171229; x=1728776029; darn=nongnu.org; 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=o3MlKySkLCqcubwj2AlCHtEZtre6EurFM45v8Ib7p+Y=; b=EcBr3RROnng+Kwd7MidtFRmZhKsqTueJzo3ri8MjfFdWzInTss+j+LgDjdM2yzcDbw EUWs8WCI6A+zN6eApZYTel26gk0+/ljcwywAiIjGMgZKtHR9yMMUojX+swUmXGnJZ2ge Ob5+Xiw6BS94Eb9HtlidcHVITF3ceU0AmajrGowx/laz6jFkWKkroNUd1ugP8nFFkPb1 XGhwE9RNvvNnKFbukjCQ+4JCbEZnWrDnjtktN9sAztfulnJmYEDy1iRfdOGA99Fcm742 T5XlRZJAzMSMCPWe6Kz9/zo3IeXYu1KMqUTTZMlpHbPQORaM0fuXmpwwvuGzau7qMaNp yEVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728171229; x=1728776029; 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=o3MlKySkLCqcubwj2AlCHtEZtre6EurFM45v8Ib7p+Y=; b=iKrHh/4CGFytxbNo+sVwAUtPqSiB/OyUfBNNmdx+4TMeanbkdf0Rw54OOxTgYWSgYV T6DPyxCr+S0iS3+UFN4DDqKh7WZLgJm4zqM3nw140U/7oGD/R6zECaU6uqd/CYiNppcS 4s/cfOghsf1CFG2Eyeg3aiuvxhlePeLMNghe+kMR5qzsKqKKibJDoDIWlMVu6Sy2HaMS 1g9EAdDPKbJE0h1OQYZrzjQKmLeKD2ocOQqf8hzt+lC+s+ANZhupogGB9tmL5OhRNltB s1nThVgpBfUEpAXxy+ululWdbF07Y59F2GaPYHV/11nPZX2kFC2Q+kyu235rxBFyqYXl 0xxg== X-Gm-Message-State: AOJu0Yyu1J5XRwV9dt741uoxW/akjTjgYs0WCngvBbAS/ZrTRNHeEFgl Nk1qwsSM2y/IYVRUDf3kFMA14uXLaPFEY98iHOF0r5I5mgFIoxf3D/Fp0dr/MU6080Q0mprPtDV W X-Received: by 2002:a17:90a:c82:b0:2e0:80e8:a312 with SMTP id 98e67ed59e1d1-2e1e63bb8a8mr8356508a91.34.1728171229044; Sat, 05 Oct 2024 16:33:49 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20b129cc2sm2394600a91.51.2024.10.05.16.33.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 16:33:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich Subject: [PATCH 05/10] linux-user: Trace wait4()'s and waitpid()'s wstatus Date: Sat, 5 Oct 2024 16:33:38 -0700 Message-ID: <20241005233343.503426-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005233343.503426-1-richard.henderson@linaro.org> References: <20241005233343.503426-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Ilya Leoshkevich Borrow the code for formatting the most frequent WIFEXITED() and WIFSIGNALED() special cases from from the strace's printstatus(). Output examples: 474729 wait4(-1,0x7f00767ff0a0,0,(nil)) = 474733 (wstatus={WIFEXITED(s) && WEXITSTATUS(s) == 1}) 475833 wait4(-1,0x7f7de61ff0a0,0,(nil)) = 475837 (wstatus={WIFSIGNALED(s) && WTERMSIG(s) == SIGKILL}) 1168 waitpid(1171,0x7f44eea00340,0) = 1171 (wstatus={WIFSIGNALED(s) && WTERMSIG(s) == SIGKILL}) Signed-off-by: Ilya Leoshkevich Message-ID: <20241001193244.14939-1-iii@linux.ibm.com> [rth: Drop extra output for NULL wstatus or error reading.] Signed-off-by: Richard Henderson --- linux-user/strace.c | 57 ++++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 6 +++-- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index d3cdd09dc1..cf9eaf71c9 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -4215,6 +4215,63 @@ print_ioctl(CPUArchState *cpu_env, const struct syscallname *name, } #endif +#if defined(TARGET_NR_wait4) || defined(TARGET_NR_waitpid) +static void print_wstatus(int wstatus) +{ + if (WIFSIGNALED(wstatus)) { + qemu_log("{WIFSIGNALED(s) && WTERMSIG(s) == "); + print_signal(WTERMSIG(wstatus), 1); + if (WCOREDUMP(wstatus)) { + qemu_log(" && WCOREDUMP(s)"); + } + qemu_log("}"); + } else if (WIFEXITED(wstatus)) { + qemu_log("{WIFEXITED(s) && WEXITSTATUS(s) == %d}", + WEXITSTATUS(wstatus)); + } else { + print_number(wstatus, 1); + } +} + +static void print_ret_wstatus(abi_long ret, abi_long wstatus_addr) +{ + int wstatus; + + if (!print_syscall_err(ret) + && wstatus_addr + && get_user_s32(wstatus, wstatus_addr)) { + qemu_log(TARGET_ABI_FMT_ld " (wstatus=", ret); + print_wstatus(wstatus); + qemu_log(")"); + } + qemu_log("\n"); +} +#endif + +#ifdef TARGET_NR_wait4 +static void +print_syscall_ret_wait4(CPUArchState *cpu_env, + const struct syscallname *name, + abi_long ret, abi_long arg0, abi_long arg1, + abi_long arg2, abi_long arg3, abi_long arg4, + abi_long arg5) +{ + print_ret_wstatus(ret, arg1); +} +#endif + +#ifdef TARGET_NR_waitpid +static void +print_syscall_ret_waitpid(CPUArchState *cpu_env, + const struct syscallname *name, + abi_long ret, abi_long arg0, abi_long arg1, + abi_long arg2, abi_long arg3, abi_long arg4, + abi_long arg5) +{ + print_ret_wstatus(ret, arg1); +} +#endif + /* * An array of all of the syscalls we know about */ diff --git a/linux-user/strace.list b/linux-user/strace.list index ef658224fc..f8899710b5 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1662,13 +1662,15 @@ { TARGET_NR_vserver, "vserver" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_wait4 -{ TARGET_NR_wait4, "wait4" , "%s(%d,%p,%d,%p)", NULL, NULL }, +{ TARGET_NR_wait4, "wait4" , "%s(%d,%p,%d,%p)", NULL, + print_syscall_ret_wait4 }, #endif #ifdef TARGET_NR_waitid { TARGET_NR_waitid, "waitid" , "%s(%#x,%d,%p,%#x)", NULL, NULL }, #endif #ifdef TARGET_NR_waitpid -{ TARGET_NR_waitpid, "waitpid" , "%s(%d,%p,%#x)", NULL, NULL }, +{ TARGET_NR_waitpid, "waitpid", "%s(%d,%p,%#x)", NULL, + print_syscall_ret_waitpid }, #endif #ifdef TARGET_NR_write { TARGET_NR_write, "write" , "%s(%d,%#x,%d)", NULL, NULL }, From patchwork Sat Oct 5 23:33:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 833016 Delivered-To: patch@linaro.org Received: by 2002:adf:8b52:0:b0:367:895a:4699 with SMTP id v18csp1380019wra; Sat, 5 Oct 2024 16:34:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUqD6lnu62bCW9a18cKybCHZ61EVWq+Va7gTV7aN6+JjAfjjou1SymRimRLsgNsR3Pz4njDqw==@linaro.org X-Google-Smtp-Source: AGHT+IFw2wx/PFA4QCSRcBxWSLfMeV54Rmuq6XmNWbXytP0by0+JQQVtTVG2gbJgUNlrvcOmUvE6 X-Received: by 2002:ac8:5d09:0:b0:45b:5cdf:54f3 with SMTP id d75a77b69052e-45d9ba21589mr107806101cf.10.1728171277280; Sat, 05 Oct 2024 16:34:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728171277; cv=none; d=google.com; s=arc-20240605; b=U+d83KElHj/7gUEkOn5weJBGvmmJ7ME9RR1MnaU06W1TiOukWWm94ebxoZ4A2qr6Jh AdVpUnn38vPP2I8kJpC+fiVM2WvVLpLpl/NdqIPrhL2mDXYl+p6mgiNeeEzXCRmQsDi5 lh8FmZlJ6whTzyB9IGhvmfhj5ZCAWTu7FQqj+tdPmEC+9j91o47dBoKU/AmeD3Lv1Hhc X3g7TEHInoSHf4w3L553kN5T49l23BcTVkIUfW+zz5RsuOF1+OAhlq0ZL8/g0TxmbAv5 VTocg/PmLTr7W+63Bf66vdKd2kdzrHosNFKbB6d5suwA4VHFvds77hy2rOWP8Mj5HLHR CFTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=5CYklN5kY6AhJz0z8fnMo7i52/61zUcEwxCjMHlZ3PY=; fh=RZjZOy5+Yj9WJfOPbqEaL9dDAfIcQQit8cKdQSuDgDE=; b=Y2oIbyxdD6vpoyC6TUf6uqilyHCaNx6C2z7HST9jWpew8m8nS9WyxBmbleDtuqkKjb JeXmkKFPeuDCLA+RSRSnv9pIjP9ikdQ7YjaMTjrtpaH3Pbz1BwxLhXlx1EqD/+3audW9 ljETO4vryDU6bjkGzAC1oAuP8dJqgtt7AAQRVd3VhcSicAtN5ltK2i4x+Fl5MiY7Ordc KZ4pk/VpGPeLT6zwm6dpmCJpJOPk0qCDeNAyMhhsZ0P1pnkKCLb14h+WKittBlzQfuZ1 +zVZ4QiDm6b+eok93XEPwxpw7tb+SdqHwCctSpamMLaaQLrmTnH6XE+YPFgUoP2g69B+ mF5w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OFGG4gZL; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-45da74ac816si30281601cf.32.2024.10.05.16.34.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 Oct 2024 16:34: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=OFGG4gZL; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sxEHb-0006C6-Bd; Sat, 05 Oct 2024 19:33:55 -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 1sxEHY-0006Aj-Mr for qemu-devel@nongnu.org; Sat, 05 Oct 2024 19:33:52 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sxEHX-0004DT-9K for qemu-devel@nongnu.org; Sat, 05 Oct 2024 19:33:52 -0400 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-2e1bfa9ddb3so2481927a91.0 for ; Sat, 05 Oct 2024 16:33:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728171230; x=1728776030; darn=nongnu.org; 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=5CYklN5kY6AhJz0z8fnMo7i52/61zUcEwxCjMHlZ3PY=; b=OFGG4gZLWdA8Zh95OBZQBsTVgvkGfJOlEsAFbO2+xe15ypmhyr40Y5TF8oD16djA1u KUIqngAeHx0vyjHyeCu9fBFxH67+ydsoH5swH1UTmlbHKeb+Jcj0ashTk2VJDlCgaWV7 0O885zKIe+/F5Qjcv6wv/4+hWh9RLAv6dn0AMZZyhoqFdGZ8EX1E1B5RVu75gtTvRiJ8 vtPinvEcQK0rE7KFU/PqiLbsu/37Ud8lv52HF7JZzxabbjqHbeIBaXD3mL5ZD9i/tI1k 7nVGXzrZOrNcYm4pmUBNk4Pt2YbpeF0OfqXL9vvB6qwb36v+I7xK+QRV5Dp6SZXLHxGp NWEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728171230; x=1728776030; 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=5CYklN5kY6AhJz0z8fnMo7i52/61zUcEwxCjMHlZ3PY=; b=DapsBxGBmJNVSIlrPMvw23EIwRk2XxOx43KUY714bxB1NchbHZF6/nFnmyMa/GvzL9 grl1SCK9wa4PzZtD63SHXVtE2LvmCeL10cyFzmp3wmQpNPYzAH0UFv/XMTwxIe5eHU3k 4PpPE5S2wCMQxk7+2PQomJaH0oo4pzQzTts+SK0qNEDO1rMhNOS2ycA5fsUEip4NG2iJ FAmFaZN33VU81n9/lSeqQaHw/GFAH743U8wfkWNA6SPaYYfTrllhmrLShYxfXyuqwz7A pJ5KOfeDGftts6GvAFRaZAONNrcfvb7WvMNnqo9kHlQmQQGju2KyaqQGl07X97vjXz1V l7ow== X-Gm-Message-State: AOJu0YxQl8BjCthJNtxKryqu7BfsXUpxKmXBG4op4dEZHsUh9PomY7M6 em47VG5JqsXG4+P97ah2sIH+eUzBUSmG5BVnXrCsb7ZoVKMKcKd+ygvY0Di9oe8A9BSBb8ZLpfg D X-Received: by 2002:a17:90a:fc96:b0:2c9:6aa9:1d76 with SMTP id 98e67ed59e1d1-2e1e626bc1amr8125478a91.18.1728171230067; Sat, 05 Oct 2024 16:33:50 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20b129cc2sm2394600a91.51.2024.10.05.16.33.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 16:33:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Ilya Leoshkevich Subject: [PATCH 06/10] linux-user: Correct print_sockaddr() format Date: Sat, 5 Oct 2024 16:33:39 -0700 Message-ID: <20241005233343.503426-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005233343.503426-1-richard.henderson@linaro.org> References: <20241005233343.503426-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé When the %addr argument can not be accessed, a double comma is logged (the final qemu_log call prepend a comma). Move the comma from the final qemu_log to the preceeding switch cases that had omitted it. Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20240807124306.52903-2-philmd@linaro.org> Acked-by: Ilya Leoshkevich [rth: Move comma into the various switch cases.] Signed-off-by: Richard Henderson --- linux-user/strace.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index cf9eaf71c9..dfdec58542 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -376,7 +376,7 @@ print_sockaddr(abi_ulong addr, abi_long addrlen, int last) un->sun_path[i]; i++) { qemu_log("%c", un->sun_path[i]); } - qemu_log("\"}"); + qemu_log("\"},"); break; } case AF_INET: { @@ -386,7 +386,7 @@ print_sockaddr(abi_ulong addr, abi_long addrlen, int last) ntohs(in->sin_port)); qemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")", c[0], c[1], c[2], c[3]); - qemu_log("}"); + qemu_log("},"); break; } case AF_PACKET: { @@ -417,12 +417,12 @@ print_sockaddr(abi_ulong addr, abi_long addrlen, int last) } qemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]); - qemu_log("}"); + qemu_log("},"); break; } case AF_NETLINK: { struct target_sockaddr_nl *nl = (struct target_sockaddr_nl *)sa; - qemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u}", + qemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u},", tswap32(nl->nl_pid), tswap32(nl->nl_groups)); break; } @@ -432,14 +432,14 @@ print_sockaddr(abi_ulong addr, abi_long addrlen, int last) qemu_log("%02x, ", sa->sa_data[i]); } qemu_log("%02x}", sa->sa_data[i]); - qemu_log("}"); + qemu_log("},"); break; } unlock_user(sa, addr, 0); } else { print_raw_param("0x"TARGET_ABI_FMT_lx, addr, 0); } - qemu_log(", "TARGET_ABI_FMT_ld"%s", addrlen, get_comma(last)); + qemu_log(TARGET_ABI_FMT_ld"%s", addrlen, get_comma(last)); } static void From patchwork Sat Oct 5 23:33:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 833017 Delivered-To: patch@linaro.org Received: by 2002:adf:8b52:0:b0:367:895a:4699 with SMTP id v18csp1380020wra; Sat, 5 Oct 2024 16:34:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWdOj7ZTAlWWin+xWdgE0WzU3XOCrrryYLqDXkUOKeS4s2HA3+0rQsb6QtbLFlLnGNUAQ+tmQ==@linaro.org X-Google-Smtp-Source: AGHT+IEuqVzM2EwfG4B3UiGNAspoOptXiWO2fub5Uuyjzoam8kJrvo0VOSBlhzShtnMZnvlr9JJS X-Received: by 2002:a05:622a:144b:b0:458:2894:984e with SMTP id d75a77b69052e-45d9ba2893amr122788621cf.3.1728171277288; Sat, 05 Oct 2024 16:34:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728171277; cv=none; d=google.com; s=arc-20240605; b=TlMmE+kyxc8g+TbLnn2VNwcTy62wQWM8zNM0reyBw48i8Eq2bfuKnUjbemlZ81f3+0 QAYKvLmw3dcCJKYOOmGqPv4hdvz+dBO8dvUkvoH1rA5NBoc/fsvIOUZZ/luR/kgl37Re zDAvtbrdYgQeFV5pudwRTBl0liPejI8Ca+EWHWORZwqZItuDywxLJsfsLhYa46JCZ8p5 wHEEcR9XFATnubMpq3yMj+TKWr7bMhKwoJZTEEl6HyuBcTHoMl2Y14su8t8JrmoRY9o0 /BNEW3utdYvFFa4YZTWQSl8RglztL1ZiTVTgH/Pd/F9Nwrqf9mEL5+TtqK8g+IxoW2tz Hhcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=4lBUGHhECpofGFp4uwDS9iqEwNffUJsxDhRgO3S72WA=; fh=RZjZOy5+Yj9WJfOPbqEaL9dDAfIcQQit8cKdQSuDgDE=; b=eM6g8i2ZdHNYD3Q4m6BqeLaSjQdWkMHsTu5VoC+aruqbB0AtwukQ87WvCxhetth3AH Xe/BTkhIljfxpUWYC7jyEQGPLLHnhGE47NHYOue5AB1DeqyOM/2v341i2utDb/QGJoCW rxFAEwx8aRuqzvXBRpVMhcpgmky0pfiKiDGATwYtYdPnEfHCRBPov+WJmyrJCHo1IM18 3B0PS5MEsYLJ72LHFOJwqYrfbixeH2m6kKXq0/FKYagJXpUs0HRre1g2IQY9hIC81cTo Zd4/9Hk8nJc73+/XoLBzmUq8x8rBMWOWoeIJLquCggoclVB85JIF6zMIrkr9CHxB533y W65A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=l54tXIgK; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-45da75e1887si31609041cf.322.2024.10.05.16.34.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 Oct 2024 16:34: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=l54tXIgK; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sxEHb-0006C3-3R; Sat, 05 Oct 2024 19:33:55 -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 1sxEHZ-0006BE-OI for qemu-devel@nongnu.org; Sat, 05 Oct 2024 19:33:54 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sxEHY-0004Dd-AP for qemu-devel@nongnu.org; Sat, 05 Oct 2024 19:33:53 -0400 Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-2e082f2a427so2433380a91.3 for ; Sat, 05 Oct 2024 16:33:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728171231; x=1728776031; darn=nongnu.org; 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=4lBUGHhECpofGFp4uwDS9iqEwNffUJsxDhRgO3S72WA=; b=l54tXIgKtrH35E54nHKX6diTs7rhvXfO9/3Wzpnmso6SHpH+6FR4BzM4DpENA7t597 gATfh/T7xSs5VAjcEhZcfEXUs6mhwJwu7Lpzxe1oDB6GtWmgzKCADLTb4QpkzgQTii/9 4geeHvMarTfJX61D9/tG11e7bg+L+Qflny3tOkV2JM0BNUHBFJzib22wVKwwWz53kVEL qabjL1SNdvJ5M53k+3fPn537sfJdj4okIKip/MNXNtCAdNOut9BqAinYsrpjzLZVa/UE SCxpC01EUWEy+SBvVuQVQxZPNtpsVE+zKCE+aJbz4fGjXmOM6ZiTDalTc74vTgdF1YK0 m3mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728171231; x=1728776031; 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=4lBUGHhECpofGFp4uwDS9iqEwNffUJsxDhRgO3S72WA=; b=sR12ZlNOWPOTKFIMEbB+/yRnC0IqZbe/VlEeLThezg8F5ye3aSsLsd8A2oxHD4o3Sb UeY6bspzFb65Ft+28XfGb2ixPtoMxWHQ1rbSe/LY7LEUdQ8iUFZvJc5YAQIJdjyG+jGm 5+AI5Y6Iqo/yw/p6EmTnjmWd8zu3EWNlD8U9j1tTvOH1H50I6v9YWomrirBgZ902P1Ca Li+bXGYgqm1lqONaab1QJSKv3U8u+YQQzukn0qFjNFedL1L6kWS1k7TyVBxfZBWnyz5I bS86iQiAMsYKbEFsjMnpstSjDJO5puSPBlf5aKvXJ/FyPiRiR/KQBk3ONLGNSfICIDwx xZEQ== X-Gm-Message-State: AOJu0YyDvqrEEQiciwYBQFuLAQ4sEfjWotj3hseidve0fWoX9+GAlOHa lgW/cUOCjW8SVKXbp3mWv/FeDlvL+XEQrFxQOB8rfpwmWa1jrZVGzmx8bn/18LgKlF6orCg3pZd n X-Received: by 2002:a17:90b:3891:b0:2e0:9d3e:bc2b with SMTP id 98e67ed59e1d1-2e1e636f94amr8943063a91.25.1728171231090; Sat, 05 Oct 2024 16:33:51 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20b129cc2sm2394600a91.51.2024.10.05.16.33.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 16:33:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Ilya Leoshkevich Subject: [PATCH 07/10] linux-user: Display sockaddr buffer as pointer Date: Sat, 5 Oct 2024 16:33:40 -0700 Message-ID: <20241005233343.503426-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005233343.503426-1-richard.henderson@linaro.org> References: <20241005233343.503426-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé Rather than 'raw param', display as pointer to get "NULL" instead of "0x00000000". Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Message-ID: <20240807124306.52903-3-philmd@linaro.org> Signed-off-by: Richard Henderson --- linux-user/strace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index dfdec58542..b72fcd515f 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -437,7 +437,7 @@ print_sockaddr(abi_ulong addr, abi_long addrlen, int last) } unlock_user(sa, addr, 0); } else { - print_raw_param("0x"TARGET_ABI_FMT_lx, addr, 0); + print_pointer(addr, 0); } qemu_log(TARGET_ABI_FMT_ld"%s", addrlen, get_comma(last)); } From patchwork Sat Oct 5 23:33:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 833021 Delivered-To: patch@linaro.org Received: by 2002:adf:8b52:0:b0:367:895a:4699 with SMTP id v18csp1380203wra; Sat, 5 Oct 2024 16:35:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXvFvBLRtozdYX6RggxLONrYw3nfcor9Rc4hRoZsAtnxELHsL2uLhNIyRqksXoib8E0bk7ZEg==@linaro.org X-Google-Smtp-Source: AGHT+IFiZEq9ApxL9Va1f6RHcJjIiXMy+nCFHRvlibR1kqeBmI4iE13Vdb76Q/GUT/dtIik0Vj5D X-Received: by 2002:ac8:5a46:0:b0:45d:5786:80b4 with SMTP id d75a77b69052e-45d9ba6449bmr120915941cf.26.1728171342213; Sat, 05 Oct 2024 16:35:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728171342; cv=none; d=google.com; s=arc-20240605; b=Mk+0q/nBAEaz2B5jYWuJHYbe300Kdmy6DnfDATH9+Z2HncpxESQnqhxqQaRw8pcMZE M1MrOYwaKV5hPDe19PCj+WudtmhAJRzqMIt/SmhMt6xaw9g3CGKGOFD8cPIIUzlyI/8f jw48/jTzlMTnpgipo/CYMabKDt5peTZy8pLvBgMuJ3BF558I4m8+SKIO6lOyR6lS9SFo 9Cjgi87oS3FwixYU+S/2LSBjLxvGaBJzFAdhXQbn+yFouyye16v6+BYbHcHVAP0UV/rM OpNTr0THkU84Gxg/Ru8HnAbG419QHglMqTEhV7YQdzUKtoaTWAW333xhPxL0jJAXg1vb uGIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=280plYgj9pKDnH+V9HZdJ+ePLYDZqB5eIDcpDzTLK4I=; fh=RZjZOy5+Yj9WJfOPbqEaL9dDAfIcQQit8cKdQSuDgDE=; b=Rr8PzSX26AzxcBWIVa2CiaLPmCGljvqs9cXyxKAcaObrNTFr5IgNxhI5XlfCr411++ KvmWV5z8pbCWJ5CXwuFzYYVMpCy4uqVBYB8HYAS14xikmGm88ZjkmMqslXj0o4EYPUEO TajFwz5gofzIAG/cx1vs/9exJlyB0rWbXOwsU0ckod6X03HFk+rhLXo7bPLvBdGlrBHr MTqCvje1sFF/CnEkaA5kMT3Vor4Sce/TXR6iY7jlrXCHVcn2sC8hpgJ9pm03cNncmRvV wuDy/GcVmkcUHx94QmAaVHPV9rBJVaD9Ev4AFlwN2YqmVQcer0sfaPyLU/wERw73q4Gi sjDA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D6Jz87m3; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-45da763fda1si29325081cf.456.2024.10.05.16.35.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 Oct 2024 16:35:42 -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=D6Jz87m3; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sxEHc-0006Ci-C4; Sat, 05 Oct 2024 19:33:56 -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 1sxEHa-0006Bq-Qk for qemu-devel@nongnu.org; Sat, 05 Oct 2024 19:33:54 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sxEHZ-0004Dz-BN for qemu-devel@nongnu.org; Sat, 05 Oct 2024 19:33:54 -0400 Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-2e18856feb4so2807800a91.3 for ; Sat, 05 Oct 2024 16:33:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728171232; x=1728776032; darn=nongnu.org; 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=280plYgj9pKDnH+V9HZdJ+ePLYDZqB5eIDcpDzTLK4I=; b=D6Jz87m3IxHmMjgpUgCgxFBNVnhsM5yu36b3KoUcAT8T8Fr9MEw8YmzWtBobjSLYcA 1FeUJ4PqCNqFp9x/q4yzdbqHUR0lKiLCAaZIaI+IwqIkozHElRhhnucGKcQUp7zOmQKO 2FHWOxmHoPYQ8eiqjiAbPLXmMDi0TAmkEr65+85BBHbRD5MbJbne27vSYZ+vRQGzqdHT 7l7LGydYbI7r05vJ70mg+1+GpJkq5baxdVmwYaS8TkjUDmT5Vfq/Ny8HjigcSOaMhFnN Ebw/HsS0kzJRJajwmwEooicOqBnHEodt8OAhnxfgygOm6FRl203o4/KFL7A0AU4rjDr1 o6dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728171232; x=1728776032; 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=280plYgj9pKDnH+V9HZdJ+ePLYDZqB5eIDcpDzTLK4I=; b=gV0+V5+3/HaQRwEnlxXobWY8szZnRv06u1PQn/x10Qeg+QTs9k3nrI1UNyfkzLSAvC 199FdJjjdyTvOqJhcawShszwCfy6dN53tRE68K1a1pkMctolTIR4LAEMPCoSEUD9G6r3 gZdF57NL9vebBPBm+Os+isXDu7XOXoDc5XcDCj495JqAISwm4KQ5Fh8i0s13Tg8Ey5VG 0qBI2299Zl+uS40ahM+R5WWSFM64+gZDmhtCv4cMpJkBypeKNXbeOl1MEq614rnCtu0Q XkbePXqlCPyTW3s5Kzn9U4q/TOXEDncu3owxSiLGJex0kQheGb9M9qsRp4fXn7wxtw4L j54Q== X-Gm-Message-State: AOJu0YxwVImJXnI7zSs6sp2Pxg4A1DGUR0EJA+wBAEBkK2qvvkZpLYqd 4czwz3LaGj+yJ1s1KWFaWE53wYTmqcRQr/sNUq9ASL7GviWbZHz/XkLnaMieGu4PaiocH3Z6ad9 i X-Received: by 2002:a17:90a:2ecc:b0:2cf:fe5d:ea12 with SMTP id 98e67ed59e1d1-2e1e626c037mr9183664a91.24.1728171232101; Sat, 05 Oct 2024 16:33:52 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20b129cc2sm2394600a91.51.2024.10.05.16.33.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 16:33:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Ilya Leoshkevich Subject: [PATCH 08/10] linux-user: Factor print_buf_len() out Date: Sat, 5 Oct 2024 16:33:41 -0700 Message-ID: <20241005233343.503426-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005233343.503426-1-richard.henderson@linaro.org> References: <20241005233343.503426-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Ilya Leoshkevich Message-ID: <20240807124306.52903-4-philmd@linaro.org> Signed-off-by: Richard Henderson --- linux-user/strace.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index b72fcd515f..245153c1ce 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1670,6 +1670,13 @@ print_buf(abi_long addr, abi_long len, int last) } } +static void +print_buf_len(abi_long addr, abi_long len, int last) +{ + print_buf(addr, len, 0); + print_raw_param(TARGET_ABI_FMT_ld, len, last); +} + /* * Prints out raw parameter using given format. Caller needs * to do byte swapping if needed. @@ -2757,8 +2764,7 @@ static void do_print_sendrecv(const char *name, abi_long arg1) qemu_log("%s(", name); print_sockfd(sockfd, 0); - print_buf(msg, len, 0); - print_raw_param(TARGET_ABI_FMT_ld, len, 0); + print_buf_len(msg, len, 0); print_flags(msg_flags, flags, 1); qemu_log(")"); } @@ -2776,8 +2782,7 @@ static void do_print_msgaddr(const char *name, abi_long arg1) qemu_log("%s(", name); print_sockfd(sockfd, 0); - print_buf(msg, len, 0); - print_raw_param(TARGET_ABI_FMT_ld, len, 0); + print_buf_len(msg, len, 0); print_flags(msg_flags, flags, 0); print_sockaddr(addr, addrlen, 0); qemu_log(")"); From patchwork Sat Oct 5 23:33:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 833020 Delivered-To: patch@linaro.org Received: by 2002:adf:8b52:0:b0:367:895a:4699 with SMTP id v18csp1380173wra; Sat, 5 Oct 2024 16:35:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUiBK7Z2MT2oKFWF+EVfI5VfB5AI2OLA78X+332rZWlSf44VGadjxMP+XQ4ShvEaBDgtqqX6w==@linaro.org X-Google-Smtp-Source: AGHT+IGYxw2eEElsDT1bqZguudrh+fRjMhydCHRcWlaoyF1JJVuSZekAufC4jViE4Ktt/9uKbTG2 X-Received: by 2002:a05:620a:454e:b0:7ac:b93b:b250 with SMTP id af79cd13be357-7ae6f3b23cdmr1141454085a.0.1728171331230; Sat, 05 Oct 2024 16:35:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728171331; cv=none; d=google.com; s=arc-20240605; b=N85fsLt8iLuL/4MzCnPyJg+eBH/8xh+u7a6k1ycyaLrKpihdZlMMY50RqDbH/CeJTo Rg2zC6sEqaft3GJsC2Mio5eAirKtfWCh/kPBAC2S7xuPHnZnRZDMqshJCIcNCPcTbmf+ /Q5YolzJ1GKgjw1Ij7k1tMmQq7fSgYDPRcxzsbW2H4SomUPmMIIk1/oYrdp0a3vnpjuD DpfSZQMgcDd2/xfAg7rJhC8vq4/yOuUNoCOm1lXCBcQkC9c7lvyAqoYYNebWhlYJuwgO uv08o58tIbImZNwFc6kHDNOKeNbldrh9J7eI6YeZ1Ixhvq6un13CEkLILarzaltEKmqt JNEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=F2PtOJCUNqbnhgRp0PzmkQFuI5aOsUosexzj1Se6aBs=; fh=RZjZOy5+Yj9WJfOPbqEaL9dDAfIcQQit8cKdQSuDgDE=; b=dlIB0nslKRl9NS7bxn6eIifAfDL6GAG3AJjnD2JYk502djtjsfILd2pQbeMbu7kKik t0LJMf+cOtcWwbLhNMhS+KySJmmqCmAngt6nBd/jeT3Ugb/xY9GdJ6w1nGkHy56ivCoL ILNLbLzxzFdLK9GMpO428d7JN5WbDyhEC+Aufb4z9NSFoUXr4Zd5P0kYYHXj9xSNMnbY hLtnxPlJCNhIuotkIpH1sMR0dTDsRfGgryJ7IoZbxas4KGf8PaFPa9YEFIGQB2xXQtGW KTCYdkJF2Q91lHNEM5G6/Tvg6jOaDmnl/Z3r1uNopckb7AZfa+FZzrlbCAHk9itwMxYM netQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=murOCSQ8; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7ae756166c2si285698485a.108.2024.10.05.16.35.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 Oct 2024 16:35:31 -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=murOCSQ8; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sxEHc-0006Cy-RN; Sat, 05 Oct 2024 19:33:56 -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 1sxEHb-0006CZ-Vu for qemu-devel@nongnu.org; Sat, 05 Oct 2024 19:33:55 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sxEHa-0004E9-Iu for qemu-devel@nongnu.org; Sat, 05 Oct 2024 19:33:55 -0400 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-2e18293a5efso2300546a91.3 for ; Sat, 05 Oct 2024 16:33:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728171233; x=1728776033; darn=nongnu.org; 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=F2PtOJCUNqbnhgRp0PzmkQFuI5aOsUosexzj1Se6aBs=; b=murOCSQ8hvhLMnhb+ESpSC/KB1TUufVo5XSJYWzRjqR+uvh3o85zUl2TE3N+SRELf4 QGqGWr4WjNbsW20meFia20Par8gr61SmRv12GjOH3lndGtfw4hEIKFJ9/amQe1ycR0w9 wfsYyUbpm3m0b6mJxP/zLZEuYlggmybWgHYRWUhP3mIolkvF72NSJmobMBfu8NOsTzIP oRgz6LqskXK3bA3BKfjuMJRSR4YcKpxMqU5CDQp/sSiwXZ22CiqQtljEuKXnuQKmWtiI LaU74yMLPl9YxEldA+7JTlWA7LXBhcLi2do2FacysBuUD0bD4Lw/+DjLb7js7gCYmbm4 Sd+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728171233; x=1728776033; 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=F2PtOJCUNqbnhgRp0PzmkQFuI5aOsUosexzj1Se6aBs=; b=ORKEcWCZxyKPGp83E9MvyDADb8n8FZb+5ZaFPVdmErzXhXvLl+BqaMsqZ75JUom6sc 09GkiVwM6hKoENJ60IR2PTTLYFso6cj8T99T+Lh5ukiilf6bdwjDMraChpcsaFukkNql qiVds7LchBFDarOK10simtq9rFfL1wq1OvEWqM5IYKn+5g3+jV28QOETYd4P6igyPE4f K+lL53nhEn/HMMiCgUfPeE8NbDo2bPBq8Mrk7m7kbZKYYCPJ+41m8Y6FO31IWkMDy+Yz fUkJG0UgV2QW1F261iUT0dKPP1qeHC3CIu8AIiwZlM+SfReCw5G5i+xiIP26ITbJPFW3 Uv3A== X-Gm-Message-State: AOJu0Yy0IlNt3N4nt8zRSQoqRReHTk7Mbjjq2HmUuXH8EZOnxUn9V7Fu yguxeKHryYBlsHIiqO/Xy2P6ECVKkr6IsQ1lOysKb4T5WS5RGmBRZ1laHS5/vHPV0EmM41EchDL q X-Received: by 2002:a17:90a:f40a:b0:2e1:e433:767e with SMTP id 98e67ed59e1d1-2e1e631e566mr9485663a91.28.1728171232947; Sat, 05 Oct 2024 16:33:52 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20b129cc2sm2394600a91.51.2024.10.05.16.33.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 16:33:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Ilya Leoshkevich Subject: [PATCH 09/10] linux-user: Add strace for sendto() Date: Sat, 5 Oct 2024 16:33:42 -0700 Message-ID: <20241005233343.503426-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005233343.503426-1-richard.henderson@linaro.org> References: <20241005233343.503426-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Ilya Leoshkevich Message-ID: <20240807124306.52903-5-philmd@linaro.org> Signed-off-by: Richard Henderson --- linux-user/strace.c | 15 +++++++++++++++ linux-user/strace.list | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 245153c1ce..0263e6a396 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -3142,6 +3142,21 @@ print_bind(CPUArchState *cpu_env, const struct syscallname *name, } #endif +#ifdef TARGET_NR_sendto +static void +print_sendto(CPUArchState *cpu_env, const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_sockfd(arg0, 0); + print_buf_len(arg1, arg2, 0); + print_flags(msg_flags, arg3, 0); + print_sockaddr(arg4, arg5, 1); + print_syscall_epilogue(name); +} +#endif + #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \ defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64) static void diff --git a/linux-user/strace.list b/linux-user/strace.list index f8899710b5..64d24e16d0 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1288,7 +1288,7 @@ { TARGET_NR_sendmsg, "sendmsg" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_sendto -{ TARGET_NR_sendto, "sendto" , NULL, NULL, NULL }, +{ TARGET_NR_sendto, "sendto" , NULL, print_sendto, NULL }, #endif #ifdef TARGET_NR_setdomainname { TARGET_NR_setdomainname, "setdomainname" , NULL, NULL, NULL }, From patchwork Sat Oct 5 23:33:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 833015 Delivered-To: patch@linaro.org Received: by 2002:adf:8b52:0:b0:367:895a:4699 with SMTP id v18csp1380016wra; Sat, 5 Oct 2024 16:34:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVxoV/M+UsLhZJoXhk7he5OyOYHZKPW/uc8dB9GAP5VUOkCp0DYsivx6kLiKIje4IF1NDoe8w==@linaro.org X-Google-Smtp-Source: AGHT+IHok4wXCWz+KJq4IZjZqs0DJ1QNPjig6OI9WyZeD2aHK9jUa3vf7ZuuNYfGyuTc9UKi9DPd X-Received: by 2002:a05:6214:46a1:b0:6cb:7e1d:c530 with SMTP id 6a1803df08f44-6cb9a4540e7mr133506666d6.19.1728171277140; Sat, 05 Oct 2024 16:34:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728171277; cv=none; d=google.com; s=arc-20240605; b=cHz8/vh06Y7thhQCz5UDiqnv5mBvFUI2EP5fJh+aqb5TpQJ0++lcCJuUjVn4I4J/QW Os1/7y8e1PZ+5HDYDClS/DGrU7ZfRzo/ovph8tjSYUvCpEP8t1oH5mNPmeT7as76yzwi rfJNBNqTrz1LsnfAg6ZBJmz/Zls6CJQaSxglp393NuA8XgW3up26tH3hMb40HvPW4dLK O2rOCoy28kmAEXkon148UBM1M/OuCTG+4u14TvylHyV2EXNEhcsjSafN3weyCuPBJRvb B+YG/fmcuPz0RM6Ki2dV67ExdfrUJEKJMM8zilNRN9CTaiWajYsZYugPy1sPVXx9dHor qilg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=wYBWpQBnXZ27uF3GVfCeocPGkAYUMjeFh2ALsFccVN8=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=kXePtY4BylAP7RpF573a2c8CufuERgQ01dVpFC67ruFfXq/+wh7fezmPoCfrrOCy5C YKSAQnweyIUmmFqbYfBg1aomWZ6UbVwcoxqm8Zu/Is8+QKUFf15RhO38KeQ5m6Xr/nek atRFXjANfP0MmWdytWmUhbqLeyOxAgf3A0GcGPVa079yuuNbh10si36Avx6gO3tFBIx4 VtqTDbriShNop2uz6TKbLb+6mNtwiCnQjlG078Lj8gaXzzGakq6ORxhTGep4BItnRMXF kU8xkDCNL2jgoSYgeimFy3MNimCqg+yVtHuNN2xSOxvS0DOVtlLTN4xdk8p84rrjRaJp 2Y/A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="OFvV/hS8"; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6cba478ba22si30459366d6.467.2024.10.05.16.34.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 Oct 2024 16:34: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="OFvV/hS8"; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sxEHe-0006DP-OF; Sat, 05 Oct 2024 19:33:58 -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 1sxEHc-0006Cx-Px for qemu-devel@nongnu.org; Sat, 05 Oct 2024 19:33:56 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sxEHb-0004EP-9h for qemu-devel@nongnu.org; Sat, 05 Oct 2024 19:33:56 -0400 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-2e0a74ce880so2809062a91.2 for ; Sat, 05 Oct 2024 16:33:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728171234; x=1728776034; darn=nongnu.org; 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=wYBWpQBnXZ27uF3GVfCeocPGkAYUMjeFh2ALsFccVN8=; b=OFvV/hS8dqx0tGgAmQAqfe08dF1Ck76FYvyW7aMS9I/w3VdFZ85rcCSKF6MI+M0lml gvaaVXd+EU1YjIrhk14zkfgizwiXb4yeX08F9TuYbdy/u20qyLziGiDwcPraKSh63lkF L2QT+b09oUV5k1FieW2/i9JH8uy9L9Ugsdm8sX1iB49kGaChgwlnxgbI/CWr4bNvKJYI vOwUXTAEn78RH2ysVxjbWX84PTdGRr3SDhSw/Pnmwl06w0jE9SP+6+hkYrDKFczIvviH 38qTtLP50XpZiQHrKzbmWcQ6sHevxuqRjRzZYG78k2alINmb1e2pywVGQ4RTyxQ8f6MJ T+Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728171234; x=1728776034; 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=wYBWpQBnXZ27uF3GVfCeocPGkAYUMjeFh2ALsFccVN8=; b=FOl9kTUjwKdFnssOXnrZgQtJ3raNyT00wXaFL0BPjC0OYPH3WkpFzSxwaUosNPieyq +6NhVWbva1vhjW0VsJprmiNQjYGCFP86EztcjM2DGsbSgprQvs2/y3czD0sIqg+W3/Nd 06g2ATQZl4LHdKq+wozZjVRbGFwFY+JMuNHZOwZiGfNuybMNV6nCaEEVRjAJuD1yn0De XLGdNZqyTcAh4Kt1OyfGJkLo5wNLx6h2vo/WFPRybvldp3YRMUMNQFy2MrA9ibxCMXMV 0ErgDqV4JTimaD0bxMe+ggdLm6mZew1ZPN295P9IsrddV+cJLsrx0HGtrqmqYcxoDwjw tP/g== X-Gm-Message-State: AOJu0Yy4ATQwKGTj5jaA4Zg8ohCuF7DYzeyzscR23DFl9GuHXtoX9c4s cvRvkwm8tpWQ0cNb8anUt4kSbJ2J+zy9pYn5i522mdlpqKs92qosEXT0SUHeB2fzoKzInkEGfXm f X-Received: by 2002:a17:90a:2ecc:b0:2cf:fe5d:ea12 with SMTP id 98e67ed59e1d1-2e1e626c037mr9183719a91.24.1728171233936; Sat, 05 Oct 2024 16:33:53 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20b129cc2sm2394600a91.51.2024.10.05.16.33.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 16:33:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 10/10] linux-user: Add strace for recvfrom() Date: Sat, 5 Oct 2024 16:33:43 -0700 Message-ID: <20241005233343.503426-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005233343.503426-1-richard.henderson@linaro.org> References: <20241005233343.503426-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Message-ID: <20240807124306.52903-6-philmd@linaro.org> [rth: Do not dump output buffers.] Signed-off-by: Richard Henderson --- linux-user/strace.c | 17 +++++++++++++++++ linux-user/strace.list | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 0263e6a396..c3eb3a2706 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -3142,6 +3142,23 @@ print_bind(CPUArchState *cpu_env, const struct syscallname *name, } #endif +#ifdef TARGET_NR_recvfrom +static void +print_recvfrom(CPUArchState *cpu_env, const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_sockfd(arg0, 0); + print_pointer(arg1, 0); /* output */ + print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); + print_flags(msg_flags, arg3, 0); + print_pointer(arg4, 0); /* output */ + print_pointer(arg5, 1); /* in/out */ + print_syscall_epilogue(name); +} +#endif + #ifdef TARGET_NR_sendto static void print_sendto(CPUArchState *cpu_env, const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index 64d24e16d0..0d69fb3150 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1138,7 +1138,7 @@ { TARGET_NR_recv, "recv" , "%s(%d,%p,%u,%d)", NULL, NULL }, #endif #ifdef TARGET_NR_recvfrom -{ TARGET_NR_recvfrom, "recvfrom" , NULL, NULL, NULL }, +{ TARGET_NR_recvfrom, "recvfrom" , NULL, print_recvfrom, NULL }, #endif #ifdef TARGET_NR_recvmmsg { TARGET_NR_recvmmsg, "recvmmsg" , NULL, NULL, NULL },