Skip to content

Commit 2beb6d2

Browse files
liuhangbinJakub Kicinski
authored andcommitted
ipv6/addrconf: only check invalid header values when NETLINK_F_STRICT_CHK is set
In commit 4b1373d ("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 because I thought it's a valid check. Reported-by: Jianlin Shi <[email protected]> Fixes: 4b1373d ("net: ipv6: addr: perform strict checks also for doit handlers") Signed-off-by: Hangbin Liu <[email protected]> Reviewed-by: David Ahern <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 03b06e3 commit 2beb6d2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

net/ipv6/addrconf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5231,16 +5231,16 @@ static int inet6_rtm_valid_getaddr_req(struct sk_buff *skb,
52315231
return -EINVAL;
52325232
}
52335233

5234+
if (!netlink_strict_get_check(skb))
5235+
return nlmsg_parse_deprecated(nlh, sizeof(*ifm), tb, IFA_MAX,
5236+
ifa_ipv6_policy, extack);
5237+
52345238
ifm = nlmsg_data(nlh);
52355239
if (ifm->ifa_prefixlen || ifm->ifa_flags || ifm->ifa_scope) {
52365240
NL_SET_ERR_MSG_MOD(extack, "Invalid values in header for get address request");
52375241
return -EINVAL;
52385242
}
52395243

5240-
if (!netlink_strict_get_check(skb))
5241-
return nlmsg_parse_deprecated(nlh, sizeof(*ifm), tb, IFA_MAX,
5242-
ifa_ipv6_policy, extack);
5243-
52445244
err = nlmsg_parse_deprecated_strict(nlh, sizeof(*ifm), tb, IFA_MAX,
52455245
ifa_ipv6_policy, extack);
52465246
if (err)

0 commit comments

Comments
 (0)