Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2019-05-17 06:38:43 +0200
committerJiri Slaby <jslaby@suse.cz>2019-05-17 06:38:51 +0200
commitf5be590f7ea275fcc97119e37b5ef1e597c027c1 (patch)
tree38b6df738009c6e1e5b16408ea844d4e742622de
parent510651760017b9739c09ddaa35bf8559f272e96a (diff)
tuntap: fix dividing by zero in ebpf queue selection
-rw-r--r--patches.kernel.org/5.1.3-029-tuntap-fix-dividing-by-zero-in-ebpf-queue-selec.patch50
-rw-r--r--series.conf1
2 files changed, 51 insertions, 0 deletions
diff --git a/patches.kernel.org/5.1.3-029-tuntap-fix-dividing-by-zero-in-ebpf-queue-selec.patch b/patches.kernel.org/5.1.3-029-tuntap-fix-dividing-by-zero-in-ebpf-queue-selec.patch
new file mode 100644
index 0000000000..68c888a299
--- /dev/null
+++ b/patches.kernel.org/5.1.3-029-tuntap-fix-dividing-by-zero-in-ebpf-queue-selec.patch
@@ -0,0 +1,50 @@
+From: Jason Wang <jasowang@redhat.com>
+Date: Wed, 8 May 2019 23:20:17 -0400
+Subject: [PATCH] tuntap: fix dividing by zero in ebpf queue selection
+References: bnc#1012628
+Patch-mainline: 5.1.3
+Git-commit: a35d310f03a692bf4798eb309a1950a06a150620
+
+[ Upstream commit a35d310f03a692bf4798eb309a1950a06a150620 ]
+
+We need check if tun->numqueues is zero (e.g for the persist device)
+before trying to use it for modular arithmetic.
+
+Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
+Fixes: 96f84061620c6("tun: add eBPF based queue selection method")
+Signed-off-by: Jason Wang <jasowang@redhat.com>
+Reviewed-by: Eric Dumazet <edumazet@google.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Jiri Slaby <jslaby@suse.cz>
+---
+ drivers/net/tun.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/net/tun.c b/drivers/net/tun.c
+index e9ca1c088d0b..dc62fc3c5a95 100644
+--- a/drivers/net/tun.c
++++ b/drivers/net/tun.c
+@@ -596,13 +596,18 @@ static u16 tun_automq_select_queue(struct tun_struct *tun, struct sk_buff *skb)
+ static u16 tun_ebpf_select_queue(struct tun_struct *tun, struct sk_buff *skb)
+ {
+ struct tun_prog *prog;
++ u32 numqueues;
+ u16 ret = 0;
+
++ numqueues = READ_ONCE(tun->numqueues);
++ if (!numqueues)
++ return 0;
++
+ prog = rcu_dereference(tun->steering_prog);
+ if (prog)
+ ret = bpf_prog_run_clear_cb(prog->prog, skb);
+
+- return ret % tun->numqueues;
++ return ret % numqueues;
+ }
+
+ static u16 tun_select_queue(struct net_device *dev, struct sk_buff *skb,
+--
+2.21.0
+
diff --git a/series.conf b/series.conf
index bf60185e90..af7f32761c 100644
--- a/series.conf
+++ b/series.conf
@@ -114,6 +114,7 @@
patches.kernel.org/5.1.3-026-tipc-fix-hanging-clients-using-poll-with-EPOLLO.patch
patches.kernel.org/5.1.3-027-vlan-disable-SIOCSHWTSTAMP-in-container.patch
patches.kernel.org/5.1.3-028-vrf-sit-mtu-should-not-be-updated-when-vrf-netd.patch
+ patches.kernel.org/5.1.3-029-tuntap-fix-dividing-by-zero-in-ebpf-queue-selec.patch
########################################################
# Build fixes that apply to the vanilla kernel too.