net/xen-netback: prevent UAF in xenvif_flush_hash()
authorJeongjun Park <aha310510@gmail.com>
Thu, 22 Aug 2024 18:11:09 +0000 (03:11 +0900)
committerJakub Kicinski <kuba@kernel.org>
Thu, 29 Aug 2024 00:07:42 +0000 (17:07 -0700)
commit0fa5e94a1811d68fbffa0725efe6d4ca62c03d12
tree5331c970f54958f43c867cbf0bbdba8a712420a6
parente5899b60f52a7591cfc2a2dec3e83710975117d7
net/xen-netback: prevent UAF in xenvif_flush_hash()

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>
drivers/net/xen-netback/hash.c