]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
gtp: avoid zero size hashtable
authorTaehee Yoo <ap420073@gmail.com>
Wed, 11 Dec 2019 08:23:48 +0000 (08:23 +0000)
committerKhalid Elmously <khalid.elmously@canonical.com>
Wed, 29 Jan 2020 04:47:27 +0000 (23:47 -0500)
BugLink: https://bugs.launchpad.net/bugs/1860602
[ 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: 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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/net/gtp.c

index 51043a637719d9fc0ab1c4b988eb2d3e2138ee6f..35905e9ee9ecf940a1500148c624c306672929ed 100644 (file)
@@ -671,10 +671,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)