]> granicus.if.org Git - strace/commitdiff
Adjust prototypes of netlink parsing functions
authorDmitry V. Levin <ldv@altlinux.org>
Wed, 19 Jul 2017 10:07:34 +0000 (10:07 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 19 Jul 2017 10:07:34 +0000 (10:07 +0000)
Change the type of "len" argument that is based
on struct nlmsghdr.nlmsg_len from kernel_ulong_t to unsigned int.

* defs.h (netlink_decoder_t, DECL_NETLINK): Change "len" argument type
from kernel_ulong_t to unsigned int.
* netlink.c (decode_nlmsgerr_attr_cookie, decode_nlmsgerr,
decode_payload): Likewise.
* netlink_selinux.c (decode_netlink_selinux): Likewise.
* netlink_sock_diag.c (decode_family, decode_unix_diag_req,
decode_meminfo, decode_unix_diag_vfs, decode_unix_diag_inode,
decode_unix_diag_rqlen, decode_unix_diag_msg, decode_netlink_diag_req,
print_group, decode_netlink_diag_ring, decode_netlink_diag_flags,
decode_netlink_diag_msg, decode_packet_diag_req,
decode_packet_diag_info, decode_packet_diag_mclist,
decode_packet_diag_ring, decode_packet_diag_filter,
decode_packet_diag_msg, decode_inet_addr, decode_inet_diag_hostcond,
decode_inet_diag_markcond, decode_bytecode_data, decode_inet_diag_bc_op,
decode_inet_diag_req_compat, decode_inet_diag_req_v2,
decode_inet_diag_req, decode_inet_diag_meminfo, decode_tcpvegas_info,
decode_tcp_dctcp_info, decode_tcp_bbr_info, decode_inet_diag_msg,
decode_smc_diag_req, decode_smc_diag_conninfo, decode_smc_diag_lgrinfo,
decode_smc_diag_msg, netlink_diag_decoder_t, decode_netlink_sock_diag):
Likewise.
* nlattr.c (fetch_nlattr, decode_nlattr_with_data, decode_nlattr,
decode_nla_str, decode_nla_strn, DECODE_NLA_INTEGER): Likewise.
* nlattr.h (nla_decoder_t, DECL_NLA, decode_nlattr): Likewise.

defs.h
netlink.c
netlink_selinux.c
netlink_sock_diag.c
nlattr.c
nlattr.h

diff --git a/defs.h b/defs.h
index bc9a3e01130a6b1703080a60c2e5586c2bb311f0..4a77008d96853a59a82b8df21b61f0417b8cff10 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -703,12 +703,12 @@ extern int decode_sg_io_v4(struct tcb *, const kernel_ulong_t arg);
 struct nlmsghdr;
 
 typedef bool (*netlink_decoder_t)(struct tcb *, const struct nlmsghdr *,
-                                 kernel_ulong_t addr, kernel_ulong_t len);
+                                 kernel_ulong_t addr, unsigned int len);
 
 #define DECL_NETLINK(name)                                             \
 extern bool                                                            \
 decode_netlink_ ## name(struct tcb *, const struct nlmsghdr *,         \
-                       kernel_ulong_t addr, kernel_ulong_t len)
+                       kernel_ulong_t addr, unsigned int len)
 DECL_NETLINK(selinux);
 DECL_NETLINK(sock_diag);
 
index ddaa6c202ebdffa0eb40383a820261dfcd3381fe..b9ad7d245d0f27392fd78891ff09d79f8c04b3ab 100644 (file)
--- a/netlink.c
+++ b/netlink.c
@@ -300,7 +300,7 @@ print_cookie(struct tcb *const tcp,
 static bool
 decode_nlmsgerr_attr_cookie(struct tcb *const tcp,
                            const kernel_ulong_t addr,
-                           const kernel_ulong_t len,
+                           const unsigned int len,
                            const void *const opaque_data)
 {
        uint8_t cookie;
@@ -331,7 +331,7 @@ decode_nlmsgerr(struct tcb *const tcp,
                const int fd,
                const int family,
                kernel_ulong_t addr,
-               kernel_ulong_t len,
+               unsigned int len,
                const bool capped)
 {
        struct nlmsgerr err;
@@ -390,7 +390,7 @@ decode_payload(struct tcb *const tcp,
               const int family,
               const struct nlmsghdr *const nlmsghdr,
               const kernel_ulong_t addr,
-              const kernel_ulong_t len)
+              const unsigned int len)
 {
        if (nlmsghdr->nlmsg_type == NLMSG_ERROR) {
                decode_nlmsgerr(tcp, fd, family, addr, len,
index 43885ffef647165856d6b754698a13d00a460d0e..0bba3cfc4c045981c9b7f71c4f62adaa26b948d7 100644 (file)
@@ -36,7 +36,7 @@ bool
 decode_netlink_selinux(struct tcb *const tcp,
                       const struct nlmsghdr *const nlmsghdr,
                       const kernel_ulong_t addr,
-                      const kernel_ulong_t len)
+                      const unsigned int len)
 {
        switch (nlmsghdr->nlmsg_type) {
        case SELNL_MSG_SETENFORCE: {
index 44ec34a1f37b613c0e118923e6a8b27562138096..cd4e54e77f8efa85b263b1fbdf76a484445c3efe 100644 (file)
@@ -73,7 +73,7 @@
 
 static void
 decode_family(struct tcb *const tcp, const uint8_t family,
-             const kernel_ulong_t addr, const kernel_ulong_t len)
+             const kernel_ulong_t addr, const unsigned int len)
 {
        tprints("{family=");
        printxval(addrfams, family, "AF_???");
@@ -90,7 +90,7 @@ decode_unix_diag_req(struct tcb *const tcp,
                     const struct nlmsghdr *const nlmsghdr,
                     const uint8_t family,
                     const kernel_ulong_t addr,
-                    const kernel_ulong_t len)
+                    const unsigned int len)
 {
        struct unix_diag_req req = { .sdiag_family = family };
        const size_t offset = sizeof(req.sdiag_family);
@@ -135,11 +135,11 @@ print_meminfo(struct tcb *const tcp,
 static bool
 decode_meminfo(struct tcb *const tcp,
               const kernel_ulong_t addr,
-              const kernel_ulong_t len,
+              const unsigned int len,
               const void *const opaque_data)
 {
        uint32_t mem;
-       size_t nmemb = len / sizeof(mem);
+       const size_t nmemb = len / sizeof(mem);
 
        if (!nmemb)
                return false;
@@ -154,7 +154,7 @@ decode_meminfo(struct tcb *const tcp,
 static bool
 decode_unix_diag_vfs(struct tcb *const tcp,
                     const kernel_ulong_t addr,
-                    const kernel_ulong_t len,
+                    const unsigned int len,
                     const void *const opaque_data)
 {
        struct unix_diag_vfs uv;
@@ -185,7 +185,7 @@ print_inode(struct tcb *const tcp,
 static bool
 decode_unix_diag_inode(struct tcb *const tcp,
                       const kernel_ulong_t addr,
-                      const kernel_ulong_t len,
+                      const unsigned int len,
                       const void *const opaque_data)
 {
        uint32_t inode;
@@ -203,7 +203,7 @@ decode_unix_diag_inode(struct tcb *const tcp,
 static bool
 decode_unix_diag_rqlen(struct tcb *const tcp,
                       const kernel_ulong_t addr,
-                      const kernel_ulong_t len,
+                      const unsigned int len,
                       const void *const opaque_data)
 {
        struct unix_diag_rqlen rql;
@@ -235,7 +235,7 @@ decode_unix_diag_msg(struct tcb *const tcp,
                     const struct nlmsghdr *const nlmsghdr,
                     const uint8_t family,
                     const kernel_ulong_t addr,
-                    const kernel_ulong_t len)
+                    const unsigned int len)
 {
        struct unix_diag_msg msg = { .udiag_family = family };
        size_t offset = sizeof(msg.udiag_family);
@@ -274,7 +274,7 @@ decode_netlink_diag_req(struct tcb *const tcp,
                        const struct nlmsghdr *const nlmsghdr,
                        const uint8_t family,
                        const kernel_ulong_t addr,
-                       const kernel_ulong_t len)
+                       const unsigned int len)
 {
        struct netlink_diag_req req = { .sdiag_family = family };
        const size_t offset = sizeof(req.sdiag_family);
@@ -321,7 +321,7 @@ print_group(struct tcb *const tcp,
 static bool
 decode_netlink_diag_groups(struct tcb *const tcp,
                           const kernel_ulong_t addr,
-                          const kernel_ulong_t len,
+                          const unsigned int len,
                           const void *const opaque_data)
 {
        kernel_ulong_t buf;
@@ -339,7 +339,7 @@ decode_netlink_diag_groups(struct tcb *const tcp,
 static bool
 decode_netlink_diag_ring(struct tcb *const tcp,
                         const kernel_ulong_t addr,
-                        const kernel_ulong_t len,
+                        const unsigned int len,
                         const void *const opaque_data)
 {
        struct netlink_diag_ring ndr;
@@ -361,7 +361,7 @@ decode_netlink_diag_ring(struct tcb *const tcp,
 static bool
 decode_netlink_diag_flags(struct tcb *const tcp,
                          const kernel_ulong_t addr,
-                         const kernel_ulong_t len,
+                         const unsigned int len,
                          const void *const opaque_data)
 {
        uint32_t flags;
@@ -389,7 +389,7 @@ decode_netlink_diag_msg(struct tcb *const tcp,
                        const struct nlmsghdr *const nlmsghdr,
                        const uint8_t family,
                        const kernel_ulong_t addr,
-                       const kernel_ulong_t len)
+                       const unsigned int len)
 {
        struct netlink_diag_msg msg = { .ndiag_family = family };
        size_t offset = sizeof(msg.ndiag_family);
@@ -433,7 +433,7 @@ decode_packet_diag_req(struct tcb *const tcp,
                       const struct nlmsghdr *const nlmsghdr,
                       const uint8_t family,
                       const kernel_ulong_t addr,
-                      const kernel_ulong_t len)
+                      const unsigned int len)
 {
        struct packet_diag_req req = { .sdiag_family = family };
        const size_t offset = sizeof(req.sdiag_family);
@@ -459,7 +459,7 @@ decode_packet_diag_req(struct tcb *const tcp,
 static bool
 decode_packet_diag_info(struct tcb *const tcp,
                        const kernel_ulong_t addr,
-                       const kernel_ulong_t len,
+                       const unsigned int len,
                        const void *const opaque_data)
 {
        struct packet_diag_info pinfo;
@@ -502,7 +502,7 @@ print_packet_diag_mclist(struct tcb *const tcp, void *const elem_buf,
 static bool
 decode_packet_diag_mclist(struct tcb *const tcp,
                          const kernel_ulong_t addr,
-                         const kernel_ulong_t len,
+                         const unsigned int len,
                          const void *const opaque_data)
 {
        struct packet_diag_mclist dml;
@@ -520,7 +520,7 @@ decode_packet_diag_mclist(struct tcb *const tcp,
 static bool
 decode_packet_diag_ring(struct tcb *const tcp,
                        const kernel_ulong_t addr,
-                       const kernel_ulong_t len,
+                       const unsigned int len,
                        const void *const opaque_data)
 {
        struct packet_diag_ring pdr;
@@ -545,10 +545,10 @@ decode_packet_diag_ring(struct tcb *const tcp,
 static bool
 decode_packet_diag_filter(struct tcb *const tcp,
                          const kernel_ulong_t addr,
-                         const kernel_ulong_t len,
+                         const unsigned int len,
                          const void *const opaque_data)
 {
-       const kernel_ulong_t nmemb = len / sizeof(struct sock_filter);
+       const unsigned int nmemb = len / sizeof(struct sock_filter);
        if (!nmemb || (unsigned short) nmemb != nmemb)
                return false;
 
@@ -573,7 +573,7 @@ decode_packet_diag_msg(struct tcb *const tcp,
                       const struct nlmsghdr *const nlmsghdr,
                       const uint8_t family,
                       const kernel_ulong_t addr,
-                      const kernel_ulong_t len)
+                      const unsigned int len)
 {
        struct packet_diag_msg msg = { .pdiag_family = family };
        size_t offset = sizeof(msg.pdiag_family);
@@ -627,7 +627,7 @@ print_inet_diag_sockid(const struct inet_diag_sockid *id, const uint8_t family)
 static void
 decode_inet_addr(struct tcb *const tcp,
                 const kernel_ulong_t addr,
-                const kernel_ulong_t len,
+                const unsigned int len,
                 const int family)
 {
        union {
@@ -663,7 +663,7 @@ decode_inet_addr(struct tcb *const tcp,
 static void
 decode_inet_diag_hostcond(struct tcb *const tcp,
                          const kernel_ulong_t addr,
-                         const kernel_ulong_t len)
+                         const unsigned int len)
 {
        struct inet_diag_hostcond cond;
 
@@ -699,7 +699,7 @@ print_inet_diag_bc_op(const struct inet_diag_bc_op *const op)
 static void
 decode_inet_diag_markcond(struct tcb *const tcp,
                          const kernel_ulong_t addr,
-                         const kernel_ulong_t len)
+                         const unsigned int len)
 {
        struct inet_diag_markcond markcond;
 
@@ -715,7 +715,7 @@ decode_inet_diag_markcond(struct tcb *const tcp,
 static void
 decode_bytecode_data(struct tcb *const tcp,
                     const kernel_ulong_t addr,
-                    const kernel_ulong_t len,
+                    const unsigned int len,
                     const unsigned char code)
 {
        switch (code) {
@@ -759,7 +759,7 @@ decode_bytecode_data(struct tcb *const tcp,
 static bool
 decode_inet_diag_bc_op(struct tcb *const tcp,
                       const kernel_ulong_t addr,
-                      const kernel_ulong_t len,
+                      const unsigned int len,
                       const void *const opaque_data)
 {
        struct inet_diag_bc_op op;
@@ -793,7 +793,7 @@ decode_inet_diag_req_compat(struct tcb *const tcp,
                            const struct nlmsghdr *const nlmsghdr,
                            const uint8_t family,
                            const kernel_ulong_t addr,
-                           const kernel_ulong_t len)
+                           const unsigned int len)
 {
        struct inet_diag_req req = { .idiag_family = family };
        size_t offset = sizeof(req.idiag_family);
@@ -836,7 +836,7 @@ decode_inet_diag_req_v2(struct tcb *const tcp,
                        const struct nlmsghdr *const nlmsghdr,
                        const uint8_t family,
                        const kernel_ulong_t addr,
-                       const kernel_ulong_t len)
+                       const unsigned int len)
 {
        struct inet_diag_req_v2 req = { .sdiag_family = family };
        size_t offset = sizeof(req.sdiag_family);
@@ -878,7 +878,7 @@ decode_inet_diag_req(struct tcb *const tcp,
                     const struct nlmsghdr *const nlmsghdr,
                     const uint8_t family,
                     const kernel_ulong_t addr,
-                    const kernel_ulong_t len)
+                    const unsigned int len)
 {
        if (nlmsghdr->nlmsg_type == TCPDIAG_GETSOCK
            || nlmsghdr->nlmsg_type == DCCPDIAG_GETSOCK)
@@ -892,7 +892,7 @@ decode_inet_diag_req(struct tcb *const tcp,
 static bool
 decode_inet_diag_meminfo(struct tcb *const tcp,
                         const kernel_ulong_t addr,
-                        const kernel_ulong_t len,
+                        const unsigned int len,
                         const void *const opaque_data)
 {
        struct inet_diag_meminfo minfo;
@@ -914,7 +914,7 @@ decode_inet_diag_meminfo(struct tcb *const tcp,
 static bool
 decode_tcpvegas_info(struct tcb *const tcp,
                     const kernel_ulong_t addr,
-                    const kernel_ulong_t len,
+                    const unsigned int len,
                     const void *const opaque_data)
 {
        struct tcpvegas_info vegas;
@@ -936,7 +936,7 @@ decode_tcpvegas_info(struct tcb *const tcp,
 static bool
 decode_tcp_dctcp_info(struct tcb *const tcp,
                      const kernel_ulong_t addr,
-                     const kernel_ulong_t len,
+                     const unsigned int len,
                      const void *const opaque_data)
 {
        struct tcp_dctcp_info dctcp;
@@ -959,7 +959,7 @@ decode_tcp_dctcp_info(struct tcb *const tcp,
 static bool
 decode_tcp_bbr_info(struct tcb *const tcp,
                    const kernel_ulong_t addr,
-                   const kernel_ulong_t len,
+                   const unsigned int len,
                    const void *const opaque_data)
 {
        struct tcp_bbr_info bbr;
@@ -1003,7 +1003,7 @@ decode_inet_diag_msg(struct tcb *const tcp,
                     const struct nlmsghdr *const nlmsghdr,
                     const uint8_t family,
                     const kernel_ulong_t addr,
-                    const kernel_ulong_t len)
+                    const unsigned int len)
 {
        struct inet_diag_msg msg = { .idiag_family = family };
        size_t offset = sizeof(msg.idiag_family);
@@ -1048,7 +1048,7 @@ decode_smc_diag_req(struct tcb *const tcp,
                    const struct nlmsghdr *const nlmsghdr,
                    const uint8_t family,
                    const kernel_ulong_t addr,
-                   const kernel_ulong_t len)
+                   const unsigned int len)
 {
        struct smc_diag_req req = { .diag_family = family };
        const size_t offset = sizeof(req.diag_family);
@@ -1091,7 +1091,7 @@ print_smc_diag_cursor(const struct smc_diag_cursor *const cursor)
 static bool
 decode_smc_diag_conninfo(struct tcb *const tcp,
                         const kernel_ulong_t addr,
-                        const kernel_ulong_t len,
+                        const unsigned int len,
                         const void *const opaque_data)
 {
        struct smc_diag_conninfo cinfo;
@@ -1124,7 +1124,7 @@ decode_smc_diag_conninfo(struct tcb *const tcp,
 static bool
 decode_smc_diag_lgrinfo(struct tcb *const tcp,
                        const kernel_ulong_t addr,
-                       const kernel_ulong_t len,
+                       const unsigned int len,
                        const void *const opaque_data)
 {
        struct smc_diag_lgrinfo linfo;
@@ -1157,7 +1157,7 @@ decode_smc_diag_msg(struct tcb *const tcp,
                    const struct nlmsghdr *const nlmsghdr,
                    const uint8_t family,
                    const kernel_ulong_t addr,
-                   const kernel_ulong_t len)
+                   const unsigned int len)
 {
        struct smc_diag_msg msg = { .diag_family = family };
        size_t offset = sizeof(msg.diag_family);
@@ -1201,7 +1201,7 @@ typedef void (*netlink_diag_decoder_t)(struct tcb *,
                                       const struct nlmsghdr *,
                                       uint8_t family,
                                       kernel_ulong_t addr,
-                                      kernel_ulong_t len);
+                                      unsigned int len);
 
 static const struct {
        const netlink_diag_decoder_t request, response;
@@ -1220,7 +1220,7 @@ bool
 decode_netlink_sock_diag(struct tcb *const tcp,
                         const struct nlmsghdr *const nlmsghdr,
                         const kernel_ulong_t addr,
-                        const kernel_ulong_t len)
+                        const unsigned int len)
 {
        uint8_t family;
 
index 8775d3569949c5e10e149b6eb16ab8bd4a8adc38..6293f93a4a4a85c117b5f0a367801264912ed158 100644 (file)
--- a/nlattr.c
+++ b/nlattr.c
@@ -33,7 +33,7 @@
 
 static bool
 fetch_nlattr(struct tcb *const tcp, struct nlattr *const nlattr,
-            const kernel_ulong_t addr, const kernel_ulong_t len)
+            const kernel_ulong_t addr, const unsigned int len)
 {
        if (len < sizeof(struct nlattr)) {
                printstr_ex(tcp, addr, len, QUOTE_FORCE_HEX);
@@ -64,7 +64,7 @@ static void
 decode_nlattr_with_data(struct tcb *const tcp,
                        const struct nlattr *const nla,
                        const kernel_ulong_t addr,
-                       const kernel_ulong_t len,
+                       const unsigned int len,
                        const struct xlat *const table,
                        const char *const dflt,
                        const nla_decoder_t *const decoders,
@@ -95,7 +95,7 @@ decode_nlattr_with_data(struct tcb *const tcp,
 void
 decode_nlattr(struct tcb *const tcp,
              kernel_ulong_t addr,
-             kernel_ulong_t len,
+             unsigned int len,
              const struct xlat *const table,
              const char *const dflt,
              const nla_decoder_t *const decoders,
@@ -112,9 +112,9 @@ decode_nlattr(struct tcb *const tcp,
                        break;
                }
 
-               const unsigned long nla_len = NLA_ALIGN(nla.nla_len);
+               const unsigned int nla_len = NLA_ALIGN(nla.nla_len);
                kernel_ulong_t next_addr = 0;
-               kernel_ulong_t next_len = 0;
+               unsigned int next_len = 0;
 
                if (nla.nla_len >= NLA_HDRLEN) {
                        next_len = (len >= nla_len) ? len - nla_len : 0;
@@ -147,7 +147,7 @@ decode_nlattr(struct tcb *const tcp,
 bool
 decode_nla_str(struct tcb *const tcp,
               const kernel_ulong_t addr,
-              const kernel_ulong_t len,
+              const unsigned int len,
               const void *const opaque_data)
 {
        printstr_ex(tcp, addr, len, QUOTE_0_TERMINATED);
@@ -158,7 +158,7 @@ decode_nla_str(struct tcb *const tcp,
 bool
 decode_nla_strn(struct tcb *const tcp,
                const kernel_ulong_t addr,
-               const kernel_ulong_t len,
+               const unsigned int len,
                const void *const opaque_data)
 {
        printstrn(tcp, addr, len);
@@ -170,7 +170,7 @@ decode_nla_strn(struct tcb *const tcp,
 bool                                                   \
 decode_nla_ ## name(struct tcb *const tcp,             \
                    const kernel_ulong_t addr,          \
-                   const kernel_ulong_t len,           \
+                   const unsigned int len,             \
                    const void *const opaque_data)      \
 {                                                      \
        type num;                                       \
index 40a476fcc7550155b36e36b74c21abb6ab622c82..1a8ca88f4f937d559d66dcac7a9c0c3b2ffc86b2 100644 (file)
--- a/nlattr.h
+++ b/nlattr.h
 #define STRACE_NLATTR_H
 
 typedef bool (*nla_decoder_t)(struct tcb *, kernel_ulong_t addr,
-                             kernel_ulong_t len, const void *opaque_data);
+                             unsigned int len, const void *opaque_data);
 extern void
 decode_nlattr(struct tcb *,
              kernel_ulong_t addr,
-             kernel_ulong_t len,
+             unsigned int len,
              const struct xlat *,
              const char *dflt,
              const nla_decoder_t *,
@@ -45,7 +45,7 @@ decode_nlattr(struct tcb *,
 #define DECL_NLA(name)                                 \
 extern bool                                            \
 decode_nla_ ## name(struct tcb *, kernel_ulong_t addr, \
-                   kernel_ulong_t len, const void *)
+                   unsigned int len, const void *)
 DECL_NLA(u8);
 DECL_NLA(u16);
 DECL_NLA(u32);