All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] ipv6/addrconf: only check invalid header values when NETLINK_F_STRICT_CHK is set
@ 2019-12-11 14:20 Hangbin Liu
  2019-12-11 15:44 ` David Ahern
  2019-12-14  1:15 ` Jakub Kicinski
  0 siblings, 2 replies; 3+ messages in thread
From: Hangbin Liu @ 2019-12-11 14:20 UTC (permalink / raw)
  To: netdev; +Cc: Jakub Kicinski, Jiri Benc, David Miller, Hangbin Liu

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.

Reported-by: Jianlin Shi <jishi@redhat.com>
Fixes: 4b1373de73a3 ("net: ipv6: addr: perform strict checks also for doit handlers")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 net/ipv6/addrconf.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 98d82305d6de..39d861d00377 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -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)
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] ipv6/addrconf: only check invalid header values when NETLINK_F_STRICT_CHK is set
  2019-12-11 14:20 [PATCH net] ipv6/addrconf: only check invalid header values when NETLINK_F_STRICT_CHK is set Hangbin Liu
@ 2019-12-11 15:44 ` David Ahern
  2019-12-14  1:15 ` Jakub Kicinski
  1 sibling, 0 replies; 3+ messages in thread
From: David Ahern @ 2019-12-11 15:44 UTC (permalink / raw)
  To: Hangbin Liu, netdev; +Cc: Jakub Kicinski, Jiri Benc, David Miller

On 12/11/19 7:20 AM, Hangbin Liu wrote:
> 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.
> 
> Reported-by: Jianlin Shi <jishi@redhat.com>
> Fixes: 4b1373de73a3 ("net: ipv6: addr: perform strict checks also for doit handlers")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> ---
>  net/ipv6/addrconf.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 

Looks right to me.

Reviewed-by: David Ahern <dsahern@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] ipv6/addrconf: only check invalid header values when NETLINK_F_STRICT_CHK is set
  2019-12-11 14:20 [PATCH net] ipv6/addrconf: only check invalid header values when NETLINK_F_STRICT_CHK is set Hangbin Liu
  2019-12-11 15:44 ` David Ahern
@ 2019-12-14  1:15 ` Jakub Kicinski
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2019-12-14  1:15 UTC (permalink / raw)
  To: Hangbin Liu; +Cc: netdev, Jiri Benc, David Miller

On Wed, 11 Dec 2019 22:20:16 +0800, Hangbin Liu wrote:
> 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.
> 
> Reported-by: Jianlin Shi <jishi@redhat.com>
> Fixes: 4b1373de73a3 ("net: ipv6: addr: perform strict checks also for doit handlers")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>

Applied, and queued for stable, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-14  1:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-11 14:20 [PATCH net] ipv6/addrconf: only check invalid header values when NETLINK_F_STRICT_CHK is set Hangbin Liu
2019-12-11 15:44 ` David Ahern
2019-12-14  1:15 ` Jakub Kicinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.