public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Marek Lindner <lindner_marek@yahoo.de>
To: The list for a Better Approach To Mobile Ad-hoc Networking
	<b.a.t.m.a.n@lists.open-mesh.org>
Subject: Re: [B.A.T.M.A.N.] race condition with activate_module?
Date: Thu, 11 Feb 2010 17:20:16 +0800	[thread overview]
Message-ID: <201002111720.16266.lindner_marek@yahoo.de> (raw)
In-Reply-To: <20100211022543.GA6493@Linus-Debian>


Hi,

>I think I've seen this bug a couple of times but I've never been
>able to reproduce it. Now I added a little patch to slow down the
>activate_module() procedure and the bug occures every time now. My
>question is, did I make a race condition apparent or did I introduce
>a bug with this patch?

the race condition existed before - you just make it more visible. No matter 
how slow the code is being processed it should not lead to a crash.


> Okay, I could narrow it down a little further: There is a problem
> with the num_ifs variable. When activate_module() gets called in
> proc_interfaces_write() and an ogm of a neighbour arrives after
> this for the first time but before we've set 'num_ifs = if_num + 1;',
> then we're not allocating enough space in get_orig_node(), leading
> to a kernel panic.

I think you managed to uncover 2 race conditions:
* receiving a packet before the module is fully initialized
* concurrent activate_module() calls

Better than introducing some locking code which would need to halt the whole 
module we should make sure that batman-adv does not process packets before its 
initialization is complete.

Regards,
Marek

  reply	other threads:[~2010-02-11  9:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-08 19:38 [B.A.T.M.A.N.] race condition with activate_module? Linus Lüssing
2010-02-11  2:25 ` Linus Lüssing
2010-02-11  9:20   ` Marek Lindner [this message]
2010-02-12 11:06     ` Marek Lindner
2010-02-14 16:58       ` Simon Wunderlich

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=201002111720.16266.lindner_marek@yahoo.de \
    --to=lindner_marek@yahoo.de \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    /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