summaryrefslogtreecommitdiffstats
path: root/drivers/staging/batman-adv/types.h
diff options
context:
space:
mode:
authorSven Eckelmann <sven.eckelmann@gmx.de>2010-09-18 21:01:19 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2010-09-20 16:29:50 -0700
commit47f621dddc0b5ce3be4592a58e5f73707a83ad41 (patch)
treeb57e1136232846f098f646bc1e0f0f240af37bbe /drivers/staging/batman-adv/types.h
parent16f9530e99f5eb35dd1adafbae854dd94f8d3751 (diff)
downloadop-kernel-dev-47f621dddc0b5ce3be4592a58e5f73707a83ad41.zip
op-kernel-dev-47f621dddc0b5ce3be4592a58e5f73707a83ad41.tar.gz
Staging: batman-adv: Use refcnt to track usage count of batman_if
get_batman_if_by_netdev and get_active_batman_if may leak data from the rcu protected list of interfaces. The rcu protected list of all gateway nodes leaks the actual data outside the read-side critical area. This is not valid as we may free the data using a call_rcu created callback after we unlock using rcu_read_unlock. A workaround is to provide a reference count to be sure that the memory isn't freed to early. It is currently only to implement the already existing functionality and doesn't provide the full tracking of all usage cases. Additionally, we must hardif_hold inside the rcu_read_lock()..rcu_read_unlock() before we attach to the structure which "leaks" it. When another function now removed it from its usage context (primary_if, usage on stack, ...) then we must hardif_put it. If it is decremented to zero then we can issue the call_rcu to the freeing function. So "put" is not allowed inside an rcu_read_lock. Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/batman-adv/types.h')
-rw-r--r--drivers/staging/batman-adv/types.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/staging/batman-adv/types.h b/drivers/staging/batman-adv/types.h
index b162644..bb5827f 100644
--- a/drivers/staging/batman-adv/types.h
+++ b/drivers/staging/batman-adv/types.h
@@ -44,6 +44,7 @@ struct batman_if {
unsigned char *packet_buff;
int packet_len;
struct kobject *hardif_obj;
+ atomic_t refcnt;
struct packet_type batman_adv_ptype;
struct net_device *soft_iface;
};
OpenPOWER on IntegriCloud