Message ID | 20220705005058.3971-1-hoang.h.le@dektech.com.au (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next] tipc: fix uninit-value in tipc_nl_node_reset_link_stats | expand |
On Tue, 5 Jul 2022 07:50:57 +0700 Hoang Le wrote: > Reported-by: syzbot+a73d24a22eeeebe5f244@syzkaller.appspotmail.com > Acked-by: Jon Maloy <jmaloy@redhat.com> > Signed-off-by: Hoang Le <hoang.h.le@dektech.com.au> Can we get a Fixes tag please? > diff --git a/net/tipc/node.c b/net/tipc/node.c > index b48d97cbbe29..23419a599471 100644 > --- a/net/tipc/node.c > +++ b/net/tipc/node.c > @@ -2561,6 +2561,7 @@ int tipc_nl_node_reset_link_stats(struct sk_buff *skb, struct genl_info *info) > struct net *net = sock_net(skb->sk); > struct tipc_net *tn = tipc_net(net); > struct tipc_link_entry *le; > + int len; > > if (!info->attrs[TIPC_NLA_LINK]) > return -EINVAL; > @@ -2574,7 +2575,14 @@ int tipc_nl_node_reset_link_stats(struct sk_buff *skb, struct genl_info *info) > if (!attrs[TIPC_NLA_LINK_NAME]) > return -EINVAL; > > + len = nla_len(attrs[TIPC_NLA_LINK_NAME]); > + if (len <= 0) > + return -EINVAL; > + > link_name = nla_data(attrs[TIPC_NLA_LINK_NAME]); > + len = min_t(int, len, TIPC_MAX_LINK_NAME); > + if (!memchr(link_name, '\0', len)) > + return -EINVAL; Should we just change the netlink policy for this attribute to NLA_NUL_STRING, then?
> -----Original Message----- > From: Jakub Kicinski <kuba@kernel.org> > Sent: Wednesday, July 6, 2022 8:53 AM > To: Hoang Huu Le <hoang.h.le@dektech.com.au> > Cc: jmaloy@redhat.com; maloy@donjonn.com; ying.xue@windriver.com; Tung Quang Nguyen <tung.q.nguyen@dektech.com.au>; > pabeni@redhat.com; edumazet@google.com; tipc-discussion@lists.sourceforge.net; netdev@vger.kernel.org; > davem@davemloft.net; syzbot+a73d24a22eeeebe5f244@syzkaller.appspotmail.com > Subject: Re: [net-next] tipc: fix uninit-value in tipc_nl_node_reset_link_stats > > On Tue, 5 Jul 2022 07:50:57 +0700 Hoang Le wrote: > > Reported-by: syzbot+a73d24a22eeeebe5f244@syzkaller.appspotmail.com > > Acked-by: Jon Maloy <jmaloy@redhat.com> > > Signed-off-by: Hoang Le <hoang.h.le@dektech.com.au> > > Can we get a Fixes tag please? > > > diff --git a/net/tipc/node.c b/net/tipc/node.c > > index b48d97cbbe29..23419a599471 100644 > > --- a/net/tipc/node.c > > +++ b/net/tipc/node.c > > @@ -2561,6 +2561,7 @@ int tipc_nl_node_reset_link_stats(struct sk_buff *skb, struct genl_info *info) > > struct net *net = sock_net(skb->sk); > > struct tipc_net *tn = tipc_net(net); > > struct tipc_link_entry *le; > > + int len; > > > > if (!info->attrs[TIPC_NLA_LINK]) > > return -EINVAL; > > @@ -2574,7 +2575,14 @@ int tipc_nl_node_reset_link_stats(struct sk_buff *skb, struct genl_info *info) > > if (!attrs[TIPC_NLA_LINK_NAME]) > > return -EINVAL; > > > > + len = nla_len(attrs[TIPC_NLA_LINK_NAME]); > > + if (len <= 0) > > + return -EINVAL; > > + > > link_name = nla_data(attrs[TIPC_NLA_LINK_NAME]); > > + len = min_t(int, len, TIPC_MAX_LINK_NAME); > > + if (!memchr(link_name, '\0', len)) > > + return -EINVAL; > > Should we just change the netlink policy for this attribute to > NLA_NUL_STRING, then? I recognize this is redundant check. I will post v2 into net.
diff --git a/net/tipc/node.c b/net/tipc/node.c index b48d97cbbe29..23419a599471 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -2561,6 +2561,7 @@ int tipc_nl_node_reset_link_stats(struct sk_buff *skb, struct genl_info *info) struct net *net = sock_net(skb->sk); struct tipc_net *tn = tipc_net(net); struct tipc_link_entry *le; + int len; if (!info->attrs[TIPC_NLA_LINK]) return -EINVAL; @@ -2574,7 +2575,14 @@ int tipc_nl_node_reset_link_stats(struct sk_buff *skb, struct genl_info *info) if (!attrs[TIPC_NLA_LINK_NAME]) return -EINVAL; + len = nla_len(attrs[TIPC_NLA_LINK_NAME]); + if (len <= 0) + return -EINVAL; + link_name = nla_data(attrs[TIPC_NLA_LINK_NAME]); + len = min_t(int, len, TIPC_MAX_LINK_NAME); + if (!memchr(link_name, '\0', len)) + return -EINVAL; err = -EINVAL; if (!strcmp(link_name, tipc_bclink_name)) {