Page MenuHomeFreeBSD

netlink: Parse repeated nested attributes
ClosedPublic

Authored by kbowling on Mon, Aug 10, 10:39 PM.
Tags
None
Referenced Files
F169029197: D58775.id.diff
Mon, Aug 31, 4:18 AM
F168988830: D58775.id183841.diff
Mon, Aug 31, 1:54 AM
F168946800: D58775.id.diff
Sun, Aug 30, 9:51 PM
F168902999: D58775.id183841.diff
Sun, Aug 30, 4:40 PM
Unknown Object (File)
Sun, Aug 30, 3:32 AM
Unknown Object (File)
Sun, Aug 30, 2:44 AM
Unknown Object (File)
Sun, Aug 30, 12:18 AM
Unknown Object (File)
Thu, Aug 27, 1:05 AM
Subscribers

Details

Summary
Modern Netlink arrays encode their elements as repeated attributes of
the same type rather than as children of an additional array container.

Add an SNL callback that parses one nested element for each occurrence
and appends it to a geometrically grown parser array.  Retain the
existing parray callback for protocols that use the legacy container
form.

Store the growth capacity in struct snl_parray, appended after its
existing public count and items fields so their offsets remain stable
on LP64 and ILP32.  Require parser targets to be real snl_parray
objects, and convert bitset, generic Netlink, and route multipath arrays
accordingly.  This avoids relying on layout aliases for private growth
state.

Add regression coverage for a nested bit array that grows beyond its
initial allocation, while preserving replacement semantics when a
legacy array target is reused.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Overall, this is a great change. I also wanted to rename parray structure from nexthop-specific names to something more generic too, considering we really need the multi-attr parser in our library too. specially for cases like D58643.

However, this definitely breaks snl(3) compatibility for applications that depend on this library.
I have no objection, but I'd prefer to get @glebius opinion on this too.
A quick search on github shows some applications that are using these interfaces outside our code base.
https://github.com/search?q=struct+rta_mpath_nh&type=code

I'm not qualified to review this from a security perspective, so it would be helpful to get input from a security team member as well. (@markj)

Thank you, I'll review this in depth soon.

Overall, this is a great change. I also wanted to rename parray structure from nexthop-specific names to something more generic too, considering we really need the multi-attr parser in our library too. specially for cases like D58643.

However, this definitely breaks snl(3) compatibility for applications that depend on this library.
I have no objection, but I'd prefer to get @glebius opinion on this too.
A quick search on github shows some applications that are using these interfaces outside our code base.
https://github.com/search?q=struct+rta_mpath_nh&type=code

The cheap answer is it's not an MFC candidate :)

For completeness in case it guides later decision making, I did scan all 5 github search pages: the only case that isn't a fork of freebsd-src or spiritually the same (f-stack, rtems-libbsd) is zig's libc wrappers.

This revision is now accepted and ready to land.Thu, Aug 13, 10:37 PM

LGTM
Thank you!
I'll rebase D58644 on top of this and replace my struct iflaf_group with snl_parray.
It *might* also need a version bump.