batman-adv: Refresh patches
[feed/routing.git] / batman-adv / patches / 0022-batman-adv-Avoid-WARN-on-net_device-without-parent-i.patch
1 From: Sven Eckelmann <sven@narfation.org>
2 Date: Sun, 30 Dec 2018 12:46:01 +0100
3 Subject: batman-adv: Avoid WARN on net_device without parent in netns
4
5 It is not allowed to use WARN* helpers on potential incorrect input from
6 the user or transient problems because systems configured as panic_on_warn
7 will reboot due to such a problem.
8
9 A NULL return value of __dev_get_by_index can be caused by various problems
10 which can either be related to the system configuration or problems
11 (incorrectly returned network namespaces) in other (virtual) net_device
12 drivers. batman-adv should not cause a (harmful) WARN in this situation and
13 instead only report it via a simple message.
14
15 Fixes: 3d48811b27f5 ("batman-adv: prevent using any virtual device created on batman-adv as hard-interface")
16 Reported-by: syzbot+c764de0fcfadca9a8595@syzkaller.appspotmail.com
17 Reported-by: Dmitry Vyukov <dvyukov@google.com>
18 Signed-off-by: Sven Eckelmann <sven@narfation.org>
19
20 Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/59ad04405be86f648fd83d81d2fd0a78f215a43b
21
22 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
23 index 2f0d42f2f913e74cf10c0c6ce89320434994cac5..08690d06b7be2b25ca3f009394763c7083c70644 100644
24 --- a/net/batman-adv/hard-interface.c
25 +++ b/net/batman-adv/hard-interface.c
26 @@ -20,7 +20,6 @@
27 #include "main.h"
28
29 #include <linux/atomic.h>
30 -#include <linux/bug.h>
31 #include <linux/byteorder/generic.h>
32 #include <linux/errno.h>
33 #include <linux/gfp.h>
34 @@ -179,8 +178,10 @@ static bool batadv_is_on_batman_iface(const struct net_device *net_dev)
35 parent_dev = __dev_get_by_index((struct net *)parent_net,
36 dev_get_iflink(net_dev));
37 /* if we got a NULL parent_dev there is something broken.. */
38 - if (WARN(!parent_dev, "Cannot find parent device"))
39 + if (!parent_dev) {
40 + pr_err("Cannot find parent device\n");
41 return false;
42 + }
43
44 if (batadv_mutual_parents(net_dev, net, parent_dev, parent_net))
45 return false;