Skip to content

Commit 04e1a65

Browse files
ecsvgregkh
authored andcommitted
batman-adv: dat: prevent false sharing between VLANs
commit 20d7658 upstream. The local hash of DAT entries is supposed to be VLAN (VID) aware. But the adding to the hash and the search in the hash were not checking the VID information of the hash entries. The entries would therefore only be correctly separated when batadv_hash_dat() didn't select the same buckets for different VIDs. Cc: stable@kernel.org Fixes: be1db4f ("batman-adv: make the Distributed ARP Table vlan aware") Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 3f82fc9 commit 04e1a65

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

net/batman-adv/distributed-arp-table.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,13 @@ static void batadv_dat_purge(struct work_struct *work)
214214
*/
215215
static bool batadv_compare_dat(const struct hlist_node *node, const void *data2)
216216
{
217-
const void *data1 = container_of(node, struct batadv_dat_entry,
218-
hash_entry);
217+
const struct batadv_dat_entry *entry1;
218+
const struct batadv_dat_entry *entry2;
219219

220-
return memcmp(data1, data2, sizeof(__be32)) == 0;
220+
entry1 = container_of(node, struct batadv_dat_entry, hash_entry);
221+
entry2 = data2;
222+
223+
return entry1->ip == entry2->ip && entry1->vid == entry2->vid;
221224
}
222225

223226
/**
@@ -344,6 +347,9 @@ batadv_dat_entry_hash_find(struct batadv_priv *bat_priv, __be32 ip,
344347
if (dat_entry->ip != ip)
345348
continue;
346349

350+
if (dat_entry->vid != vid)
351+
continue;
352+
347353
if (!kref_get_unless_zero(&dat_entry->refcount))
348354
continue;
349355

0 commit comments

Comments
 (0)