[PATCH v7 4/4] Netlink: handle multi netlink messages

Fabien Siron fabien.siron at epita.fr
Mon Jun 27 07:20:56 UTC 2016


Quoting Fabien Siron (2016-06-24 11:54:16)
> Quoting Dmitry V. Levin (2016-06-23 11:36:25)
> > On Thu, Jun 23, 2016 at 10:49:53AM +0000, Fabien Siron wrote:
> > > Quoting Dmitry V. Levin (2016-06-22 17:40:39)
> > > > On Wed, Jun 22, 2016 at 01:27:06PM +0000, Fabien Siron wrote:
> [...]
> > > > > +     if (NLMSG_ALIGN(nlmsghdr->nlmsg_len) == 0 ||
> > > > > +         NLMSG_ALIGN(nlmsghdr->nlmsg_len) > *len)
> > > > > +             return 0;
> > > > 
> > > > This is not going to happen with current implementation of nlmsg_fetch,
> > > > but if nlmsg_fetch changes and if this condition is true, then
> > > > *len remains unchanged and the subsequent nlmsg_fetch prints NULL.
> > > 
> > > A way to fix that is to put *len to 0 in this test. But the problem is that
> > > nothing will be printed if sizeof(struct nlmsghdr) < *len < nlmsghdr->nlmsg_len.
> > 
> > It's up to decode_netlink_msg to decide how to print such messages.
> > 
> > decode_netlink has to be consistent.  Every successfully fetched struct
> > nlmsghdr should be printed.  When decode_netlink leaves some bytes of the
> > message undecoded, it has to print an indication.
> 
> It already prints a string, what kind of indication do you want to add?
> 
> So do you agree with this test for next_nlmsghdr:
> 
> if (NLMSG_ALIGN(nlmsghdr->nlmsg_len) == 0 ||
>     NLMSG_ALIGN(nlmsghdr->nlmsg_len) > *len) {
>     *len = nlmsghdr->nlmsg_len;
>     return 0;
> }
> 
> Now, the subsequent nlmsg_fetch does not print NULL.
> 

And of course, to add this at the beginning of fetch_nlmsg():

if (addr == 0)
   return 0;

--
Fabien Siron




More information about the Strace-devel mailing list