From f622ffd9bcfad8be64e716cbcbb656b6fc53694d Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Wed, 16 Jan 2019 09:41:28 +0100 Subject: [PATCH] batman-adv: Merge bugfixes from 2019.0 * Avoid WARN on net_device without parent in netns * Force mac header to start of data on xmit Signed-off-by: Sven Eckelmann --- batman-adv/Makefile | 2 +- ...-WARN-on-net_device-without-parent-i.patch | 48 +++++++++++++++++++ ...-mac-header-to-start-of-data-on-xmit.patch | 39 +++++++++++++++ 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 batman-adv/patches/0058-batman-adv-Avoid-WARN-on-net_device-without-parent-i.patch create mode 100644 batman-adv/patches/0059-batman-adv-Force-mac-header-to-start-of-data-on-xmit.patch diff --git a/batman-adv/Makefile b/batman-adv/Makefile index 09c3692..252fd3f 100644 --- a/batman-adv/Makefile +++ b/batman-adv/Makefile @@ -11,7 +11,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=batman-adv PKG_VERSION:=2016.5 -PKG_RELEASE:=11 +PKG_RELEASE:=12 PKG_MD5SUM:=6717a933a08dd2a01b00df30cb9f16a8 PKG_HASH:=d0a0fc90c4f410b57d043215e253bb0b855efa5edbe165d87c17bfdcfafd0db7 diff --git a/batman-adv/patches/0058-batman-adv-Avoid-WARN-on-net_device-without-parent-i.patch b/batman-adv/patches/0058-batman-adv-Avoid-WARN-on-net_device-without-parent-i.patch new file mode 100644 index 0000000..647e191 --- /dev/null +++ b/batman-adv/patches/0058-batman-adv-Avoid-WARN-on-net_device-without-parent-i.patch @@ -0,0 +1,48 @@ +From: Sven Eckelmann +Date: Sun, 30 Dec 2018 12:46:01 +0100 +Subject: [PATCH] batman-adv: Avoid WARN on net_device without parent in netns + +It is not allowed to use WARN* helpers on potential incorrect input from +the user or transient problems because systems configured as panic_on_warn +will reboot due to such a problem. + +A NULL return value of __dev_get_by_index can be caused by various problems +which can either be related to the system configuration or problems +(incorrectly returned network namespaces) in other (virtual) net_device +drivers. batman-adv should not cause a (harmful) WARN in this situation and +instead only report it via a simple message. + +Fixes: 3d48811b27f5 ("batman-adv: prevent using any virtual device created on batman-adv as hard-interface") +Reported-by: syzbot+c764de0fcfadca9a8595@syzkaller.appspotmail.com +Reported-by: Dmitry Vyukov +Signed-off-by: Sven Eckelmann + +Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/59ad04405be86f648fd83d81d2fd0a78f215a43b +--- + net/batman-adv/hard-interface.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c +index 23d3893264f989c9740e68d83f6db300dee20dc3..c9a3b7bc07bcc443281c4f12c750c4d925c3b2c3 100644 +--- a/net/batman-adv/hard-interface.c ++++ b/net/batman-adv/hard-interface.c +@@ -19,7 +19,6 @@ + #include "main.h" + + #include +-#include + #include + #include + #include +@@ -176,8 +175,10 @@ static bool batadv_is_on_batman_iface(const struct net_device *net_dev) + parent_dev = __dev_get_by_index((struct net *)parent_net, + dev_get_iflink(net_dev)); + /* if we got a NULL parent_dev there is something broken.. */ +- if (WARN(!parent_dev, "Cannot find parent device")) ++ if (!parent_dev) { ++ pr_err("Cannot find parent device\n"); + return false; ++ } + + if (batadv_mutual_parents(net_dev, net, parent_dev, parent_net)) + return false; diff --git a/batman-adv/patches/0059-batman-adv-Force-mac-header-to-start-of-data-on-xmit.patch b/batman-adv/patches/0059-batman-adv-Force-mac-header-to-start-of-data-on-xmit.patch new file mode 100644 index 0000000..dba1826 --- /dev/null +++ b/batman-adv/patches/0059-batman-adv-Force-mac-header-to-start-of-data-on-xmit.patch @@ -0,0 +1,39 @@ +From: Sven Eckelmann +Date: Mon, 31 Dec 2018 22:46:09 +0100 +Subject: [PATCH] batman-adv: Force mac header to start of data on xmit + +The caller of ndo_start_xmit may not already have called +skb_reset_mac_header. The returned value of skb_mac_header/eth_hdr +therefore can be in the wrong position and even outside the current skbuff. +This for example happens when the user binds to the device using a +PF_PACKET-SOCK_RAW with enabled qdisc-bypass: + + int opt = 4; + setsockopt(sock, SOL_PACKET, PACKET_QDISC_BYPASS, &opt, sizeof(opt)); + +Since eth_hdr is used all over the codebase, the batadv_interface_tx +function must always take care of resetting it. + +Fixes: fe28a94c01e1 ("batman-adv: receive packets directly using skbs") +Reported-by: syzbot+9d7405c7faa390e60b4e@syzkaller.appspotmail.com +Reported-by: syzbot+7d20bc3f1ddddc0f9079@syzkaller.appspotmail.com +Signed-off-by: Sven Eckelmann + +Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/74c4b0c50f19f986752ee18ed393732f4eed7a66 +--- + net/batman-adv/soft-interface.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c +index ff797f32fb3bb81dafe1e7d3e9c6307e6a5aaff1..f590c7b2c76816303fe1d3f5d2858e3a9b126539 100644 +--- a/net/batman-adv/soft-interface.c ++++ b/net/batman-adv/soft-interface.c +@@ -232,6 +232,8 @@ static int batadv_interface_tx(struct sk_buff *skb, + + netif_trans_update(soft_iface); + vid = batadv_get_vid(skb, 0); ++ ++ skb_reset_mac_header(skb); + ethhdr = eth_hdr(skb); + + switch (ntohs(ethhdr->h_proto)) { -- 2.30.2