ipv6/addrconf: only check invalid header values when NETLINK_F_STRICT_CHK is set
Subsystems (3)
PATCH 1/1 ipv6/addrconf: only check invalid header values when NETLINK_F_STRICT_CHK is set
In patch 4b1373de73a3 ("net: ipv6: addr: perform strict checks also for doit handlers") we add strict check for inet6_rtm_getaddr(). But we did the invalid header values check before checking if NETLINK_F_STRICT_CHK is set. This may break backwards compatibility if user already set the ifm->ifa_prefixlen, ifm->ifa_flags, ifm->ifa_scope in their netlink code.
I didn't move the nlmsg_len check becuase I thought it's a valid check.
--- net/ipv6/addrconf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/ipv6/addrconf.c +4 -4
@@ -5231,16 +5231,16 @@ static int inet6_rtm_valid_getaddr_req(struct sk_buff *skb,return -EINVAL ; } +if (!netlink_strict_get_check (skb)) +return nlmsg_parse_deprecated (nlh,sizeof (*ifm), tb,IFA_MAX , + ifa_ipv6_policy, extack); + ifm =nlmsg_data (nlh);if (ifm->ifa_prefixlen || ifm->ifa_flags || ifm->ifa_scope) {NL_SET_ERR_MSG_MOD (extack,"Invalid values in header for get address request" );return -EINVAL ; } -if (!netlink_strict_get_check (skb)) -return nlmsg_parse_deprecated (nlh,sizeof (*ifm), tb,IFA_MAX , - ifa_ipv6_policy, extack); - err =nlmsg_parse_deprecated_strict (nlh,sizeof (*ifm), tb,IFA_MAX , ifa_ipv6_policy, extack);if (err)
Signature · 1 line
2.19.2
Quoted 6 lines · Hangbin Liu
In patch
4b1373de73a3("net: ipv6: addr: perform strict checks also for doit handlers") we add strict check forinet6_rtm_getaddr(). But we did the invalid header values check before checking ifNETLINK_F_STRICT_CHKis set. This may break backwards compatibility if user already set theifm->ifa_prefixlen,ifm->ifa_flags,ifm->ifa_scopein their netlink code.
Quoted 9 lines
I didn't move the
nlmsg_lencheck becuase I thought it's a valid check.Reported-by Jianlin Shi <[email protected]>Fixes 4b1373de73a3 ("net: ipv6: addr: perform strict checks also for doit handlers")Signed-off-by Hangbin Liu <[email protected]>--- net/ipv6/addrconf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Looks right to me.
Jakub Kicinski
AppliedQuoted 11 lines · Hangbin Liu
In patch
4b1373de73a3("net: ipv6: addr: perform strict checks also for doit handlers") we add strict check forinet6_rtm_getaddr(). But we did the invalid header values check before checking ifNETLINK_F_STRICT_CHKis set. This may break backwards compatibility if user already set theifm->ifa_prefixlen,ifm->ifa_flags,ifm->ifa_scopein their netlink code.I didn't move the
nlmsg_lencheck becuase I thought it's a valid check.Reported-by Jianlin Shi <[email protected]>Fixes 4b1373de73a3 ("net: ipv6: addr: perform strict checks also for doit handlers")Signed-off-by Hangbin Liu <[email protected]>
Applied, and queued for stable, thanks!