Skip to contentSkip to conversation

openwrt routing feed: add three ordex patches for anti-panic, anti-leaking

PATCH In review Russell Senior 2 participants 7 messages Feb 13, 2014 – Feb 14, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 openwrt routing feed: add three ordex patches for anti-panic, anti-leaking

These three patches successfully stopped panics and memory leaks for me, tested during some extended IRC sessions. Thanks Antonio!

This patch adds them to the OpenWrt routing feed patches directory for batman-adv.

---
 ...set-mac_header-when-forging-an-ARP-reply-.patch | 38 ++++++++++
 .../0010-batman-adv-byte-order-affects-crc.patch   | 83 ++++++++++++++++++++++
 .../patches/0011-batman-adv-memory-leak-fix.patch  | 39 ++++++++++
 3 files changed, 160 insertions(+)
 create mode 100644 batman-adv/patches/0008-batman-adv-set-mac_header-when-forging-an-ARP-reply-.patch
 create mode 100644 batman-adv/patches/0010-batman-adv-byte-order-affects-crc.patch
 create mode 100644 batman-adv/patches/0011-batman-adv-memory-leak-fix.patch
batman-adv/patches/0008-batman-adv-set-mac_header-when-forging-an-ARP-reply-.patch new file +38 -0
new file mode 100644
index 0000000..67c6dde
@@ -0,0 +1,38 @@
+From 9cfee06f7350c28881b5cb0bfa2901c3b726eb1a Mon Sep 17 00:00:00 2001
+From: Antonio Quartulli <[email protected]>
+Date: Fri, 31 Jan 2014 00:51:50 +0100
+Subject: [PATCH 8/9] batman-adv: set mac_header when forging an ARP reply in
+ DAT
+
+In the TX path we now have functions that rely on the
+skb->mac_header field. DAT does not set such field when
+creating its own ARP packets thus leading to wrong memory
+access.
+
+Fix it by always setting the mac_header after having forged
+the ARP packet.
+
+Signed-off-by: Antonio Quartulli <[email protected]>
+---
+ distributed-arp-table.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/distributed-arp-table.c b/distributed-arp-table.c
+index 6da587a..0b69b61 100644
+--- a/distributed-arp-table.c
++++ b/distributed-arp-table.c
+@@ -1028,6 +1028,11 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
+ 	if (!skb_new)
+ 		goto out;
+ 
++	/* the rest of the TX path assumes that the mac_header offset pointing
++	 * to the inner Ethernet header has been set, therefore reset it now.
++	 */
++	skb_reset_mac_header(skb_new);
++
+ 	if (vid & BATADV_VLAN_HAS_TAG)
+ 		skb_new = vlan_insert_tag(skb_new, htons(ETH_P_8021Q),
+ 					  vid & VLAN_VID_MASK);
+-- 
+1.8.5.3
+
batman-adv/patches/0010-batman-adv-byte-order-affects-crc.patch new file +83 -0

83 lines not on this page · raw message

batman-adv/patches/0011-batman-adv-memory-leak-fix.patch new file +39 -0
new file mode 100644
index 0000000..c991d5d
@@ -0,0 +1,39 @@
+From: Antonio Quartulli <[email protected]>
+To: [email protected]
+Date: Tue, 11 Feb 2014 17:05:07 +0100
+Subject: [B.A.T.M.A.N.] [PATCH maint 2/2] batman-adv: free skb on TVLV
+	parsing success
+
+From: Antonio Quartulli <[email protected]>
+
+When the TVLV parsing routine succeed the skb is left
+untouched thus leading to a memory leak.
+
+Fix this by consuming the skb in case of success.
+
+Introduced by 0b6aa0d43767889eeda43a132cf5e73df4e63bf2
+("batman-adv: tvlv - basic infrastructure")
+
+Signed-off-by: Antonio Quartulli <[email protected]>
+---
+ routing.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/routing.c b/routing.c
+index f7579d0..71bf698 100644
+--- a/routing.c
++++ b/routing.c
+@@ -1063,6 +1063,8 @@ int batadv_recv_unicast_tvlv(struct sk_buff *skb,
+ 
+ 	if (ret != NET_RX_SUCCESS)
+ 		ret = batadv_route_unicast_packet(skb, recv_if);
++	else
++		consume_skb(skb);
+ 
+ 	return ret;
+ }
+-- 
+1.8.5.3
+
+
+
Signature · 7 lines
1.8.1.2



-- 
Russell Senior, President
[email protected]
#1 lore raw

PATCH 2/4 openwrt routing feed: batman-adv: split kmod and userland into separate packages

Creates a new package, batctl, split out from the batman-adv package. Simplifies the Makefiles, allows QUILT patch management to work, removes the quirky naming requirement for patches. The batctl package is a dependency of kmod-batman-adv, retaining the existing dependency relationship.

---
 batctl/Makefile                                    | 66 +++++++++++++++++
 batman-adv/Config.in                               |  9 ---
 batman-adv/Makefile                                | 84 +++-------------------
 .../patches/0011-batman-adv-memory-leak-fix.patch  | 15 ++--
 4 files changed, 80 insertions(+), 94 deletions(-)
 create mode 100644 batctl/Makefile
batctl/Makefile new file +66 -0
new file mode 100644
index 0000000..7a34957
@@ -0,0 +1,66 @@
+#
+# Copyright (C) 2010-2014 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=batctl
+PKG_VERSION:=2014.0.0
+PKG_RELEASE:=2
+PKG_MD5SUM:=b0bcf29fef80ddcc33769e13f5937d0a
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/batctl
+  URL:=http://www.open-mesh.org/
+  SECTION:=net
+  CATEGORY:=Network
+  TITLE:=B.A.T.M.A.N. Advanced user space configuration tool batctl
+  MAINTAINER:=Marek Lindner <[email protected]>
+endef
+
+define Package/batctl/description
+B.A.T.M.A.N. advanced is a kernel module which allows to
+build layer 2 mesh networks. This package contains the
+version $(PKG_VERSION) of the user space configuration & 
+management tool batctl.
+endef
+
+TARGET_CFLAGS  += -ffunction-sections -fdata-sections
+TARGET_LDFLAGS += -Wl,--gc-sections
+
+# Link-time optimization allows to move parts of the optimization from the single
+# source file to the global source view. This is done by emitting the GIMPLE
+# representation in each object file and analyzing it again during the link step.
+
+TARGET_CFLAGS  += -flto
+TARGET_LDFLAGS += -fuse-linker-plugin
+
+MAKE_BATCTL_ENV += \
+        CPPFLAGS="$(TARGET_CPPFLAGS)" \
+        CFLAGS="$(TARGET_CFLAGS)" \
+        LDFLAGS="$(TARGET_LDFLAGS)"
+
+MAKE_BATCTL_ARGS += \
+        REVISION="" \
+        CC="$(TARGET_CC)" \
+        DESTDIR="$(PKG_INSTALL_DIR)" \
+        batctl install
+
+
+define Build/compile
+	$(MAKE_BATCTL_ENV) $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_BATCTL_ARGS)
+endef
+
+define Package/batctl/install
+	$(INSTALL_DIR) $(1)/usr/sbin
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_NAME) $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,batctl))
batman-adv/Config.in +0 -9
index 1330525..160d3a3 100644
@@ -18,12 +18,3 @@ config KMOD_BATMAN_ADV_NC
 	bool "enable network coding [requires promisc mode support]"
 	depends on PACKAGE_kmod-batman-adv
 	default n
-
-config KMOD_BATMAN_ADV_BATCTL
-	bool "enable batctl"
-	depends on PACKAGE_kmod-batman-adv
-	default y
-	help
-	  batctl is a more intuitive managment utility for B.A.T.M.A.N.-Advanced.
-	  It is an easier method for configuring batman-adv and
-	  provides some additional tools for debugging as well.
batman-adv/Makefile +9 -75

134 lines not on this page · raw message

batman-adv/patches/0011-batman-adv-memory-leak-fix.patch +5 -10
index c991d5d..d8fe56e 100644
@@ -19,11 +19,11 @@ Signed-off-by: Antonio Quartulli <[email protected]>
  routing.c | 2 ++
  1 file changed, 2 insertions(+)
 
-diff --git a/routing.c b/routing.c
-index f7579d0..71bf698 100644
---- a/routing.c
-+++ b/routing.c
-@@ -1063,6 +1063,8 @@ int batadv_recv_unicast_tvlv(struct sk_buff *skb,
+Index: batman-adv-2014.0.0/routing.c
+===================================================================
+--- batman-adv-2014.0.0.orig/routing.c
++++ batman-adv-2014.0.0/routing.c
+@@ -1063,6 +1063,8 @@ int batadv_recv_unicast_tvlv(struct sk_b
  
  	if (ret != NET_RX_SUCCESS)
  		ret = batadv_route_unicast_packet(skb, recv_if);
@@ -32,8 +32,3 @@ index f7579d0..71bf698 100644
  
  	return ret;
  }
--- 
-1.8.5.3
-
-
-
Signature · 6 lines
1.8.1.2


-- 
Russell Senior, President
[email protected]
#2 lore raw

PATCH 3/4 openwrt routing feed: batman-adv: remove apparently unused variables from make arguments

Removes what appear to be unused and/or unnecessary environment variables passed to make.

---
 batman-adv/Makefile | 5 -----
 1 file changed, 5 deletions(-)
batman-adv/Makefile +0 -5
index c5c7625..1344198 100644
@@ -40,13 +40,8 @@ define KernelPackage/batman-adv/config
 endef
 
 MAKE_BATMAN_ADV_ARGS += \
-	CROSS_COMPILE="$(TARGET_CROSS)" \
 	KERNELPATH="$(LINUX_DIR)" \
-	ARCH="$(LINUX_KARCH)" \
-	PATH="$(TARGET_PATH)" \
-	SUBDIRS="$(PKG_BUILD_DIR)" \
 	PWD="$(PKG_BUILD_DIR)" \
-	LINUX_VERSION="$(LINUX_VERSION)" \
 	CONFIG_BATMAN_ADV_DEBUG=$(if $(CONFIG_KMOD_BATMAN_ADV_DEBUG_LOG),y,n) \
 	CONFIG_BATMAN_ADV_BLA=$(if $(CONFIG_KMOD_BATMAN_ADV_BLA),y,n) \
 	CONFIG_BATMAN_ADV_DAT=$(if $(CONFIG_KMOD_BATMAN_ADV_DAT),y,n) \
Signature · 7 lines
1.8.1.2



-- 
Russell Senior, President
[email protected]
#3 lore raw

PATCH 4/4 openwrt routing feed: batctl: remove apparently unused variables from make arguments

Removes what appear to be unused and/or unnecessary environment variables passed to make.

---
 batctl/Makefile | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
batctl/Makefile +1 -3
index 7a34957..eef22ec 100644
@@ -49,9 +49,7 @@ MAKE_BATCTL_ENV += \
 
 MAKE_BATCTL_ARGS += \
         REVISION="" \
-        CC="$(TARGET_CC)" \
-        DESTDIR="$(PKG_INSTALL_DIR)" \
-        batctl install
+        batctl
 
 
 define Build/compile
Signature · 7 lines
1.8.1.2



-- 
Russell Senior, President
[email protected]
#4 lore raw

Re: [B.A.T.M.A.N.] [PATCH 3/4] openwrt routing feed: batman-adv: remove apparently unused variables from make arguments

In reply to Russell Senior

Oops. Don't apply this one. It worked okay on a soekris net4826 build, but got an error building for ar71xx. Not sure yet specifically what is causing the trouble. Reverting this one, but applying the other three in this series built and is running on ar71xx.

Quoted 28 lines

Removes what appear to be unused and/or unnecessary environment variables passed to make.

---
 batman-adv/Makefile | 5 -----
 1 file changed, 5 deletions(-)
batman-adv/Makefile +0 -5
index c5c7625..1344198 100644
@@ -40,13 +40,8 @@ define KernelPackage/batman-adv/config
 endef
 
 MAKE_BATMAN_ADV_ARGS += \
-	CROSS_COMPILE="$(TARGET_CROSS)" \
 	KERNELPATH="$(LINUX_DIR)" \
-	ARCH="$(LINUX_KARCH)" \
-	PATH="$(TARGET_PATH)" \
-	SUBDIRS="$(PKG_BUILD_DIR)" \
 	PWD="$(PKG_BUILD_DIR)" \
-	LINUX_VERSION="$(LINUX_VERSION)" \
 	CONFIG_BATMAN_ADV_DEBUG=$(if $(CONFIG_KMOD_BATMAN_ADV_DEBUG_LOG),y,n) \
 	CONFIG_BATMAN_ADV_BLA=$(if $(CONFIG_KMOD_BATMAN_ADV_BLA),y,n) \
 	CONFIG_BATMAN_ADV_DAT=$(if $(CONFIG_KMOD_BATMAN_ADV_DAT),y,n) \
Signature · 1 line
1.8.1.2
Signature · 2 lines
Russell Senior, President
[email protected]
#5 lore raw

Re: [B.A.T.M.A.N.] [PATCH 2/4] openwrt routing feed: batman-adv: split kmod and userland into separate packages

In reply to Russell Senior
Quoted 5 lines · On Thursday 13 February 2014 06:01:19 Russell Senior wrote:

Creates a new package, batctl, split out from the batman-adv package. Simplifies the Makefiles, allows QUILT patch management to work, removes the quirky naming requirement for patches. The batctl package is a dependency of kmod-batman-adv, retaining the existing dependency relationship.

There is no batctl dependency and there should not be one. Some people try to save as many bytes as possible ..

Your patch does more than splitting the the Makefile. I'd prefer you send these changes separately.

Thanks,
Marek

#6 lore raw

PATCH v2 1/1 openwrt routing feed: batman-adv: split kmod and userland into separate packages

Creates a new package, batctl, split out from batman-adv package. Simplifies the Makefiles, allows QUILT patch management wto work, removes the quirky patch naming requirement. Modified Config.in to work as before with batctl, except now with PACKAGE_batctl.

This patch also avoids leakage of unrelated changes from first try. Oops.

---
 batctl/Makefile      | 66 ++++++++++++++++++++++++++++++++++++++++++++
 batman-adv/Config.in |  5 ++--
 batman-adv/Makefile  | 78 ++++------------------------------------------------
 3 files changed, 74 insertions(+), 75 deletions(-)
batctl/Makefile new file +66 -0
new file mode 100644
index 0000000..7a34957
@@ -0,0 +1,66 @@
+#
+# Copyright (C) 2010-2014 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=batctl
+PKG_VERSION:=2014.0.0
+PKG_RELEASE:=2
+PKG_MD5SUM:=b0bcf29fef80ddcc33769e13f5937d0a
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/batctl
+  URL:=http://www.open-mesh.org/
+  SECTION:=net
+  CATEGORY:=Network
+  TITLE:=B.A.T.M.A.N. Advanced user space configuration tool batctl
+  MAINTAINER:=Marek Lindner <[email protected]>
+endef
+
+define Package/batctl/description
+B.A.T.M.A.N. advanced is a kernel module which allows to
+build layer 2 mesh networks. This package contains the
+version $(PKG_VERSION) of the user space configuration & 
+management tool batctl.
+endef
+
+TARGET_CFLAGS  += -ffunction-sections -fdata-sections
+TARGET_LDFLAGS += -Wl,--gc-sections
+
+# Link-time optimization allows to move parts of the optimization from the single
+# source file to the global source view. This is done by emitting the GIMPLE
+# representation in each object file and analyzing it again during the link step.
+
+TARGET_CFLAGS  += -flto
+TARGET_LDFLAGS += -fuse-linker-plugin
+
+MAKE_BATCTL_ENV += \
+        CPPFLAGS="$(TARGET_CPPFLAGS)" \
+        CFLAGS="$(TARGET_CFLAGS)" \
+        LDFLAGS="$(TARGET_LDFLAGS)"
+
+MAKE_BATCTL_ARGS += \
+        REVISION="" \
+        CC="$(TARGET_CC)" \
+        DESTDIR="$(PKG_INSTALL_DIR)" \
+        batctl install
+
+
+define Build/compile
+	$(MAKE_BATCTL_ENV) $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_BATCTL_ARGS)
+endef
+
+define Package/batctl/install
+	$(INSTALL_DIR) $(1)/usr/sbin
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_NAME) $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,batctl))
batman-adv/Config.in +3 -2
index 1330525..aeefd35 100644
@@ -19,11 +19,12 @@ config KMOD_BATMAN_ADV_NC
 	depends on PACKAGE_kmod-batman-adv
 	default n
 
-config KMOD_BATMAN_ADV_BATCTL
-	bool "enable batctl"
+config PACKAGE_batctl
+	tristate "enable batctl"
 	depends on PACKAGE_kmod-batman-adv
 	default y
 	help
 	  batctl is a more intuitive managment utility for B.A.T.M.A.N.-Advanced.
 	  It is an easier method for configuring batman-adv and
 	  provides some additional tools for debugging as well.
+
batman-adv/Makefile +5 -73

124 lines not on this page · raw message

Signature · 2 lines
Russell Senior, President
[email protected]