b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH] batman-adv: Don't write in not allocated packet_buff
@ 2010-08-20 15:32 Sven Eckelmann
  2010-08-21  8:41 ` Sven Eckelmann
  0 siblings, 1 reply; 2+ messages in thread
From: Sven Eckelmann @ 2010-08-20 15:32 UTC (permalink / raw)
  To: b.a.t.m.a.n

Each net_device in a system will automatically managed as a possible
batman_if and holds different informations like a buffer with a prepared
originator messages. To reduce the memory usage, the packet_buff will
only be allocated when the interface is really added/enabled for
batman-adv.

The function to update the hw address information inside the packet_buff
just assumes that the packet_buff is always initialised and thus the
kernel will just oops when we try to change the hw address of a not
already fully enabled interface.

We must always check if the packet_buff is allocated before we try to
change information inside of it.

Reported-by: Tim Glaremin <Tim.Glaremin@web.de>
Reported-by: Lemonde <zukky@bb.banban.jp>
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
Cc: stable <stable@kernel.org>
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
 batman-adv/hard-interface.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/batman-adv/hard-interface.c b/batman-adv/hard-interface.c
index eb26026..9d0a47c 100644
--- a/batman-adv/hard-interface.c
+++ b/batman-adv/hard-interface.c
@@ -138,6 +138,9 @@ static bool hardif_is_iface_up(struct batman_if *batman_if)
 
 static void update_mac_addresses(struct batman_if *batman_if)
 {
+	if (!batman_if || !batman_if->packet_buff)
+		return;
+
 	addr_to_string(batman_if->addr_str, batman_if->net_dev->dev_addr);
 
 	memcpy(((struct batman_packet *)(batman_if->packet_buff))->orig,
@@ -397,6 +400,7 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev)
 	batman_if->net_dev = net_dev;
 	batman_if->soft_iface = NULL;
 	batman_if->if_status = IF_NOT_IN_USE;
+	batman_if->packet_buff = NULL;
 	INIT_LIST_HEAD(&batman_if->list);
 
 	check_known_mac_addr(batman_if->net_dev->dev_addr);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH] batman-adv: Don't write in not allocated packet_buff
  2010-08-20 15:32 [B.A.T.M.A.N.] [PATCH] batman-adv: Don't write in not allocated packet_buff Sven Eckelmann
@ 2010-08-21  8:41 ` Sven Eckelmann
  0 siblings, 0 replies; 2+ messages in thread
From: Sven Eckelmann @ 2010-08-21  8:41 UTC (permalink / raw)
  To: b.a.t.m.a.n

[-- Attachment #1: Type: Text/Plain, Size: 1369 bytes --]

Sven Eckelmann wrote:
> Each net_device in a system will automatically managed as a possible
> batman_if and holds different informations like a buffer with a prepared
> originator messages. To reduce the memory usage, the packet_buff will
> only be allocated when the interface is really added/enabled for
> batman-adv.
> 
> The function to update the hw address information inside the packet_buff
> just assumes that the packet_buff is always initialised and thus the
> kernel will just oops when we try to change the hw address of a not
> already fully enabled interface.
> 
> We must always check if the packet_buff is allocated before we try to
> change information inside of it.
> 
> Reported-by: Tim Glaremin <Tim.Glaremin@web.de>
> Reported-by: Lemonde <zukky@bb.banban.jp>
> Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
> Cc: stable <stable@kernel.org>

Before there is a wrong impression. This bug was indirectly already fixed in 
trunk by "batman-adv: attach each hard-interface to a soft-interface". So it 
is not a must have. maint/next got the patch now and I hope that 
openwrt/debian will have them soon too.

But I will send it for the stable kernel tree now and change the patch
 "batman-adv: attach each hard-interface to a soft-interface" in master-rebase 
to remove those changes again.

Best regards,
	Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-08-21  8:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-20 15:32 [B.A.T.M.A.N.] [PATCH] batman-adv: Don't write in not allocated packet_buff Sven Eckelmann
2010-08-21  8:41 ` Sven Eckelmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).