On Fri, Jun 17, 2016 at 02:32:02PM +0000, Fabien Siron wrote: > Quoting Dmitry V. Levin (2016-06-16 14:54:58) > > On Thu, Jun 16, 2016 at 02:20:07PM +0000, Fabien Siron wrote: > > > Quoting Dmitry V. Levin (2016-06-16 10:40:18) > > > > On Wed, Jun 15, 2016 at 12:43:01PM +0000, Fabien Siron wrote: > > > > [...] > > > > > +static void > > > > > +send_query(const int fd, const unsigned int pid_magic) > > > > > +{ > > > > > + struct { > > > > > + struct nlmsghdr nlh; > > > > > + char magic[4]; > > > > > + } req = { > > > > > + .nlh = { > > > > > + .nlmsg_len = sizeof(req), > > > > > + .nlmsg_type = NLMSG_NOOP, > > > > > + .nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST > > > > > + }, > > > > > + .magic = "abcd" > > > > > + }; > > > > > + > > > > > + if (sendto(fd, &req, sizeof(req), MSG_DONTWAIT, NULL, 0) != > > > > > + (unsigned) sizeof(req)) > > > > > + perror_msg_and_skip("sendto"); > > > > > + > > > > > + printf("sendto(%d<NETLINK:[SOCK_DIAG:%u]>, {{len=%u, > > > > > type=NLMSG_NOOP, " > > > > > + "flags=NLM_F_REQUEST|0x%x, seq=0, pid=0}, \"abcd\"}, %u, > > > > > " > > > > > + "MSG_DONTWAIT, NULL, 0) = %u\n", > > > > > + fd, pid_magic, (unsigned) sizeof(req), NLM_F_DUMP, > > > > > + (unsigned) sizeof(req), (unsigned) sizeof(req)); > > > > > > > > I'd also add coverage for the following corner cases when > > > > + data length equals to sizeof(struct nlmsghdr); > > > > + data length is less than sizeof(struct nlmsghdr); > > > > + data length is enough but data points to unmapped memory. > > > > > > > I am not sure what you mean by "data". > > > > By data I mean the 2nd argument of sendto, by data length I mean > > the 3rd argument of sendto. > > > > If only part of memory pointed by 2nd argument of sendto is mapped, > > netlink parser won't be able to fetch it and is expected to print > > something meaningfull. > > > I really don't see how you can handle this case. Can I have any clue?
const void *const efault = tail_alloc(sizeof(struct nlmsghdr) - 1); sendto(fd, efault, sizeof(struct nlmsghdr), ... -- ldv
pgp3bTOSqqrs1.pgp
Description: PGP signature
------------------------------------------------------------------------------ What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. http://sdm.link/zohomanageengine
_______________________________________________ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel