]> exis.tech > repos - linux.git/commit
netlabel: validate unlabeled address and mask attribute lengths
authorChenguang Zhao <zhaochenguang@kylinos.cn>
Wed, 3 Jun 2026 01:13:53 +0000 (09:13 +0800)
committerJakub Kicinski <kuba@kernel.org>
Sat, 6 Jun 2026 02:05:06 +0000 (19:05 -0700)
commit9772589b57e44aedc240211c5c3f7a684a034d3a
treec9dc6992140681df03a277d7955f44dacb77036a
parent3847d94783c0b893c27ff0b26a3325796d9444c6
netlabel: validate unlabeled address and mask attribute lengths

netlbl_unlabel_addrinfo_get() used the address attribute length to
determine whether the attribute data could be read as an IPv4 or IPv6
address, but did not independently validate the corresponding mask
attribute length.  A crafted Generic Netlink request could therefore
provide a valid IPv4/IPv6 address attribute with a shorter mask
attribute, which would later be read as a full struct in_addr or
struct in6_addr.

NLA_BINARY policy lengths are maximum lengths by default, so use
NLA_POLICY_EXACT_LEN() for the unlabeled IPv4/IPv6 address and mask
attributes.  This rejects short attributes during policy validation and
also exposes the exact length requirements through policy introspection.

Fixes: 8cc44579d1bd ("NetLabel: Introduce static network labels for unlabeled connections")
Signed-off-by: Chenguang Zhao <zhaochenguang@kylinos.cn>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/netlabel/netlabel_unlabeled.c