Skip to content

Commit 664b9c4

Browse files
dsaherndavem330
authored andcommitted
ipv4: Check attribute length for RTA_FLOW in multipath route
Make sure RTA_FLOW is at least 4B before using. Fixes: 4e902c5 ("[IPv4]: FIB configuration using struct fib_config") Signed-off-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7a3429b commit 664b9c4

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

net/ipv4/fib_semantics.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -731,8 +731,13 @@ static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh,
731731
}
732732

733733
nla = nla_find(attrs, attrlen, RTA_FLOW);
734-
if (nla)
734+
if (nla) {
735+
if (nla_len(nla) < sizeof(u32)) {
736+
NL_SET_ERR_MSG(extack, "Invalid RTA_FLOW");
737+
return -EINVAL;
738+
}
735739
fib_cfg.fc_flow = nla_get_u32(nla);
740+
}
736741

737742
fib_cfg.fc_encap = nla_find(attrs, attrlen, RTA_ENCAP);
738743
nla = nla_find(attrs, attrlen, RTA_ENCAP_TYPE);
@@ -963,8 +968,14 @@ int fib_nh_match(struct net *net, struct fib_config *cfg, struct fib_info *fi,
963968

964969
#ifdef CONFIG_IP_ROUTE_CLASSID
965970
nla = nla_find(attrs, attrlen, RTA_FLOW);
966-
if (nla && nla_get_u32(nla) != nh->nh_tclassid)
967-
return 1;
971+
if (nla) {
972+
if (nla_len(nla) < sizeof(u32)) {
973+
NL_SET_ERR_MSG(extack, "Invalid RTA_FLOW");
974+
return -EINVAL;
975+
}
976+
if (nla_get_u32(nla) != nh->nh_tclassid)
977+
return 1;
978+
}
968979
#endif
969980
}
970981

0 commit comments

Comments
 (0)