diff options
author | Taehee Yoo <ap420073@gmail.com> | 2019-12-11 09:23:48 +0100 |
---|---|---|
committer | Jakub Kicinski <jakub.kicinski@netronome.com> | 2019-12-15 02:15:24 +0100 |
commit | 6a902c0f31993ab02e1b6ea7085002b9c9083b6a (patch) | |
tree | 0c3c21f1217705dad14aecd5de3c69715fc70760 /drivers | |
parent | gtp: fix an use-after-free in ipv4_pdp_find() (diff) | |
download | linux-6a902c0f31993ab02e1b6ea7085002b9c9083b6a.tar.xz linux-6a902c0f31993ab02e1b6ea7085002b9c9083b6a.zip |
gtp: avoid zero size hashtable
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: 459aa660eb1d ("gtp: add initial driver for datapath of GPRS Tunneling Protocol (GTP-U)")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/gtp.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index 5450b1099c6d..e5b7d6d2286e 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -667,10 +667,13 @@ static int gtp_newlink(struct net *src_net, struct net_device *dev, if (err < 0) return err; - if (!data[IFLA_GTP_PDP_HASHSIZE]) + if (!data[IFLA_GTP_PDP_HASHSIZE]) { hashsize = 1024; - else + } else { hashsize = nla_get_u32(data[IFLA_GTP_PDP_HASHSIZE]); + if (!hashsize) + hashsize = 1024; + } err = gtp_hashtable_new(gtp, hashsize); if (err < 0) |