All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net/{ipv4,ipv6}: Do not put target net if input nsid is invalid
@ 2018-10-25 19:18 Bjørn Mork
  2018-10-25 20:16 ` David Ahern
  2018-10-25 23:22 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Bjørn Mork @ 2018-10-25 19:18 UTC (permalink / raw)
  To: netdev; +Cc: Li RongQing, David Miller, Bjørn Mork, David Ahern

The cleanup path will put the target net when netnsid is set.  So we must
reset netnsid if the input is invalid.

Fixes: d7e38611b81e ("net/ipv4: Put target net when address dump fails due to bad attributes")
Fixes: 242afaa6968c ("net/ipv6: Put target net when address dump fails due to bad attributes")
Cc: David Ahern <dsahern@gmail.com>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
 net/ipv4/devinet.c  | 1 +
 net/ipv6/addrconf.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 9250b309c742..a34602ae27de 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1704,6 +1704,7 @@ static int inet_valid_dump_ifaddr_req(const struct nlmsghdr *nlh,
 
 			net = rtnl_get_net_ns_capable(sk, fillargs->netnsid);
 			if (IS_ERR(net)) {
+				fillargs->netnsid = -1;
 				NL_SET_ERR_MSG(extack, "ipv4: Invalid target network namespace id");
 				return PTR_ERR(net);
 			}
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 7eb09c86fa13..63a808d5af15 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -5058,6 +5058,7 @@ static int inet6_valid_dump_ifaddr_req(const struct nlmsghdr *nlh,
 			fillargs->netnsid = nla_get_s32(tb[i]);
 			net = rtnl_get_net_ns_capable(sk, fillargs->netnsid);
 			if (IS_ERR(net)) {
+				fillargs->netnsid = -1;
 				NL_SET_ERR_MSG_MOD(extack, "Invalid target network namespace id");
 				return PTR_ERR(net);
 			}
-- 
2.11.0

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

* Re: [PATCH] net/{ipv4,ipv6}: Do not put target net if input nsid is invalid
  2018-10-25 19:18 [PATCH] net/{ipv4,ipv6}: Do not put target net if input nsid is invalid Bjørn Mork
@ 2018-10-25 20:16 ` David Ahern
  2018-10-25 23:22 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Ahern @ 2018-10-25 20:16 UTC (permalink / raw)
  To: Bjørn Mork, netdev; +Cc: Li RongQing, David Miller

On 10/25/18 1:18 PM, Bjørn Mork wrote:
> The cleanup path will put the target net when netnsid is set.  So we must
> reset netnsid if the input is invalid.
> 
> Fixes: d7e38611b81e ("net/ipv4: Put target net when address dump fails due to bad attributes")
> Fixes: 242afaa6968c ("net/ipv6: Put target net when address dump fails due to bad attributes")
> Cc: David Ahern <dsahern@gmail.com>
> Signed-off-by: Bjørn Mork <bjorn@mork.no>
> ---
>  net/ipv4/devinet.c  | 1 +
>  net/ipv6/addrconf.c | 1 +
>  2 files changed, 2 insertions(+)
> 

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

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

* Re: [PATCH] net/{ipv4,ipv6}: Do not put target net if input nsid is invalid
  2018-10-25 19:18 [PATCH] net/{ipv4,ipv6}: Do not put target net if input nsid is invalid Bjørn Mork
  2018-10-25 20:16 ` David Ahern
@ 2018-10-25 23:22 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-10-25 23:22 UTC (permalink / raw)
  To: bjorn; +Cc: netdev, lirongqing, dsahern

From: Bjørn Mork <bjorn@mork.no>
Date: Thu, 25 Oct 2018 21:18:25 +0200

> The cleanup path will put the target net when netnsid is set.  So we must
> reset netnsid if the input is invalid.
> 
> Fixes: d7e38611b81e ("net/ipv4: Put target net when address dump fails due to bad attributes")
> Fixes: 242afaa6968c ("net/ipv6: Put target net when address dump fails due to bad attributes")
> Cc: David Ahern <dsahern@gmail.com>
> Signed-off-by: Bjørn Mork <bjorn@mork.no>

Applied, thank you.

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

end of thread, other threads:[~2018-10-26  7:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-25 19:18 [PATCH] net/{ipv4,ipv6}: Do not put target net if input nsid is invalid Bjørn Mork
2018-10-25 20:16 ` David Ahern
2018-10-25 23:22 ` David Miller

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.