lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 18 Sep 2020 11:03:19 +0800
From:   Xiyu Yang <xiyuyang19@...an.edu.cn>
To:     Marek Lindner <mareklindner@...mailbox.ch>,
        Simon Wunderlich <sw@...onwunderlich.de>,
        Antonio Quartulli <a@...table.cc>,
        Sven Eckelmann <sven@...fation.org>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        b.a.t.m.a.n@...ts.open-mesh.org, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Cc:     yuanxzhang@...an.edu.cn, kjlu@....edu,
        Xiyu Yang <xiyuyang19@...an.edu.cn>,
        Xin Tan <tanxin.ctf@...il.com>
Subject: [PATCH] batman-adv: Fix orig node refcnt leak when creating neigh node

batadv_neigh_node_create() is used to create a neigh node object, whose
fields will be initialized with the specific object. When a new
reference of the specific object is created during the initialization,
its refcount should be increased.

However, when "neigh_node" object initializes its orig_node field with
the "orig_node" object, the function forgets to hold the refcount of the
"orig_node", causing a potential refcount leak and use-after-free issue
for the reason that the object can be freed in other places.

Fix this issue by increasing the refcount of orig_node object during the
initialization and adding corresponding batadv_orig_node_put() in
batadv_neigh_node_release().

Signed-off-by: Xiyu Yang <xiyuyang19@...an.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@...il.com>
---
 net/batman-adv/originator.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 805d8969bdfb..d6c2296f8e35 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -306,6 +306,8 @@ static void batadv_neigh_node_release(struct kref *ref)
 
 	batadv_hardif_put(neigh_node->if_incoming);
 
+	batadv_orig_node_put(neigh_node->orig_node);
+
 	kfree_rcu(neigh_node, rcu);
 }
 
@@ -685,6 +687,7 @@ batadv_neigh_node_create(struct batadv_orig_node *orig_node,
 	kref_get(&hard_iface->refcount);
 	ether_addr_copy(neigh_node->addr, neigh_addr);
 	neigh_node->if_incoming = hard_iface;
+	kref_get(&orig_node->refcount);
 	neigh_node->orig_node = orig_node;
 	neigh_node->last_seen = jiffies;
 
-- 
2.7.4

Powered by blists - more mailing lists