qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v6 0/8] linux-user: strace improvements
@ 2019-09-08  6:15 Philippe Mathieu-Daudé
  2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 1/8] linux-user/strace: Display invalid pointer in print_timeval() Philippe Mathieu-Daudé
                   ` (8 more replies)
  0 siblings, 9 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-09-08  6:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Guido Günther, Riku Voipio, Laurent Vivier,
	Philippe Mathieu-Daudé

Hi Laurent,

Few patches I'v been writting while trying to figure out this issue:
http://lists.nongnu.org/archive/html/qemu-arm/2018-01/msg00514.html

As usual with linux-user files, this series will trigger some checkpatch
benign warnings.

Regards,

Phil.

Since v5:
- dropped 'Verify recvfrom(addr)' since failing LTP testsuite (see [1])
- also define print_sockfd() for bind() (patches #6 and #7)

Since v4:
- rebased on master (no change)

Since v3:
- addressed Laurent comments
- added print_sockfd()
- removed the print_sockaddr_ptr() patch, also the two
  getsockname()/recvfrom() patches for after 3.0.

Since v2:
- display invalid pointer in print_timeval() and print_timezone()
- do not display gettimeofday() arguments

Since v1:
- addressed Laurent comments
- added 'last' argument to print_sockaddr()
- reordered series, so patches already correct can get applied directly
- dropped "linux-user/syscall: simplify recvfrom()" for now

v1: http://lists.nongnu.org/archive/html/qemu-devel/2018-01/msg05855.html
v2: http://lists.nongnu.org/archive/html/qemu-devel/2018-06/msg08216.html
v3: http://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg00411.html
v5: https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg02067.html
[1] https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg02807.html

Philippe Mathieu-Daudé (8):
  linux-user/strace: Display invalid pointer in print_timeval()
  linux-user/strace: Add print_timezone()
  linux-user/strace: Improve settimeofday()
  linux-user/syscall: Introduce target_sockaddr_nl
  linux-user/strace: Dump AF_NETLINK sockaddr content
  linux-user/strace: Add print_sockfd()
  linux-user/strace: Improve bind() output
  linux-user/strace: Let print_sockaddr() have a 'last' argument

 linux-user/strace.c       | 121 ++++++++++++++++++++++++++++++++++----
 linux-user/strace.list    |   4 +-
 linux-user/syscall.c      |   6 +-
 linux-user/syscall_defs.h |   7 +++
 4 files changed, 121 insertions(+), 17 deletions(-)

-- 
2.20.1



^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Qemu-devel] [PATCH v6 1/8] linux-user/strace: Display invalid pointer in print_timeval()
  2019-09-08  6:15 [Qemu-devel] [PATCH v6 0/8] linux-user: strace improvements Philippe Mathieu-Daudé
@ 2019-09-08  6:15 ` Philippe Mathieu-Daudé
  2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 2/8] linux-user/strace: Add print_timezone() Philippe Mathieu-Daudé
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-09-08  6:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Guido Günther, Riku Voipio, Laurent Vivier,
	Philippe Mathieu-Daudé

Suggested-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 linux-user/strace.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index c80e93b5db..f326c357a2 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -1243,8 +1243,10 @@ print_timeval(abi_ulong tv_addr, int last)
         struct target_timeval *tv;
 
         tv = lock_user(VERIFY_READ, tv_addr, sizeof(*tv), 1);
-        if (!tv)
+        if (!tv) {
+            print_pointer(tv_addr, last);
             return;
+        }
         gemu_log("{" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "}%s",
             tswapal(tv->tv_sec), tswapal(tv->tv_usec), get_comma(last));
         unlock_user(tv, tv_addr, 0);
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Qemu-devel] [PATCH v6 2/8] linux-user/strace: Add print_timezone()
  2019-09-08  6:15 [Qemu-devel] [PATCH v6 0/8] linux-user: strace improvements Philippe Mathieu-Daudé
  2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 1/8] linux-user/strace: Display invalid pointer in print_timeval() Philippe Mathieu-Daudé
@ 2019-09-08  6:15 ` Philippe Mathieu-Daudé
  2019-09-10  8:51   ` Laurent Vivier
  2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 3/8] linux-user/strace: Improve settimeofday() Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-09-08  6:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Guido Günther, Riku Voipio, Laurent Vivier,
	Philippe Mathieu-Daudé

Suggested-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
checkpatch error:
ERROR: storage class should be at the beginning of the declaration
---
 linux-user/strace.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index f326c357a2..5ee9d62c25 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -63,6 +63,7 @@ UNUSED static void print_string(abi_long, int);
 UNUSED static void print_buf(abi_long addr, abi_long len, int last);
 UNUSED static void print_raw_param(const char *, abi_long, int);
 UNUSED static void print_timeval(abi_ulong, int);
+UNUSED static void print_timezone(abi_ulong, int);
 UNUSED static void print_number(abi_long, int);
 UNUSED static void print_signal(abi_ulong, int);
 UNUSED static void print_sockaddr(abi_ulong addr, abi_long addrlen);
@@ -1254,6 +1255,26 @@ print_timeval(abi_ulong tv_addr, int last)
         gemu_log("NULL%s", get_comma(last));
 }
 
+static void
+print_timezone(abi_ulong tz_addr, int last)
+{
+    if (tz_addr) {
+        struct target_timezone *tz;
+
+        tz = lock_user(VERIFY_READ, tz_addr, sizeof(*tz), 1);
+        if (!tz) {
+            print_pointer(tz_addr, last);
+            return;
+        }
+        gemu_log("{" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "}%s",
+                 tswapal(tz->tz_minuteswest), tswapal(tz->tz_dsttime),
+                 get_comma(last));
+        unlock_user(tz, tz_addr, 0);
+    } else {
+        gemu_log("NULL%s", get_comma(last));
+    }
+}
+
 #undef UNUSED
 
 #ifdef TARGET_NR_accept
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Qemu-devel] [PATCH v6 3/8] linux-user/strace: Improve settimeofday()
  2019-09-08  6:15 [Qemu-devel] [PATCH v6 0/8] linux-user: strace improvements Philippe Mathieu-Daudé
  2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 1/8] linux-user/strace: Display invalid pointer in print_timeval() Philippe Mathieu-Daudé
  2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 2/8] linux-user/strace: Add print_timezone() Philippe Mathieu-Daudé
@ 2019-09-08  6:15 ` Philippe Mathieu-Daudé
  2019-09-10  8:30   ` Laurent Vivier
  2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 4/8] linux-user/syscall: Introduce target_sockaddr_nl Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-09-08  6:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Guido Günther, Riku Voipio, Laurent Vivier,
	Philippe Mathieu-Daudé

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-By: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/strace.c    | 13 +++++++++++++
 linux-user/strace.list |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index 5ee9d62c25..dcf843b360 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -1584,6 +1584,19 @@ print_futimesat(const struct syscallname *name,
 }
 #endif
 
+#ifdef TARGET_NR_settimeofday
+static void
+print_settimeofday(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_timeval(arg0, 0);
+    print_timezone(arg1, 1);
+    print_syscall_epilogue(name);
+}
+#endif
+
 #ifdef TARGET_NR_link
 static void
 print_link(const struct syscallname *name,
diff --git a/linux-user/strace.list b/linux-user/strace.list
index 63a946642d..1ff9168369 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -1345,7 +1345,7 @@
 { TARGET_NR_set_tid_address, "set_tid_address" , NULL, NULL, NULL },
 #endif
 #ifdef TARGET_NR_settimeofday
-{ TARGET_NR_settimeofday, "settimeofday" , NULL, NULL, NULL },
+{ TARGET_NR_settimeofday, "settimeofday" , NULL, print_settimeofday, NULL },
 #endif
 #ifdef TARGET_NR_setuid
 { TARGET_NR_setuid, "setuid" , NULL, NULL, NULL },
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Qemu-devel] [PATCH v6 4/8] linux-user/syscall: Introduce target_sockaddr_nl
  2019-09-08  6:15 [Qemu-devel] [PATCH v6 0/8] linux-user: strace improvements Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 3/8] linux-user/strace: Improve settimeofday() Philippe Mathieu-Daudé
@ 2019-09-08  6:15 ` Philippe Mathieu-Daudé
  2019-09-09 14:22   ` Laurent Vivier
  2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 5/8] linux-user/strace: Dump AF_NETLINK sockaddr content Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-09-08  6:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Guido Günther, Riku Voipio, Laurent Vivier,
	Philippe Mathieu-Daudé

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-By: Guido Günther <agx@sigxcpu.org>
---
 linux-user/syscall.c      | 6 ++++--
 linux-user/syscall_defs.h | 7 +++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8b41a03901..5128312db5 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1494,8 +1494,10 @@ static inline abi_long host_to_target_sockaddr(abi_ulong target_addr,
         sizeof(target_saddr->sa_family)) {
         target_saddr->sa_family = tswap16(addr->sa_family);
     }
-    if (addr->sa_family == AF_NETLINK && len >= sizeof(struct sockaddr_nl)) {
-        struct sockaddr_nl *target_nl = (struct sockaddr_nl *)target_saddr;
+    if (addr->sa_family == AF_NETLINK &&
+        len >= sizeof(struct target_sockaddr_nl)) {
+        struct target_sockaddr_nl *target_nl =
+               (struct target_sockaddr_nl *)target_saddr;
         target_nl->nl_pid = tswap32(target_nl->nl_pid);
         target_nl->nl_groups = tswap32(target_nl->nl_groups);
     } else if (addr->sa_family == AF_PACKET) {
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 0662270300..fcedd0d0fb 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -153,6 +153,13 @@ struct target_sockaddr_un {
     uint8_t sun_path[108];
 };
 
+struct target_sockaddr_nl {
+    uint16_t nl_family;     /* AF_NETLINK */
+    uint16_t __pad;
+    uint32_t nl_pid;
+    uint32_t nl_groups;
+};
+
 struct target_in_addr {
     uint32_t s_addr; /* big endian */
 };
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Qemu-devel] [PATCH v6 5/8] linux-user/strace: Dump AF_NETLINK sockaddr content
  2019-09-08  6:15 [Qemu-devel] [PATCH v6 0/8] linux-user: strace improvements Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 4/8] linux-user/syscall: Introduce target_sockaddr_nl Philippe Mathieu-Daudé
@ 2019-09-08  6:15 ` Philippe Mathieu-Daudé
  2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 6/8] linux-user/strace: Add print_sockfd() Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-09-08  6:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Guido Günther, Riku Voipio, Laurent Vivier,
	Philippe Mathieu-Daudé

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-By: Guido Günther <agx@sigxcpu.org>
---
 linux-user/strace.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index dcf843b360..77d7f6a97a 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -8,6 +8,7 @@
 #include <arpa/inet.h>
 #include <netinet/tcp.h>
 #include <linux/if_packet.h>
+#include <linux/netlink.h>
 #include <sched.h>
 #include "qemu.h"
 
@@ -398,6 +399,12 @@ print_sockaddr(abi_ulong addr, abi_long addrlen)
             gemu_log("}");
             break;
         }
+        case AF_NETLINK: {
+            struct target_sockaddr_nl *nl = (struct target_sockaddr_nl *)sa;
+            gemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u}",
+                     nl->nl_pid, nl->nl_groups);
+            break;
+        }
         default:
             gemu_log("{sa_family=%d, sa_data={", sa->sa_family);
             for (i = 0; i < 13; i++) {
@@ -424,6 +431,9 @@ print_socket_domain(int domain)
     case PF_INET:
         gemu_log("PF_INET");
         break;
+    case PF_NETLINK:
+        gemu_log("PF_NETLINK");
+        break;
     case PF_PACKET:
         gemu_log("PF_PACKET");
         break;
@@ -473,6 +483,33 @@ print_socket_protocol(int domain, int type, int protocol)
         return;
     }
 
+    if (domain == PF_NETLINK) {
+        switch (protocol) {
+        case NETLINK_ROUTE:
+            gemu_log("NETLINK_ROUTE");
+            break;
+        case NETLINK_AUDIT:
+            gemu_log("NETLINK_AUDIT");
+            break;
+        case NETLINK_NETFILTER:
+            gemu_log("NETLINK_NETFILTER");
+            break;
+        case NETLINK_KOBJECT_UEVENT:
+            gemu_log("NETLINK_KOBJECT_UEVENT");
+            break;
+        case NETLINK_RDMA:
+            gemu_log("NETLINK_RDMA");
+            break;
+        case NETLINK_CRYPTO:
+            gemu_log("NETLINK_CRYPTO");
+            break;
+        default:
+            gemu_log("%d", protocol);
+            break;
+        }
+        return;
+    }
+
     switch (protocol) {
     case IPPROTO_IP:
         gemu_log("IPPROTO_IP");
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Qemu-devel] [PATCH v6 6/8] linux-user/strace: Add print_sockfd()
  2019-09-08  6:15 [Qemu-devel] [PATCH v6 0/8] linux-user: strace improvements Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 5/8] linux-user/strace: Dump AF_NETLINK sockaddr content Philippe Mathieu-Daudé
@ 2019-09-08  6:15 ` Philippe Mathieu-Daudé
  2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 7/8] linux-user/strace: Improve bind() output Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-09-08  6:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Guido Günther, Riku Voipio, Laurent Vivier,
	Philippe Mathieu-Daudé

Extract common print_sockfd() from various socket related syscalls.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
v6: use another ifdef TARGET_NR_socketcall
---
 linux-user/strace.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index 77d7f6a97a..8a1df12e67 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -1710,6 +1710,15 @@ print_socket(const struct syscallname *name,
 
 #if defined(TARGET_NR_socketcall)
 
+static void print_sockfd(abi_long sockfd, int last)
+{
+    print_raw_param(TARGET_ABI_FMT_ld, sockfd, last);
+}
+
+#endif
+
+#if defined(TARGET_NR_socketcall)
+
 #define get_user_ualx(x, gaddr, idx) \
         get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long))
 
@@ -1742,7 +1751,7 @@ static void do_print_sockaddr(const char *name, abi_long arg1)
     get_user_ualx(addrlen, arg1, 2);
 
     gemu_log("%s(", name);
-    print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
+    print_sockfd(sockfd, 0);
     print_sockaddr(addr, addrlen);
     gemu_log(")");
 }
@@ -1755,7 +1764,7 @@ static void do_print_listen(const char *name, abi_long arg1)
     get_user_ualx(backlog, arg1, 1);
 
     gemu_log("%s(", name);
-    print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
+    print_sockfd(sockfd, 0);
     print_raw_param(TARGET_ABI_FMT_ld, backlog, 1);
     gemu_log(")");
 }
@@ -1790,7 +1799,7 @@ static void do_print_sendrecv(const char *name, abi_long arg1)
     get_user_ualx(flags, arg1, 3);
 
     gemu_log("%s(", name);
-    print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
+    print_sockfd(sockfd, 0);
     print_buf(msg, len, 0);
     print_raw_param(TARGET_ABI_FMT_ld, len, 0);
     print_flags(msg_flags, flags, 1);
@@ -1809,7 +1818,7 @@ static void do_print_msgaddr(const char *name, abi_long arg1)
     get_user_ualx(addrlen, arg1, 5);
 
     gemu_log("%s(", name);
-    print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
+    print_sockfd(sockfd, 0);
     print_buf(msg, len, 0);
     print_raw_param(TARGET_ABI_FMT_ld, len, 0);
     print_flags(msg_flags, flags, 0);
@@ -1825,7 +1834,7 @@ static void do_print_shutdown(const char *name, abi_long arg1)
     get_user_ualx(how, arg1, 1);
 
     gemu_log("shutdown(");
-    print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
+    print_sockfd(sockfd, 0);
     switch (how) {
     case SHUT_RD:
         gemu_log("SHUT_RD");
@@ -1852,7 +1861,7 @@ static void do_print_msg(const char *name, abi_long arg1)
     get_user_ualx(flags, arg1, 2);
 
     gemu_log("%s(", name);
-    print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
+    print_sockfd(sockfd, 0);
     print_pointer(msg, 0);
     print_flags(msg_flags, flags, 1);
     gemu_log(")");
@@ -1869,7 +1878,7 @@ static void do_print_sockopt(const char *name, abi_long arg1)
     get_user_ualx(optlen, arg1, 4);
 
     gemu_log("%s(", name);
-    print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
+    print_sockfd(sockfd, 0);
     switch (level) {
     case SOL_TCP:
         gemu_log("SOL_TCP,");
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Qemu-devel] [PATCH v6 7/8] linux-user/strace: Improve bind() output
  2019-09-08  6:15 [Qemu-devel] [PATCH v6 0/8] linux-user: strace improvements Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 6/8] linux-user/strace: Add print_sockfd() Philippe Mathieu-Daudé
@ 2019-09-08  6:15 ` Philippe Mathieu-Daudé
  2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 8/8] linux-user/strace: Let print_sockaddr() have a 'last' argument Philippe Mathieu-Daudé
  2019-09-08  6:28 ` [Qemu-devel] [PATCH v6 0/8] linux-user: strace improvements no-reply
  8 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-09-08  6:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Guido Günther, Riku Voipio, Laurent Vivier,
	Philippe Mathieu-Daudé

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-By: Guido Günther <agx@sigxcpu.org>
---
v6: use TARGET_NR_socketcall || TARGET_NR_bind (lvivier)
---
 linux-user/strace.c    | 15 ++++++++++++++-
 linux-user/strace.list |  2 +-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index 8a1df12e67..a1e971ac8a 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -1708,7 +1708,7 @@ print_socket(const struct syscallname *name,
 
 #endif
 
-#if defined(TARGET_NR_socketcall)
+#if defined(TARGET_NR_socketcall) || defined(TARGET_NR_bind)
 
 static void print_sockfd(abi_long sockfd, int last)
 {
@@ -2055,6 +2055,19 @@ print_socketcall(const struct syscallname *name,
 }
 #endif
 
+#if defined(TARGET_NR_bind)
+static void
+print_bind(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_sockaddr(arg1, arg2, 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 1ff9168369..957aa720af 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -41,7 +41,7 @@
 { TARGET_NR_bdflush, "bdflush" , NULL, NULL, NULL },
 #endif
 #ifdef TARGET_NR_bind
-{ TARGET_NR_bind, "bind" , NULL, NULL, NULL },
+{ TARGET_NR_bind, "bind" , NULL, print_bind, NULL },
 #endif
 #ifdef TARGET_NR_bpf
 { TARGET_NR_bpf, "bpf" , NULL, NULL, NULL },
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Qemu-devel] [PATCH v6 8/8] linux-user/strace: Let print_sockaddr() have a 'last' argument
  2019-09-08  6:15 [Qemu-devel] [PATCH v6 0/8] linux-user: strace improvements Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 7/8] linux-user/strace: Improve bind() output Philippe Mathieu-Daudé
@ 2019-09-08  6:15 ` Philippe Mathieu-Daudé
  2019-09-08  6:28 ` [Qemu-devel] [PATCH v6 0/8] linux-user: strace improvements no-reply
  8 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-09-08  6:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Guido Günther, Riku Voipio, Laurent Vivier,
	Philippe Mathieu-Daudé

If the format is not the syscall last argument, a comma is append.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
---
checkpatch error:
ERROR: storage class should be at the beginning of the declaration
---
 linux-user/strace.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index a1e971ac8a..a297f59efd 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -67,7 +67,7 @@ UNUSED static void print_timeval(abi_ulong, int);
 UNUSED static void print_timezone(abi_ulong, int);
 UNUSED static void print_number(abi_long, int);
 UNUSED static void print_signal(abi_ulong, int);
-UNUSED static void print_sockaddr(abi_ulong addr, abi_long addrlen);
+UNUSED static void print_sockaddr(abi_ulong addr, abi_long addrlen, int);
 UNUSED static void print_socket_domain(int domain);
 UNUSED static void print_socket_type(int type);
 UNUSED static void print_socket_protocol(int domain, int type, int protocol);
@@ -336,7 +336,7 @@ static void print_siginfo(const target_siginfo_t *tinfo)
 }
 
 static void
-print_sockaddr(abi_ulong addr, abi_long addrlen)
+print_sockaddr(abi_ulong addr, abi_long addrlen, int last)
 {
     struct target_sockaddr *sa;
     int i;
@@ -418,7 +418,7 @@ print_sockaddr(abi_ulong addr, abi_long addrlen)
     } else {
         print_raw_param("0x"TARGET_ABI_FMT_lx, addr, 0);
     }
-    gemu_log(", "TARGET_ABI_FMT_ld, addrlen);
+    gemu_log(", "TARGET_ABI_FMT_ld"%s", addrlen, get_comma(last));
 }
 
 static void
@@ -1752,7 +1752,7 @@ static void do_print_sockaddr(const char *name, abi_long arg1)
 
     gemu_log("%s(", name);
     print_sockfd(sockfd, 0);
-    print_sockaddr(addr, addrlen);
+    print_sockaddr(addr, addrlen, 0);
     gemu_log(")");
 }
 
@@ -1822,7 +1822,7 @@ static void do_print_msgaddr(const char *name, abi_long arg1)
     print_buf(msg, len, 0);
     print_raw_param(TARGET_ABI_FMT_ld, len, 0);
     print_flags(msg_flags, flags, 0);
-    print_sockaddr(addr, addrlen);
+    print_sockaddr(addr, addrlen, 0);
     gemu_log(")");
 }
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH v6 0/8] linux-user: strace improvements
  2019-09-08  6:15 [Qemu-devel] [PATCH v6 0/8] linux-user: strace improvements Philippe Mathieu-Daudé
                   ` (7 preceding siblings ...)
  2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 8/8] linux-user/strace: Let print_sockaddr() have a 'last' argument Philippe Mathieu-Daudé
@ 2019-09-08  6:28 ` no-reply
  8 siblings, 0 replies; 16+ messages in thread
From: no-reply @ 2019-09-08  6:28 UTC (permalink / raw)
  To: f4bug; +Cc: agx, riku.voipio, qemu-devel, f4bug, laurent

Patchew URL: https://patchew.org/QEMU/20190908061543.25136-1-f4bug@amsat.org/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Message-id: 20190908061543.25136-1-f4bug@amsat.org
Subject: [Qemu-devel] [PATCH v6 0/8] linux-user: strace improvements
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
d2015e2 linux-user/strace: Let print_sockaddr() have a 'last' argument
4c7df4b linux-user/strace: Improve bind() output
6523a43 linux-user/strace: Add print_sockfd()
073f6fd linux-user/strace: Dump AF_NETLINK sockaddr content
2abd312 linux-user/syscall: Introduce target_sockaddr_nl
0f5e8ed linux-user/strace: Improve settimeofday()
19233df linux-user/strace: Add print_timezone()
be098a1 linux-user/strace: Display invalid pointer in print_timeval()

=== OUTPUT BEGIN ===
1/8 Checking commit be098a139807 (linux-user/strace: Display invalid pointer in print_timeval())
2/8 Checking commit 19233df8c5da (linux-user/strace: Add print_timezone())
ERROR: storage class should be at the beginning of the declaration
#19: FILE: linux-user/strace.c:66:
+UNUSED static void print_timezone(abi_ulong, int);

total: 1 errors, 0 warnings, 33 lines checked

Patch 2/8 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

3/8 Checking commit 0f5e8ed953bf (linux-user/strace: Improve settimeofday())
4/8 Checking commit 2abd31260722 (linux-user/syscall: Introduce target_sockaddr_nl)
5/8 Checking commit 073f6fdfe338 (linux-user/strace: Dump AF_NETLINK sockaddr content)
6/8 Checking commit 6523a43281c4 (linux-user/strace: Add print_sockfd())
7/8 Checking commit 4c7df4b3b8c7 (linux-user/strace: Improve bind() output)
8/8 Checking commit d2015e24e08c (linux-user/strace: Let print_sockaddr() have a 'last' argument)
ERROR: storage class should be at the beginning of the declaration
#22: FILE: linux-user/strace.c:70:
+UNUSED static void print_sockaddr(abi_ulong addr, abi_long addrlen, int);

total: 1 errors, 0 warnings, 40 lines checked

Patch 8/8 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20190908061543.25136-1-f4bug@amsat.org/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH v6 4/8] linux-user/syscall: Introduce target_sockaddr_nl
  2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 4/8] linux-user/syscall: Introduce target_sockaddr_nl Philippe Mathieu-Daudé
@ 2019-09-09 14:22   ` Laurent Vivier
  2019-09-11 19:34     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 16+ messages in thread
From: Laurent Vivier @ 2019-09-09 14:22 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Guido Günther, Riku Voipio

Le 08/09/2019 à 08:15, Philippe Mathieu-Daudé a écrit :
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Tested-By: Guido Günther <agx@sigxcpu.org>
> ---
>  linux-user/syscall.c      | 6 ++++--
>  linux-user/syscall_defs.h | 7 +++++++
>  2 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 8b41a03901..5128312db5 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -1494,8 +1494,10 @@ static inline abi_long host_to_target_sockaddr(abi_ulong target_addr,
>          sizeof(target_saddr->sa_family)) {
>          target_saddr->sa_family = tswap16(addr->sa_family);
>      }
> -    if (addr->sa_family == AF_NETLINK && len >= sizeof(struct sockaddr_nl)) {
> -        struct sockaddr_nl *target_nl = (struct sockaddr_nl *)target_saddr;
> +    if (addr->sa_family == AF_NETLINK &&
> +        len >= sizeof(struct target_sockaddr_nl)) {
> +        struct target_sockaddr_nl *target_nl =
> +               (struct target_sockaddr_nl *)target_saddr;
>          target_nl->nl_pid = tswap32(target_nl->nl_pid);
>          target_nl->nl_groups = tswap32(target_nl->nl_groups);
>      } else if (addr->sa_family == AF_PACKET) {
> diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
> index 0662270300..fcedd0d0fb 100644
> --- a/linux-user/syscall_defs.h
> +++ b/linux-user/syscall_defs.h
> @@ -153,6 +153,13 @@ struct target_sockaddr_un {
>      uint8_t sun_path[108];
>  };
>  
> +struct target_sockaddr_nl {
> +    uint16_t nl_family;     /* AF_NETLINK */
> +    uint16_t __pad;
> +    uint32_t nl_pid;
> +    uint32_t nl_groups;
> +};

You should use abi_ushort and abi_uint to keep alignments good (for
instance m68k aligns on 16bit whereas others on 32bit).

Thanks,
Laurent


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH v6 3/8] linux-user/strace: Improve settimeofday()
  2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 3/8] linux-user/strace: Improve settimeofday() Philippe Mathieu-Daudé
@ 2019-09-10  8:30   ` Laurent Vivier
  2019-09-10  8:52     ` Laurent Vivier
  0 siblings, 1 reply; 16+ messages in thread
From: Laurent Vivier @ 2019-09-10  8:30 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Guido Günther, Riku Voipio

Le 08/09/2019 à 08:15, Philippe Mathieu-Daudé a écrit :
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Tested-By: Guido Günther <agx@sigxcpu.org>
> Reviewed-by: Laurent Vivier <laurent@vivier.eu>
> ---
>  linux-user/strace.c    | 13 +++++++++++++
>  linux-user/strace.list |  2 +-
>  2 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/linux-user/strace.c b/linux-user/strace.c
> index 5ee9d62c25..dcf843b360 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -1584,6 +1584,19 @@ print_futimesat(const struct syscallname *name,
>  }
>  #endif
>  
> +#ifdef TARGET_NR_settimeofday
> +static void
> +print_settimeofday(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_timeval(arg0, 0);
> +    print_timezone(arg1, 1);
> +    print_syscall_epilogue(name);
> +}
> +#endif
> +
>  #ifdef TARGET_NR_link
>  static void
>  print_link(const struct syscallname *name,
> diff --git a/linux-user/strace.list b/linux-user/strace.list
> index 63a946642d..1ff9168369 100644
> --- a/linux-user/strace.list
> +++ b/linux-user/strace.list
> @@ -1345,7 +1345,7 @@
>  { TARGET_NR_set_tid_address, "set_tid_address" , NULL, NULL, NULL },
>  #endif
>  #ifdef TARGET_NR_settimeofday
> -{ TARGET_NR_settimeofday, "settimeofday" , NULL, NULL, NULL },
> +{ TARGET_NR_settimeofday, "settimeofday" , NULL, print_settimeofday, NULL },
>  #endif
>  #ifdef TARGET_NR_setuid
>  { TARGET_NR_setuid, "setuid" , NULL, NULL, NULL },
> 

Applied to my linux-user branch.

Thanks,
Laurent


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH v6 2/8] linux-user/strace: Add print_timezone()
  2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 2/8] linux-user/strace: Add print_timezone() Philippe Mathieu-Daudé
@ 2019-09-10  8:51   ` Laurent Vivier
  0 siblings, 0 replies; 16+ messages in thread
From: Laurent Vivier @ 2019-09-10  8:51 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Guido Günther, Riku Voipio

Le 08/09/2019 à 08:15, Philippe Mathieu-Daudé a écrit :
> Suggested-by: Laurent Vivier <laurent@vivier.eu>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> checkpatch error:
> ERROR: storage class should be at the beginning of the declaration
> ---
>  linux-user/strace.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/linux-user/strace.c b/linux-user/strace.c
> index f326c357a2..5ee9d62c25 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -63,6 +63,7 @@ UNUSED static void print_string(abi_long, int);
>  UNUSED static void print_buf(abi_long addr, abi_long len, int last);
>  UNUSED static void print_raw_param(const char *, abi_long, int);
>  UNUSED static void print_timeval(abi_ulong, int);
> +UNUSED static void print_timezone(abi_ulong, int);
>  UNUSED static void print_number(abi_long, int);
>  UNUSED static void print_signal(abi_ulong, int);
>  UNUSED static void print_sockaddr(abi_ulong addr, abi_long addrlen);
> @@ -1254,6 +1255,26 @@ print_timeval(abi_ulong tv_addr, int last)
>          gemu_log("NULL%s", get_comma(last));
>  }
>  
> +static void
> +print_timezone(abi_ulong tz_addr, int last)
> +{
> +    if (tz_addr) {
> +        struct target_timezone *tz;
> +
> +        tz = lock_user(VERIFY_READ, tz_addr, sizeof(*tz), 1);
> +        if (!tz) {
> +            print_pointer(tz_addr, last);
> +            return;
> +        }
> +        gemu_log("{" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "}%s",
> +                 tswapal(tz->tz_minuteswest), tswapal(tz->tz_dsttime),

tz_minuteswest and tz_dsttime are abi_int, so it should be "%d" and
tswap32().

> +                 get_comma(last));
> +        unlock_user(tz, tz_addr, 0);
> +    } else {
> +        gemu_log("NULL%s", get_comma(last));
> +    }
> +}
> +
>  #undef UNUSED
>  
>  #ifdef TARGET_NR_accept
> 



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH v6 3/8] linux-user/strace: Improve settimeofday()
  2019-09-10  8:30   ` Laurent Vivier
@ 2019-09-10  8:52     ` Laurent Vivier
  0 siblings, 0 replies; 16+ messages in thread
From: Laurent Vivier @ 2019-09-10  8:52 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Guido Günther, Riku Voipio

Le 10/09/2019 à 10:30, Laurent Vivier a écrit :
> Le 08/09/2019 à 08:15, Philippe Mathieu-Daudé a écrit :
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> Tested-By: Guido Günther <agx@sigxcpu.org>
>> Reviewed-by: Laurent Vivier <laurent@vivier.eu>
>> ---
>>  linux-user/strace.c    | 13 +++++++++++++
>>  linux-user/strace.list |  2 +-
>>  2 files changed, 14 insertions(+), 1 deletion(-)
>>
>> diff --git a/linux-user/strace.c b/linux-user/strace.c
>> index 5ee9d62c25..dcf843b360 100644
>> --- a/linux-user/strace.c
>> +++ b/linux-user/strace.c
>> @@ -1584,6 +1584,19 @@ print_futimesat(const struct syscallname *name,
>>  }
>>  #endif
>>  
>> +#ifdef TARGET_NR_settimeofday
>> +static void
>> +print_settimeofday(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_timeval(arg0, 0);
>> +    print_timezone(arg1, 1);
>> +    print_syscall_epilogue(name);
>> +}
>> +#endif
>> +
>>  #ifdef TARGET_NR_link
>>  static void
>>  print_link(const struct syscallname *name,
>> diff --git a/linux-user/strace.list b/linux-user/strace.list
>> index 63a946642d..1ff9168369 100644
>> --- a/linux-user/strace.list
>> +++ b/linux-user/strace.list
>> @@ -1345,7 +1345,7 @@
>>  { TARGET_NR_set_tid_address, "set_tid_address" , NULL, NULL, NULL },
>>  #endif
>>  #ifdef TARGET_NR_settimeofday
>> -{ TARGET_NR_settimeofday, "settimeofday" , NULL, NULL, NULL },
>> +{ TARGET_NR_settimeofday, "settimeofday" , NULL, print_settimeofday, NULL },
>>  #endif
>>  #ifdef TARGET_NR_setuid
>>  { TARGET_NR_setuid, "setuid" , NULL, NULL, NULL },
>>
> 
> Applied to my linux-user branch.

Unapplied as it depends on the previous one.

Thanks,
Laurent


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH v6 4/8] linux-user/syscall: Introduce target_sockaddr_nl
  2019-09-09 14:22   ` Laurent Vivier
@ 2019-09-11 19:34     ` Philippe Mathieu-Daudé
  2019-09-12 17:05       ` Laurent Vivier
  0 siblings, 1 reply; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-09-11 19:34 UTC (permalink / raw)
  To: Laurent Vivier
  Cc: Guido Günther, Riku Voipio, qemu-devel@nongnu.org Developers

On Mon, Sep 9, 2019 at 4:23 PM Laurent Vivier <laurent@vivier.eu> wrote:
> Le 08/09/2019 à 08:15, Philippe Mathieu-Daudé a écrit :
> > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > Tested-By: Guido Günther <agx@sigxcpu.org>
> > ---
> >  linux-user/syscall.c      | 6 ++++--
> >  linux-user/syscall_defs.h | 7 +++++++
> >  2 files changed, 11 insertions(+), 2 deletions(-)
> >
> > diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> > index 8b41a03901..5128312db5 100644
> > --- a/linux-user/syscall.c
> > +++ b/linux-user/syscall.c
> > @@ -1494,8 +1494,10 @@ static inline abi_long host_to_target_sockaddr(abi_ulong target_addr,
> >          sizeof(target_saddr->sa_family)) {
> >          target_saddr->sa_family = tswap16(addr->sa_family);
> >      }
> > -    if (addr->sa_family == AF_NETLINK && len >= sizeof(struct sockaddr_nl)) {
> > -        struct sockaddr_nl *target_nl = (struct sockaddr_nl *)target_saddr;
> > +    if (addr->sa_family == AF_NETLINK &&
> > +        len >= sizeof(struct target_sockaddr_nl)) {
> > +        struct target_sockaddr_nl *target_nl =
> > +               (struct target_sockaddr_nl *)target_saddr;
> >          target_nl->nl_pid = tswap32(target_nl->nl_pid);
> >          target_nl->nl_groups = tswap32(target_nl->nl_groups);
> >      } else if (addr->sa_family == AF_PACKET) {
> > diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
> > index 0662270300..fcedd0d0fb 100644
> > --- a/linux-user/syscall_defs.h
> > +++ b/linux-user/syscall_defs.h
> > @@ -153,6 +153,13 @@ struct target_sockaddr_un {
> >      uint8_t sun_path[108];
> >  };
> >
> > +struct target_sockaddr_nl {
> > +    uint16_t nl_family;     /* AF_NETLINK */
> > +    uint16_t __pad;
> > +    uint32_t nl_pid;
> > +    uint32_t nl_groups;
> > +};
>
> You should use abi_ushort and abi_uint to keep alignments good (for
> instance m68k aligns on 16bit whereas others on 32bit).

Are you sure? The other target_sockaddr don't use that...
Is this because netlink is a host-only structure? (while other are
serialized over some interface).

Thanks,

Phil.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH v6 4/8] linux-user/syscall: Introduce target_sockaddr_nl
  2019-09-11 19:34     ` Philippe Mathieu-Daudé
@ 2019-09-12 17:05       ` Laurent Vivier
  0 siblings, 0 replies; 16+ messages in thread
From: Laurent Vivier @ 2019-09-12 17:05 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Guido Günther, Riku Voipio, qemu-devel@nongnu.org Developers

Le 11/09/2019 à 21:34, Philippe Mathieu-Daudé a écrit :
> On Mon, Sep 9, 2019 at 4:23 PM Laurent Vivier <laurent@vivier.eu> wrote:
>> Le 08/09/2019 à 08:15, Philippe Mathieu-Daudé a écrit :
>>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>>> Tested-By: Guido Günther <agx@sigxcpu.org>
>>> ---
>>>  linux-user/syscall.c      | 6 ++++--
>>>  linux-user/syscall_defs.h | 7 +++++++
>>>  2 files changed, 11 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
>>> index 8b41a03901..5128312db5 100644
>>> --- a/linux-user/syscall.c
>>> +++ b/linux-user/syscall.c
>>> @@ -1494,8 +1494,10 @@ static inline abi_long host_to_target_sockaddr(abi_ulong target_addr,
>>>          sizeof(target_saddr->sa_family)) {
>>>          target_saddr->sa_family = tswap16(addr->sa_family);
>>>      }
>>> -    if (addr->sa_family == AF_NETLINK && len >= sizeof(struct sockaddr_nl)) {
>>> -        struct sockaddr_nl *target_nl = (struct sockaddr_nl *)target_saddr;
>>> +    if (addr->sa_family == AF_NETLINK &&
>>> +        len >= sizeof(struct target_sockaddr_nl)) {
>>> +        struct target_sockaddr_nl *target_nl =
>>> +               (struct target_sockaddr_nl *)target_saddr;
>>>          target_nl->nl_pid = tswap32(target_nl->nl_pid);
>>>          target_nl->nl_groups = tswap32(target_nl->nl_groups);
>>>      } else if (addr->sa_family == AF_PACKET) {
>>> diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
>>> index 0662270300..fcedd0d0fb 100644
>>> --- a/linux-user/syscall_defs.h
>>> +++ b/linux-user/syscall_defs.h
>>> @@ -153,6 +153,13 @@ struct target_sockaddr_un {
>>>      uint8_t sun_path[108];
>>>  };
>>>
>>> +struct target_sockaddr_nl {
>>> +    uint16_t nl_family;     /* AF_NETLINK */
>>> +    uint16_t __pad;
>>> +    uint32_t nl_pid;
>>> +    uint32_t nl_groups;
>>> +};
>>
>> You should use abi_ushort and abi_uint to keep alignments good (for
>> instance m68k aligns on 16bit whereas others on 32bit).
> 
> Are you sure? The other target_sockaddr don't use that...
> Is this because netlink is a host-only structure? (while other are
> serialized over some interface).

I think other target_sockaddr are wrong too. No one takes really care of
alignment, and most of the time structures are by construction well aligned.

Thanks,
Laurent



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2019-09-12 17:07 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-08  6:15 [Qemu-devel] [PATCH v6 0/8] linux-user: strace improvements Philippe Mathieu-Daudé
2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 1/8] linux-user/strace: Display invalid pointer in print_timeval() Philippe Mathieu-Daudé
2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 2/8] linux-user/strace: Add print_timezone() Philippe Mathieu-Daudé
2019-09-10  8:51   ` Laurent Vivier
2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 3/8] linux-user/strace: Improve settimeofday() Philippe Mathieu-Daudé
2019-09-10  8:30   ` Laurent Vivier
2019-09-10  8:52     ` Laurent Vivier
2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 4/8] linux-user/syscall: Introduce target_sockaddr_nl Philippe Mathieu-Daudé
2019-09-09 14:22   ` Laurent Vivier
2019-09-11 19:34     ` Philippe Mathieu-Daudé
2019-09-12 17:05       ` Laurent Vivier
2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 5/8] linux-user/strace: Dump AF_NETLINK sockaddr content Philippe Mathieu-Daudé
2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 6/8] linux-user/strace: Add print_sockfd() Philippe Mathieu-Daudé
2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 7/8] linux-user/strace: Improve bind() output Philippe Mathieu-Daudé
2019-09-08  6:15 ` [Qemu-devel] [PATCH v6 8/8] linux-user/strace: Let print_sockaddr() have a 'last' argument Philippe Mathieu-Daudé
2019-09-08  6:28 ` [Qemu-devel] [PATCH v6 0/8] linux-user: strace improvements no-reply

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).