qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] linux-user: fix ioctl() arguments printing in strace support


From: Yan Cangang
Subject: [PATCH] linux-user: fix ioctl() arguments printing in strace support
Date: Wed, 18 May 2022 02:06:05 +0800

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]