b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven.eckelmann@gmx.de>
To: Nathan Wharton <naw@greptar.com>
Cc: b.a.t.m.a.n@open-mesh.net, Marek Lindner <lindner_marek@yahoo.de>
Subject: Re: [B.A.T.M.A.N.] [PATCH] [batman] Add padding around allocation debugger structures
Date: Mon, 1 Jun 2009 21:35:07 +0200	[thread overview]
Message-ID: <200906012135.22488.sven.eckelmann@gmx.de> (raw)
In-Reply-To: <4313f3060906011103q21b32600nf99f8607bd01045c@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2021 bytes --]

On Monday 01 June 2009 20:03:43 Nathan Wharton wrote:
> I had to copy the patches out of the e-mail.
>
> Here is the back trace:
> #0  list_add_tail (new=0x29bf0, head=0x298c9) at list-batman.c:68
> #1  0x0000ee7c in _hna_global_add (orig_node=0x29f80,
> hna_element=0x29ba8) at hna.c:371
> #2  0x0000f160 in hna_global_add (orig_node=0x29f80, new_hna=<value
> optimized out>, new_hna_len=<value optimized out>)
>     at hna.c:529
> #3  0x000099c8 in update_routes (orig_node=0x29f80,
> neigh_node=0x2a080, hna_recv_buff=0xbead1591 "\n\002\001",
>     hna_buff_len=10) at batman.c:377
> #4  0x0000c730 in update_orig (orig_node=0x29f80, in=0xbead157f,
> neigh=167772673, if_incoming=0x27678,
>     hna_recv_buff=0xbead1591 "\n\002\001", hna_buff_len=-16723,
> is_duplicate=0 '\0', curr_time=3199014207)
>     at originator.c:227
> #5  0x0000a7e0 in batman () at batman.c:956
> #6  0x000148d4 in main (argc=14, argv=0xbead1e14) at posix/posix.c:629
>
> Looks like debugMalloc didn't return an aligned value for head.  I'll
> step through that and see what I see.
Ok, I think I see the problem. The malloc returned a valid aligned adress. 
list_add_tail will get a pointer to an element in hna_global_entry. This 
structure is packed and all operations on it should be non-alignment safe. If 
you look at it further you will notice that orig_list is at position 9 
(assuming 4 bytes for a pointer) - which will not be aligned to 4 bytes of 
course.....
And here comes the problem: the compiler will only do the safe operations on 
non-aligned data if it knows that it is not alignent. Since a cast is done by 
calling list_add_tail it will not know that this parameter is not aligned and 
the non-alignment bug will occur.

So my question to marek: Is it really needed to have "struct hna_global_entry" 
packed in hna.h:57? If not then we should remove it and this problem should be 
gone. And what is with "struct hna_element".

Thank you for your work, Nathan :)

Regards,
	Sven

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

  reply	other threads:[~2009-06-01 19:35 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-19 14:27 [B.A.T.M.A.N.] Kernel crashes with batgat installed Nathan Wharton
2009-05-19 19:21 ` Sven Eckelmann
2009-05-19 20:38   ` Nathan Wharton
2009-05-20  1:30     ` Marek Lindner
2009-05-20 14:34       ` Nathan Wharton
2009-05-20 16:10         ` Marek Lindner
2009-05-20 17:01           ` Nathan Wharton
2009-05-20 19:02             ` Marek Lindner
2009-05-20 19:39               ` Nathan Wharton
2009-05-28 10:40 ` [B.A.T.M.A.N.] [PATCH] [batman] Add padding around allocation debugger structures Sven Eckelmann
2009-05-29  7:02   ` Marek Lindner
2009-05-29 14:00     ` Nathan Wharton
2009-06-01 16:44       ` Sven Eckelmann
2009-06-01 18:03         ` Nathan Wharton
2009-06-01 19:35           ` Sven Eckelmann [this message]
2009-06-01 21:50             ` Nathan Wharton
2009-06-02  4:36             ` Marek Lindner
2009-06-02 17:50               ` [B.A.T.M.A.N.] " Sven Eckelmann
2009-06-02 17:56                 ` [B.A.T.M.A.N.] [PATCH] [batman] Align pointers in hna list elements Sven Eckelmann
2009-06-02 18:56                   ` Nathan Wharton
2009-06-03 10:39                   ` [B.A.T.M.A.N.] [PATCHv2] " Sven Eckelmann
2009-06-03 11:16                     ` Marek Lindner
2009-05-28 11:36 ` [B.A.T.M.A.N.] [PATCH 2/3] [batman] Make TYPE_OF_WORD the largest integral type Sven Eckelmann
2009-05-28 11:36 ` [B.A.T.M.A.N.] [PATCH 3/3] [batman] Word-Align char buffer which are later casted to larger data types Sven Eckelmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200906012135.22488.sven.eckelmann@gmx.de \
    --to=sven.eckelmann@gmx.de \
    --cc=b.a.t.m.a.n@open-mesh.net \
    --cc=lindner_marek@yahoo.de \
    --cc=naw@greptar.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).