Merge tag 'batadv-net-pullrequest-20240621' of git://git.open-mesh.org/linux-merge
Simon Wunderlich says: ==================== Here are some batman-adv bugfixes: - Don't accept TT entries for out-of-spec VIDs, by Sven Eckelmann - Revert "batman-adv: prefer kfree_rcu() over call_rcu() with free-only callbacks", by Linus Lüssing * tag 'batadv-net-pullrequest-20240621' of git://git.open-mesh.org/linux-merge: Revert "batman-adv: prefer kfree_rcu() over call_rcu() with free-only callbacks" batman-adv: Don't accept TT entries for out-of-spec VIDs ==================== Link: https://patch.msgid.link/20240621143915.49137-1-sw@simonwunderlich.de Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
#include <linux/errno.h>
|
#include <linux/errno.h>
|
||||||
#include <linux/etherdevice.h>
|
#include <linux/etherdevice.h>
|
||||||
#include <linux/gfp.h>
|
#include <linux/gfp.h>
|
||||||
|
#include <linux/if_vlan.h>
|
||||||
#include <linux/jiffies.h>
|
#include <linux/jiffies.h>
|
||||||
#include <linux/kref.h>
|
#include <linux/kref.h>
|
||||||
#include <linux/list.h>
|
#include <linux/list.h>
|
||||||
@@ -131,6 +132,29 @@ batadv_orig_node_vlan_get(struct batadv_orig_node *orig_node,
|
|||||||
return vlan;
|
return vlan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* batadv_vlan_id_valid() - check if vlan id is in valid batman-adv encoding
|
||||||
|
* @vid: the VLAN identifier
|
||||||
|
*
|
||||||
|
* Return: true when either no vlan is set or if VLAN is in correct range,
|
||||||
|
* false otherwise
|
||||||
|
*/
|
||||||
|
static bool batadv_vlan_id_valid(unsigned short vid)
|
||||||
|
{
|
||||||
|
unsigned short non_vlan = vid & ~(BATADV_VLAN_HAS_TAG | VLAN_VID_MASK);
|
||||||
|
|
||||||
|
if (vid == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!(vid & BATADV_VLAN_HAS_TAG))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (non_vlan)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* batadv_orig_node_vlan_new() - search and possibly create an orig_node_vlan
|
* batadv_orig_node_vlan_new() - search and possibly create an orig_node_vlan
|
||||||
* object
|
* object
|
||||||
@@ -149,6 +173,9 @@ batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node,
|
|||||||
{
|
{
|
||||||
struct batadv_orig_node_vlan *vlan;
|
struct batadv_orig_node_vlan *vlan;
|
||||||
|
|
||||||
|
if (!batadv_vlan_id_valid(vid))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
spin_lock_bh(&orig_node->vlan_list_lock);
|
spin_lock_bh(&orig_node->vlan_list_lock);
|
||||||
|
|
||||||
/* first look if an object for this vid already exists */
|
/* first look if an object for this vid already exists */
|
||||||
|
@@ -208,6 +208,20 @@ batadv_tt_global_hash_find(struct batadv_priv *bat_priv, const u8 *addr,
|
|||||||
return tt_global_entry;
|
return tt_global_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* batadv_tt_local_entry_free_rcu() - free the tt_local_entry
|
||||||
|
* @rcu: rcu pointer of the tt_local_entry
|
||||||
|
*/
|
||||||
|
static void batadv_tt_local_entry_free_rcu(struct rcu_head *rcu)
|
||||||
|
{
|
||||||
|
struct batadv_tt_local_entry *tt_local_entry;
|
||||||
|
|
||||||
|
tt_local_entry = container_of(rcu, struct batadv_tt_local_entry,
|
||||||
|
common.rcu);
|
||||||
|
|
||||||
|
kmem_cache_free(batadv_tl_cache, tt_local_entry);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* batadv_tt_local_entry_release() - release tt_local_entry from lists and queue
|
* batadv_tt_local_entry_release() - release tt_local_entry from lists and queue
|
||||||
* for free after rcu grace period
|
* for free after rcu grace period
|
||||||
@@ -222,7 +236,7 @@ static void batadv_tt_local_entry_release(struct kref *ref)
|
|||||||
|
|
||||||
batadv_softif_vlan_put(tt_local_entry->vlan);
|
batadv_softif_vlan_put(tt_local_entry->vlan);
|
||||||
|
|
||||||
kfree_rcu(tt_local_entry, common.rcu);
|
call_rcu(&tt_local_entry->common.rcu, batadv_tt_local_entry_free_rcu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -240,6 +254,20 @@ batadv_tt_local_entry_put(struct batadv_tt_local_entry *tt_local_entry)
|
|||||||
batadv_tt_local_entry_release);
|
batadv_tt_local_entry_release);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* batadv_tt_global_entry_free_rcu() - free the tt_global_entry
|
||||||
|
* @rcu: rcu pointer of the tt_global_entry
|
||||||
|
*/
|
||||||
|
static void batadv_tt_global_entry_free_rcu(struct rcu_head *rcu)
|
||||||
|
{
|
||||||
|
struct batadv_tt_global_entry *tt_global_entry;
|
||||||
|
|
||||||
|
tt_global_entry = container_of(rcu, struct batadv_tt_global_entry,
|
||||||
|
common.rcu);
|
||||||
|
|
||||||
|
kmem_cache_free(batadv_tg_cache, tt_global_entry);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* batadv_tt_global_entry_release() - release tt_global_entry from lists and
|
* batadv_tt_global_entry_release() - release tt_global_entry from lists and
|
||||||
* queue for free after rcu grace period
|
* queue for free after rcu grace period
|
||||||
@@ -254,7 +282,7 @@ void batadv_tt_global_entry_release(struct kref *ref)
|
|||||||
|
|
||||||
batadv_tt_global_del_orig_list(tt_global_entry);
|
batadv_tt_global_del_orig_list(tt_global_entry);
|
||||||
|
|
||||||
kfree_rcu(tt_global_entry, common.rcu);
|
call_rcu(&tt_global_entry->common.rcu, batadv_tt_global_entry_free_rcu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -379,6 +407,19 @@ static void batadv_tt_global_size_dec(struct batadv_orig_node *orig_node,
|
|||||||
batadv_tt_global_size_mod(orig_node, vid, -1);
|
batadv_tt_global_size_mod(orig_node, vid, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* batadv_tt_orig_list_entry_free_rcu() - free the orig_entry
|
||||||
|
* @rcu: rcu pointer of the orig_entry
|
||||||
|
*/
|
||||||
|
static void batadv_tt_orig_list_entry_free_rcu(struct rcu_head *rcu)
|
||||||
|
{
|
||||||
|
struct batadv_tt_orig_list_entry *orig_entry;
|
||||||
|
|
||||||
|
orig_entry = container_of(rcu, struct batadv_tt_orig_list_entry, rcu);
|
||||||
|
|
||||||
|
kmem_cache_free(batadv_tt_orig_cache, orig_entry);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* batadv_tt_orig_list_entry_release() - release tt orig entry from lists and
|
* batadv_tt_orig_list_entry_release() - release tt orig entry from lists and
|
||||||
* queue for free after rcu grace period
|
* queue for free after rcu grace period
|
||||||
@@ -392,7 +433,7 @@ static void batadv_tt_orig_list_entry_release(struct kref *ref)
|
|||||||
refcount);
|
refcount);
|
||||||
|
|
||||||
batadv_orig_node_put(orig_entry->orig_node);
|
batadv_orig_node_put(orig_entry->orig_node);
|
||||||
kfree_rcu(orig_entry, rcu);
|
call_rcu(&orig_entry->rcu, batadv_tt_orig_list_entry_free_rcu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user