Skip to content

stricter netlink validation

Johannes Berg linux-wireless netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 13 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6netlink: add NLA_MIN_LENinclude/net/netlink.h lib/nlattr.c+13 -20 replies
2/6netlink: make validation more configurable for future strictnesscrypto/crypto_user_base.c drivers/block/drbd/drbd_nla.c drivers/block/nbd.c +142 more+1214 -9332 replies
3/6netlink: re-add parse/validate functions in strict modeinclude/net/genetlink.h include/net/netlink.h+84 -00 replies
4/6netlink: add strict parsing for future attributesinclude/net/netlink.h lib/nlattr.c+22 -03 replies
5/6genetlink: optionally validate strictly/dumpsdrivers/block/nbd.c drivers/net/gtp.c drivers/net/ieee802154/mac802154_hwsim.c +34 more+420 -100 replies
6/6nl80211: tag policies with strict_start_typenet/wireless/nl80211.c+22 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/6] stricter netlink validation

Here's a version that has passed build testing ;-)

As mentioned in the RFC postings, this was inspired by talks between David, Pablo and myself. Pablo is somewhat firmly on the side of less strict validation, while David and myself are in the very strict validation camp. If I understand him correctly, Pablo doesn't mind the strict validation if it is accompanied by exposing the policy to userspace, but that isn't something we can do today. I'll work on it later.

What this series does is basically first replace nla_parse() and all its friends by nla_parse_deprecated(), while making all of those just inlines around __nla_parse() and friends with configurable strict checking bits. Three versions exist after this patchset:
* liberal - no bits set
* deprecated_strict - reject attrs > maxtype
reject trailing junk
* new default - reject trailing junk
reject attrs > maxtype
reject policy entries that are NLA_UNSPEC require a policy
strictly validate attributes

The NLA_UNSPEC one can be opted in even in existing code with existing userspace in the future, as policies are updated.

In addition, infrastructure is added to opt in to the strict attribute validation even for new attributes added to existing policies, regardless of the nla_parse() strictness setting described above, as new attributes should not be a compatibility issue.

Finally, much of this is plumbed through generic netlink etc., and I've included a patch to tag nl80211 with the future attribute strictness for reference.

johannes