* [PATCH] linux-user: fix ioctl() arguments printing in strace support
@ 2022-05-17 18:06 Yan Cangang
0 siblings, 0 replies; only message in thread
From: Yan Cangang @ 2022-05-17 18:06 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, Yan Cangang
When both of the following conditions are satisfied, ioctl() arguments
printing in strace support is not working:
- highest bit of ioctl() request command is 1
- sizeof abi_long is 8 bytes
print_ioctl() and print_syscall_ret_ioctl() find IOCTLEntry by this way:
/* ie->target_cmd is int, arg1 is abi_long, both are signed */
for (ie = ioctl_entries; ie->target_cmd != 0; ie++)
if (ie->target_cmd == arg1)
break;
Operator "==" will convert target_cmd to abi_long by sign extension,
resulting in a negative number, will not match any ioctl request number.
This patch simply changes type of target_cmd to unsigned int, avoids sign
extension. ioctl command values are 32-bit constants, explain highest bit
as sign bit is pointless.
Signed-off-by: Yan Cangang <nalanzeyu@gmail.com>
---
linux-user/user-internals.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h
index ddc260e465..550d16e2dd 100644
--- a/linux-user/user-internals.h
+++ b/linux-user/user-internals.h
@@ -35,7 +35,7 @@ typedef abi_long do_ioctl_fn(const IOCTLEntry *ie, uint8_t *buf_temp,
int fd, int cmd, abi_long arg);
struct IOCTLEntry {
- int target_cmd;
+ unsigned int target_cmd;
unsigned int host_cmd;
const char *name;
int access;
--
2.36.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-17 18:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-17 18:06 [PATCH] linux-user: fix ioctl() arguments printing in strace support Yan Cangang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).