From: "Martin Hundebøll" <martin@hundeboll.net>
To: The list for a Better Approach To Mobile Ad-hoc Networking
<b.a.t.m.a.n@lists.open-mesh.org>,
Simon Wunderlich <sw@simonwunderlich.de>
Subject: Re: [B.A.T.M.A.N.] [PATCH-maint] batman-adv: fix potential orig_node reference leak
Date: Tue, 11 Feb 2014 18:29:10 +0100 [thread overview]
Message-ID: <52FA5DE6.8050005@hundeboll.net> (raw)
In-Reply-To: <52FA5D35.6020809@meshcoding.com>
[-- Attachment #1: Type: text/plain, Size: 1605 bytes --]
On 2014-02-11 18:26, Antonio Quartulli wrote:
> On 08/02/14 16:45, Simon Wunderlich wrote:
>> Since batadv_orig_node_new() sets the refcount to two, assuming that
>> the calling function will use a reference for putting the orig_node into
>> a hash or similar, both references must be freed if initialization of
>> the orig_node fails. Otherwise that object may be leaked in that error
>> case.
>>
>> Reported-by: Antonio Quartulli <antonio@meshcoding.com>
>> Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
>> ---
>> bat_iv_ogm.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
>> index 6f4fcdc..6000337 100644
>> --- a/bat_iv_ogm.c
>> +++ b/bat_iv_ogm.c
>> @@ -256,6 +256,8 @@ batadv_iv_ogm_orig_get(struct batadv_priv *bat_priv, const uint8_t *addr)
>> free_bcast_own:
>> kfree(orig_node->bat_iv.bcast_own);
>> free_orig_node:
>> + /* free twice, as batadv_orig_node_new set refcount to 2 */
>> + batadv_orig_node_free_ref(orig_node);
>> batadv_orig_node_free_ref(orig_node);
>
> Coudln't we just invoke kfree(orig_node) here ? I think that if we hit
> this point it is because the node has not added to the hash and
> therefore it i snot used in any other context. This way we avoid the
> double free_ref() and we don't trgger the whole RCU mechanism.
>
> Or am I missing something?
batadv_<type>_free_ref() might have side effect that are not handled by
kfree alone...
--
Kind Regards
Martin Hundebøll
Frederiks Allé 99, 1.th
8000 Aarhus C
Denmark
+45 61 65 54 61
martin@hundeboll.net
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 901 bytes --]
next prev parent reply other threads:[~2014-02-11 17:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-08 15:45 [B.A.T.M.A.N.] [PATCH-maint] batman-adv: fix potential orig_node reference leak Simon Wunderlich
2014-02-11 12:04 ` Marek Lindner
2014-02-11 17:26 ` Antonio Quartulli
2014-02-11 17:29 ` Martin Hundebøll [this message]
2014-02-11 17:34 ` Antonio Quartulli
2014-02-11 17:40 ` Marek Lindner
2014-02-11 17:45 ` Antonio Quartulli
2014-02-11 17:35 ` 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=52FA5DE6.8050005@hundeboll.net \
--to=martin@hundeboll.net \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
--cc=sw@simonwunderlich.de \
/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