lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241221061555.1071516-2-dheeraj.linuxdev@gmail.com>
Date: Sat, 21 Dec 2024 11:45:55 +0530
From: Dheeraj Reddy Jonnalagadda <dheeraj.linuxdev@...il.com>
To: edumazet@...gle.com,
	jasowang@...hat.com
Cc: akpm@...ux-foundation.org,
	surenb@...gle.com,
	jack@...e.cz,
	linux-kernel@...r.kernel.org,
	Dheeraj Reddy Jonnalagadda <dheeraj.linuxdev@...il.com>
Subject: [PATCH include] ptr_ring: fix potential race in ptr_ring_resize_multiple_bh_noprof

The ptr_ring_resize_multiple_bh_noprof function may have a race condition
where queues[i] is freed after releasing the locks. Since this function
can be called from multiple threads, another thread could potentially modify
queues[i] between the unlock and kvfree operations.

Move the kvfree inside the critical section to ensure atomicity of the
queue swap and cleanup operations.

Fixes: 59e6ae53248a("ptr_ring: support resizing multiple queues")
Closes: https://scan7.scan.coverity.com/#/project-view/52337/11354?selectedIssue=1602644
Signed-off-by: Dheeraj Reddy Jonnalagadda <dheeraj.linuxdev@...il.com>
---
 include/linux/ptr_ring.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/include/linux/ptr_ring.h b/include/linux/ptr_ring.h
index 551329220e4f..cb06c74fc791 100644
--- a/include/linux/ptr_ring.h
+++ b/include/linux/ptr_ring.h
@@ -641,13 +641,11 @@ static inline int ptr_ring_resize_multiple_bh_noprof(struct ptr_ring **rings,
 		spin_lock(&(rings[i])->producer_lock);
 		queues[i] = __ptr_ring_swap_queue(rings[i], queues[i],
 						  size, gfp, destroy);
+		kvfree(queues[i]);
 		spin_unlock(&(rings[i])->producer_lock);
 		spin_unlock_bh(&(rings[i])->consumer_lock);
 	}
 
-	for (i = 0; i < nrings; ++i)
-		kvfree(queues[i]);
-
 	kfree(queues);
 
 	return 0;
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ