From nobody Sat Apr 11 23:02:18 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1773064079; cv=none; d=zohomail.com; s=zohoarc; b=BoqALlLeXTnVbYKnwUGofs567Adql3HSlT6V9DAPrS+ECGBkRMUL3RmS3AMJ5VdNmVoA60tmjf7XzYHeuollE1p4lcrgiRrF06zEbpB13xhCfHIEdx68znoM3SZ/9KCm0whz3kaVCf8ZriTK75LdMu0HG2iemJCzLN8+yjQdBH4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773064079; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=uSUoduXt1McMZ+xp4HI8Tm+6BrIMPYdhMvyXUl5DEIg=; b=ntwVAfutv2T6jFMf9hbfLH4ET+7yMfv0rQNy13ToLnHZVmyVWZWElQ0u7hM/hKSB9fh0rjLrsN97w5UwgxWmNZ+NiSdR/jAmXh9p4dlTCyuj7U3zmv50WOgDiANY/iL5t74zyxlg31+Y9nQ7JdYhUqebcYjJ4J7FmSKNJqxNzW4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1773064079972939.90776694951; Mon, 9 Mar 2026 06:47:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vzaxd-00043R-Hg; Mon, 09 Mar 2026 09:47: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 1vzaxU-0003yP-2u for qemu-devel@nongnu.org; Mon, 09 Mar 2026 09:47:47 -0400 Received: from sea.source.kernel.org ([172.234.252.31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vzaxP-000673-LO for qemu-devel@nongnu.org; Mon, 09 Mar 2026 09:47:43 -0400 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 8051140506 for ; Mon, 9 Mar 2026 13:47:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCC1DC4CEF7 for ; Mon, 9 Mar 2026 13:47:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773064035; bh=0nM1s+NQvWZ8mFk4qsfcfN21HkyWkiji/p4/PrOht4w=; h=From:To:Subject:Date:In-Reply-To:References:From; b=F72Qj9JUxns3svy6xVNoWSVVp93fryi3ieLMLSV8UA2dBFmXyCDQaCCpxx12F7NVV 3rwSqcJDmFhoCdTRjLYY/YjTEZBkUL4GPiZhbg0JKlaAvy8LmQJhkv8CcjkadNdwht GGs0TH0m8vzqt36rVhyZp+o3dTxfxcKskldNP1jYNWGg1kN0HFbxN3BwVFxbimKw7N 685miERP50NaUwM4nhmItFG6uBvSFd39Yd3OZbqzxRPsBSYY/zBx6NDvA8Vc80heMQ f9I/DOWKFEjTKFF4MJcMmjWDmLUkoADo/CGmAYfLTJoTmfk7hM14gXDyYuHkR1p/L7 2OQS27LXTGdVg== From: Helge Deller To: qemu-devel@nongnu.org Subject: [PULL 01/10] linux-user/strace: fix printing of file offsets Date: Mon, 9 Mar 2026 14:47:02 +0100 Message-ID: <20260309134711.5312-2-deller@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260309134711.5312-1-deller@kernel.org> References: <20260309134711.5312-1-deller@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=172.234.252.31; envelope-from=deller@kernel.org; helo=sea.source.kernel.org X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1773064081591158500 From: Jean-Christian C=C3=8ERSTEA Previously, 64-bit file offsets (loff_t) were printed using `print_raw_para= m()` function, which led to silent truncation of the upper part. This commit fix= es this issue by adding two helper functions: 1. print_file_offset32(): prints 32-bit file offsets (off_t) 2. print_file_offset64(): prints 64-bit file offsets (loff_t) Changelog v2: 1. Make `print_file_offset32()` static. 2. Use `last` parameter in `print_file_offset32()`. 3. Rename `low` and `high` parameters of `print_file_offset64()` to `word0`, `word1` respectively 4. Convert `last` to bool for `print_file_offset[32,64]()` 5. Use `PRId64` instead of `PRIu64` for `print_file_offset64()` 6. Fix `print__llseek()` Signed-off-by: Jean-Christian C=C3=8ERSTEA Reviewed-by: Helge Deller Signed-off-by: Helge Deller --- linux-user/strace.c | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index ca67cfd09d..d253b522bf 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -85,6 +85,10 @@ UNUSED static void print_enums(const struct enums *, abi= _long, int); UNUSED static void print_at_dirfd(abi_long, int); UNUSED static void print_file_mode(abi_long, int); UNUSED static void print_open_flags(abi_long, int); +UNUSED static void print_file_offset32(abi_long offset, bool last); +UNUSED static void print_file_offset64(abi_long word0, + abi_long word1, + bool last); UNUSED static void print_syscall_prologue(const struct syscallname *); UNUSED static void print_syscall_epilogue(const struct syscallname *); UNUSED static void print_string(abi_long, int); @@ -1664,6 +1668,20 @@ print_open_flags(abi_long flags, int last) print_flags(open_flags, flags, last); } =20 +/* Prints 32-bit file offset (off_t) */ +static void +print_file_offset32(abi_long offset, bool last) +{ + print_raw_param(TARGET_ABI_FMT_ld, offset, last); +} + +/* Prints 64-bit file offset (loff_t) */ +static void +print_file_offset64(abi_long word0, abi_long word1, bool last) +{ + print_raw_param64("%" PRId64, target_offset64(word0, word1), last); +} + static void print_syscall_prologue(const struct syscallname *sc) { @@ -2256,11 +2274,13 @@ print_fallocate(CPUArchState *cpu_env, const struct= syscallname *name, print_raw_param("%d", arg0, 0); print_flags(falloc_flags, arg1, 0); #if TARGET_ABI_BITS =3D=3D 32 - print_raw_param("%" PRIu64, target_offset64(arg2, arg3), 0); - print_raw_param("%" PRIu64, target_offset64(arg4, arg5), 1); + /* On 32-bit targets, two registers are used for `loff_t` */ + print_file_offset64(arg2, arg3, false); + print_file_offset64(arg4, arg5, true); #else - print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); - print_raw_param(TARGET_ABI_FMT_ld, arg3, 1); + /* On 64-bit targets, one register is used for `loff_t` */ + print_file_offset64(arg2, 0, false); + print_file_offset64(arg3, 0, true); #endif print_syscall_epilogue(name); } @@ -2666,8 +2686,7 @@ print__llseek(CPUArchState *cpu_env, const struct sys= callname *name, const char *whence =3D "UNKNOWN"; print_syscall_prologue(name); print_raw_param("%d", arg0, 0); - print_raw_param("%ld", arg1, 0); - print_raw_param("%ld", arg2, 0); + print_file_offset64(arg1, arg2, false); print_pointer(arg3, 0); switch(arg4) { case SEEK_SET: whence =3D "SEEK_SET"; break; @@ -2688,7 +2707,7 @@ print_lseek(CPUArchState *cpu_env, const struct sysca= llname *name, { print_syscall_prologue(name); print_raw_param("%d", arg0, 0); - print_raw_param(TARGET_ABI_FMT_ld, arg1, 0); + print_file_offset32(arg1, false); switch (arg2) { case SEEK_SET: qemu_log("SEEK_SET"); break; @@ -2719,7 +2738,7 @@ print_truncate(CPUArchState *cpu_env, const struct sy= scallname *name, { print_syscall_prologue(name); print_string(arg0, 0); - print_raw_param(TARGET_ABI_FMT_ld, arg1, 1); + print_file_offset32(arg1, true); print_syscall_epilogue(name); } #endif @@ -2736,7 +2755,7 @@ print_truncate64(CPUArchState *cpu_env, const struct = syscallname *name, arg1 =3D arg2; arg2 =3D arg3; } - print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1); + print_file_offset64(arg1, arg2, true); print_syscall_epilogue(name); } #endif @@ -2753,7 +2772,7 @@ print_ftruncate64(CPUArchState *cpu_env, const struct= syscallname *name, arg1 =3D arg2; arg2 =3D arg3; } - print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1); + print_file_offset64(arg1, arg2, true); print_syscall_epilogue(name); } #endif @@ -3308,7 +3327,7 @@ print_stat(CPUArchState *cpu_env, const struct syscal= lname *name, print_syscall_epilogue(name); } #define print_lstat print_stat -#define print_stat64 print_stat +#define print_stat64 print_stat #define print_lstat64 print_stat #endif =20 @@ -4302,7 +4321,7 @@ print_pread64(CPUArchState *cpu_env, const struct sys= callname *name, print_raw_param("%d", arg0, 0); print_pointer(arg1, 0); print_raw_param("%d", arg2, 0); - print_raw_param("%" PRIu64, target_offset64(arg3, arg4), 1); + print_file_offset64(arg3, arg4, true); print_syscall_epilogue(name); } #endif --=20 2.53.0