[PATCH RESEND 1/8] netlink: call get_fd_nl_family before decode nlmsghdr

Dmitry V. Levin ldv at altlinux.org
Mon Aug 7 03:48:20 UTC 2017


On Sun, Aug 06, 2017 at 07:52:17AM +0800, JingPiao Chen wrote:
> On Sun, Aug 06, 2017 at 02:10:16AM +0300, Dmitry V. Levin wrote:
> > On Tue, Aug 01, 2017 at 07:48:41AM +0800, JingPiao Chen wrote:
> > > Prepare for NETLINK_KOBJECT_UEVENT decode. The messages
> > > of NETLINK_KOBJECT_UEVENT do not contain nlmsghdr.
> > [...]
> > > (decode_nlmsghdr_with_payload): Skip family specific decoders
> > > for type < NLMSG_MIN_TYPE && type != NLMSG_DONE.
> > [...]
> > > @@ -182,7 +177,7 @@ decode_nlmsg_type(const uint16_t type, const unsigned int family)
> > >  	const struct xlat *xlat = netlink_types;
> > >  	const char *dflt = "NLMSG_???";
> > >  
> > > -	if (type != NLMSG_DONE && family < ARRAY_SIZE(nlmsg_types)) {
> > > +	if (type >= NLMSG_MIN_TYPE && family < ARRAY_SIZE(nlmsg_types)) {
> > 
> > Why?  How this is related to the rest of NETLINK_KOBJECT_UEVENT change?
> 
> Previous code when type < NLMSG_MIN_TYPE && type != NLMSG_DONE,
> family = -2 (NL_FAMILY_DEFAULT), family < ARRAY_SIZE(nlmsg_types) filter
> this case. Now get family ignore the nlmsg_type.
> When type < NLMSG_MIN_TYPE && type != NLMSG_DONE, family is not
> a negative. family < ARRAY_SIZE(nlmsg_types) can not filter this case.
> 
> Related commit:
> v4.17-43-g1b63425, v4.17-44-g8700030: These commit introduce get_fd_nl_family.
> And get family only when type >= NLMSG_MIN_TYPE.
> 
> v4.17-123-g54aed21: This commit changed get family when
> type >= NLMSG_MIN_TYPE || type == NLMSG_DONE.

Sorry, this explanation made me even more confused than before.
I'll try to re-read the code to get an inspiration.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170807/7b2742e6/attachment.bin>


More information about the Strace-devel mailing list