Skip to content

Commit 035d210

Browse files
borkmanndavem330
authored andcommitted
rtnetlink: reject non-IFLA_VF_PORT attributes inside IFLA_VF_PORTS
Similarly as in commit 4f7d2cd ("rtnetlink: verify IFLA_VF_INFO attributes before passing them to driver"), we have a double nesting of netlink attributes, i.e. IFLA_VF_PORTS only contains IFLA_VF_PORT that is nested itself. While IFLA_VF_PORTS is a verified attribute from ifla_policy[], we only check if the IFLA_VF_PORTS container has IFLA_VF_PORT attributes and then pass the attribute's content itself via nla_parse_nested(). It would be more correct to reject inner types other than IFLA_VF_PORT instead of continuing parsing and also similarly as in commit 4f7d2cd, to check for a minimum of NLA_HDRLEN. Signed-off-by: Daniel Borkmann <[email protected]> Cc: Roopa Prabhu <[email protected]> Cc: Scott Feldman <[email protected]> Cc: Jason Gunthorpe <[email protected]> Acked-by: Roopa Prabhu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 50c2e4d commit 035d210

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

net/core/rtnetlink.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,10 +1804,13 @@ static int do_setlink(const struct sk_buff *skb,
18041804
goto errout;
18051805

18061806
nla_for_each_nested(attr, tb[IFLA_VF_PORTS], rem) {
1807-
if (nla_type(attr) != IFLA_VF_PORT)
1808-
continue;
1809-
err = nla_parse_nested(port, IFLA_PORT_MAX,
1810-
attr, ifla_port_policy);
1807+
if (nla_type(attr) != IFLA_VF_PORT ||
1808+
nla_len(attr) < NLA_HDRLEN) {
1809+
err = -EINVAL;
1810+
goto errout;
1811+
}
1812+
err = nla_parse_nested(port, IFLA_PORT_MAX, attr,
1813+
ifla_port_policy);
18111814
if (err < 0)
18121815
goto errout;
18131816
if (!port[IFLA_PORT_VF]) {

0 commit comments

Comments
 (0)