public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 5.4] net: xen-netback: hash.c: Use built-in RCU list checking
@ 2025-01-22 17:43 Hagar Hemdan
  2025-01-22 17:43 ` [PATCH 5.4] net/xen-netback: prevent UAF in xenvif_flush_hash() Hagar Hemdan
  2025-01-22 22:38 ` [PATCH 5.4] net: xen-netback: hash.c: Use built-in RCU list checking Sasha Levin
  0 siblings, 2 replies; 4+ messages in thread
From: Hagar Hemdan @ 2025-01-22 17:43 UTC (permalink / raw)
  Cc: stable, Madhuparna Bhowmik, Wei Liu, David S . Miller,
	Hagar Hemdan

From: Madhuparna Bhowmik <madhuparnabhowmik04@gmail.com>

commit f3265971ded98a069ad699b51b8a5ab95e9e5be1 upstream.

list_for_each_entry_rcu has built-in RCU and lock checking.
Pass cond argument to list_for_each_entry_rcu.

Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik04@gmail.com>
Acked-by: Wei Liu <wei.liu@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Hagar Hemdan <hagarhem@amazon.com>
---
This is a dependency to fix CVE-2024-49936 in 5.4.

diff --git a/drivers/net/xen-netback/hash.c b/drivers/net/xen-netback/hash.c
--- a/drivers/net/xen-netback/hash.c
+++ b/drivers/net/xen-netback/hash.c
@@ -51,7 +51,8 @@ static void xenvif_add_hash(struct xenvif *vif, const u8 *tag,
 
 	found = false;
 	oldest = NULL;
-	list_for_each_entry_rcu(entry, &vif->hash.cache.list, link) {
+	list_for_each_entry_rcu(entry, &vif->hash.cache.list, link,
+				lockdep_is_held(&vif->hash.cache.lock)) {
 		/* Make sure we don't add duplicate entries */
 		if (entry->len == len &&
 		    memcmp(entry->tag, tag, len) == 0)
@@ -102,7 +103,8 @@ static void xenvif_flush_hash(struct xenvif *vif)
 
 	spin_lock_irqsave(&vif->hash.cache.lock, flags);
 
-	list_for_each_entry_rcu(entry, &vif->hash.cache.list, link) {
+	list_for_each_entry_rcu(entry, &vif->hash.cache.list, link,
+				lockdep_is_held(&vif->hash.cache.lock)) {
 		list_del_rcu(&entry->link);
 		vif->hash.cache.count--;
 		kfree_rcu(entry, rcu);

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-01-22 22:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-22 17:43 [PATCH 5.4] net: xen-netback: hash.c: Use built-in RCU list checking Hagar Hemdan
2025-01-22 17:43 ` [PATCH 5.4] net/xen-netback: prevent UAF in xenvif_flush_hash() Hagar Hemdan
2025-01-22 22:38   ` Sasha Levin
2025-01-22 22:38 ` [PATCH 5.4] net: xen-netback: hash.c: Use built-in RCU list checking Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox