[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20241216104724.49813-1-kuniyu@amazon.com>
Date: Mon, 16 Dec 2024 19:47:24 +0900
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <shaw.leon@...il.com>
CC: <cong.wang@...edance.com>, <kuniyu@...zon.com>, <netdev@...r.kernel.org>,
<syzbot+21ba4d5adff0b6a7cfc6@...kaller.appspotmail.com>,
<xiyou.wangcong@...il.com>
Subject: Re: [Patch net v2] rtnetlink: fix double call of rtnl_link_get_net_ifla()
From: Xiao Liang <shaw.leon@...il.com>
Date: Mon, 16 Dec 2024 18:24:39 +0800
> > @@ -3812,40 +3818,33 @@ static int rtnl_newlink_create(struct sk_buff *skb, struct ifinfomsg *ifm,
> > goto out;
> > }
> >
> > -static int rtnl_add_peer_net(struct rtnl_nets *rtnl_nets,
> > - const struct rtnl_link_ops *ops,
> > - struct nlattr *data[],
> > - struct netlink_ext_ack *extack)
> > +static struct net *rtnl_get_peer_net(const struct rtnl_link_ops *ops,
> > + struct nlattr *data[],
> > + struct netlink_ext_ack *extack)
> > {
> > struct nlattr *tb[IFLA_MAX + 1];
> > - struct net *net;
> > int err;
> >
> > if (!data || !data[ops->peer_type])
> > - return 0;
> > + return NULL;
>
> I was adding some tests about the link netns stuff, and found
> a behavior change. Prior to this patch, veth, vxcan and netkit
> were trying the outer tb if peer info was not set. But returning
> NULL here skips this part of logic. Say if we have:
>
> ip link add netns ns1 foo type veth
>
> The peer link is changed from ns1 to current netns.
Good catch, we need the following diff.
---8<---
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index ebcfc2debf1a..d9f959c619d9 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -3819,6 +3819,7 @@ static int rtnl_newlink_create(struct sk_buff *skb, struct ifinfomsg *ifm,
}
static struct net *rtnl_get_peer_net(const struct rtnl_link_ops *ops,
+ struct nlattr *tbp[],
struct nlattr *data[],
struct netlink_ext_ack *extack)
{
@@ -3826,7 +3827,7 @@ static struct net *rtnl_get_peer_net(const struct rtnl_link_ops *ops,
int err;
if (!data || !data[ops->peer_type])
- return NULL;
+ return rtnl_link_get_net_ifla(tbp);
err = rtnl_nla_parse_ifinfomsg(tb, data[ops->peer_type], extack);
if (err < 0)
@@ -3971,7 +3972,7 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
}
if (ops->peer_type) {
- peer_net = rtnl_get_peer_net(ops, data, extack);
+ peer_net = rtnl_get_peer_net(ops, tb, data, extack);
if (IS_ERR(peer_net)) {
ret = PTR_ERR(peer_net);
goto put_ops;
---8<---
Powered by blists - more mailing lists