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: 13823614 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D89C7CFB422 for ; Sat, 5 Oct 2024 23:35:48 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IFGNI/Z26syY85g+h1OOCJphecV161enpewfMn2pQrkHY2i/yZYQ0TggOQMhWb/DW6qTJFCKQ== 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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: 13823615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1896CCFB422 for ; Sat, 5 Oct 2024 23:36:01 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IHPygXoAfODKkVSyX78r2O0tORNeO6vaVpX19zvFu5DbI+hpqVrp7ylmK9LKjpPfMFrCyFZLw== 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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: 13823610 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C2C11CFB443 for ; Sat, 5 Oct 2024 23:34:38 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IEp7liJqbo7AudEJk8nCXmc+2Ba5jkCHGkf82UKMrq9ItXX/pJK9zoqjbGm3iRXsIj80VRIBw== 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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: 13823608 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 59E72CFB43F for ; Sat, 5 Oct 2024 23:34:37 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IEOw/6dIcLBsEyYUyR6rq08Ruu3YaRALA0AmIF4zi8JczHIvLKK+xGxGsJXo/+LjI3yIBam7g== 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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: 13823616 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EA66ACFB421 for ; Sat, 5 Oct 2024 23:36:01 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IGq3p9VqELP9PXjvI3r57OJOmk0cuVTkV7kNU/+hzbRvy2+yy7SLLjWJpVurDnbDVgzag14mA== 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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: 13823607 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 57C4FCFB43C for ; Sat, 5 Oct 2024 23:34:37 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IHZ7lB2HBEEaSoCsqQ4bCfcwXtOkm38qYLhjb19Dq3r9lJ21H5uCuGJRoHYTOLEyZD2AEnw7Q== 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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: 13823606 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5BB58CFB422 for ; Sat, 5 Oct 2024 23:34:37 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IFSKRa4SE/ADCYJbfVsk2d/P2PVNDs0ikRJYMpdCWHpJvOdbUf6ioFv4Z3/DgLGjCJ5BNkB8g== 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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: 13823612 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 58748CFB421 for ; Sat, 5 Oct 2024 23:35:42 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IHeVUFhAOKjMoVYlMYITPl9jlUwiiBBQyqNrfmAXoHVx70TtF0cwi5jKySCxbuREZur2DqfIg== 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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: 13823611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7793BCFB421 for ; Sat, 5 Oct 2024 23:35:31 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IEbMPSNADjINV+ga8t4OoJ/mPVhKkO64FDtEbO//PvE2yvPmqTEGOqn57vGgYyzm0AHQor0VQ== 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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: 13823609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 55EF0CFB421 for ; Sat, 5 Oct 2024 23:34:37 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IFSRGaJlojSBD+v0xl0uQbyCy8P43U/QiMO11QfeXC2gEE43XqB4Ik0jJq+lt8kUtnx8FdtDA== 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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 },