Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit 143edf0

Browse files
name2965gregkh
authored andcommitted
net/xen-netback: prevent UAF in xenvif_flush_hash()
[ Upstream commit 0fa5e94 ] During the list_for_each_entry_rcu iteration call of xenvif_flush_hash, kfree_rcu does not exist inside the rcu read critical section, so if kfree_rcu is called when the rcu grace period ends during the iteration, UAF occurs when accessing head->next after the entry becomes free. Therefore, to solve this, you need to change it to list_for_each_entry_safe. Signed-off-by: Jeongjun Park <aha310510@gmail.com> Link: https://patch.msgid.link/20240822181109.2577354-1-aha310510@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 04053e5 commit 143edf0

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/net/xen-netback/hash.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,15 @@ static u32 xenvif_new_hash(struct xenvif *vif, const u8 *data,
9595

9696
static void xenvif_flush_hash(struct xenvif *vif)
9797
{
98-
struct xenvif_hash_cache_entry *entry;
98+
struct xenvif_hash_cache_entry *entry, *n;
9999
unsigned long flags;
100100

101101
if (xenvif_hash_cache_size == 0)
102102
return;
103103

104104
spin_lock_irqsave(&vif->hash.cache.lock, flags);
105105

106-
list_for_each_entry_rcu(entry, &vif->hash.cache.list, link,
107-
lockdep_is_held(&vif->hash.cache.lock)) {
106+
list_for_each_entry_safe(entry, n, &vif->hash.cache.list, link) {
108107
list_del_rcu(&entry->link);
109108
vif->hash.cache.count--;
110109
kfree_rcu(entry, rcu);

0 commit comments

Comments
 (0)