Skip to contentSkip to conversation

fs:super:get_anon_bdev: fix race condition could cause dev exceed its upper limitation

PATCH New Wang YanQing 1 participant 1 message Jun 23, 2015 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs:super:get_anon_bdev: fix race condition could cause dev exceed its upper limitation

Execution of get_anon_bdev concurrently and preemptive kernel all could bring race condition, it isn't enough to check dev against its upper limitation with equality operator only.

This patch fix it.

---
 fs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/super.c +1 -1
index 928c20f..b613723 100644
@@ -842,7 +842,7 @@ int get_anon_bdev(dev_t *p)
 	else if (error)
 		return -EAGAIN;
 
-	if (dev == (1 << MINORBITS)) {
+	if (dev >= (1 << MINORBITS)) {
 		spin_lock(&unnamed_dev_lock);
 		ida_remove(&unnamed_dev_ida, dev);
 		if (unnamed_dev_start > dev)
Signature · 1 line
1.8.5.6.2.g3d8a54e.dirty