提交 ec8cc420 编写于 作者: T Taehee Yoo 提交者: Yang Yingliang

gtp: avoid zero size hashtable

[ Upstream commit 6a902c0f31993ab02e1b6ea7085002b9c9083b6a ]

GTP default hashtable size is 1024 and userspace could set specific
hashtable size with IFLA_GTP_PDP_HASHSIZE. If hashtable size is set to 0
from userspace,  hashtable will not work and panic will occur.

Fixes: 459aa660 ("gtp: add initial driver for datapath of GPRS Tunneling Protocol (GTP-U)")
Signed-off-by: NTaehee Yoo <ap420073@gmail.com>
Signed-off-by: NJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 5077dd33
...@@ -671,10 +671,13 @@ static int gtp_newlink(struct net *src_net, struct net_device *dev, ...@@ -671,10 +671,13 @@ static int gtp_newlink(struct net *src_net, struct net_device *dev,
if (err < 0) if (err < 0)
return err; return err;
if (!data[IFLA_GTP_PDP_HASHSIZE]) if (!data[IFLA_GTP_PDP_HASHSIZE]) {
hashsize = 1024; hashsize = 1024;
else } else {
hashsize = nla_get_u32(data[IFLA_GTP_PDP_HASHSIZE]); hashsize = nla_get_u32(data[IFLA_GTP_PDP_HASHSIZE]);
if (!hashsize)
hashsize = 1024;
}
err = gtp_hashtable_new(gtp, hashsize); err = gtp_hashtable_new(gtp, hashsize);
if (err < 0) if (err < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册