netlink/route: validate family attribute

PR:			283818
(cherry picked from commit cdacb12065e4d85416655743da5bc6b17a9d9119)
This commit is contained in:
Gleb Smirnoff 2025-01-29 15:40:56 -08:00 committed by Franco Fichtner
parent 5add872c4e
commit a47d77f946

View File

@ -956,7 +956,7 @@ rtnl_handle_newroute(struct nlmsghdr *hdr, struct nlpcb *nlp,
/* pre-2.6.19 Linux API compatibility */
if (attrs.rtm_table > 0 && attrs.rta_table == 0)
attrs.rta_table = attrs.rtm_table;
if (attrs.rta_table >= V_rt_numfibs) {
if (attrs.rta_table >= V_rt_numfibs || attrs.rtm_family > AF_MAX) {
NLMSG_REPORT_ERR_MSG(npt, "invalid fib");
return (EINVAL);
}
@ -1019,7 +1019,7 @@ rtnl_handle_delroute(struct nlmsghdr *hdr, struct nlpcb *nlp,
return (ESRCH);
}
if (attrs.rta_table >= V_rt_numfibs) {
if (attrs.rta_table >= V_rt_numfibs || attrs.rtm_family > AF_MAX) {
NLMSG_REPORT_ERR_MSG(npt, "invalid fib");
return (EINVAL);
}
@ -1042,7 +1042,7 @@ rtnl_handle_getroute(struct nlmsghdr *hdr, struct nlpcb *nlp, struct nl_pstate *
if (error != 0)
return (error);
if (attrs.rta_table >= V_rt_numfibs) {
if (attrs.rta_table >= V_rt_numfibs || attrs.rtm_family > AF_MAX) {
NLMSG_REPORT_ERR_MSG(npt, "invalid fib");
return (EINVAL);
}