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>] [day] [month] [year] [list]
Message-Id: <20201217080030.1226023-1-yili@winhong.com>
Date:   Thu, 17 Dec 2020 16:00:30 +0800
From:   Yi Li <yili@...hong.com>
To:     colyli@...e.de
Cc:     yilikernel@...il.com, kent.overstreet@...il.com,
        linux-bcache@...r.kernel.org, linux-kernel@...r.kernel.org,
        Yi Li <yili@...hong.com>, Li bing <libing@...hong.com>
Subject: [PATCH] bcache: fix UUID room exhausted fake issue.

The UUID room will be exhausted fake when loop attach/dettach backing dev.

Using zero_uuid to the UUID room after dettach normaly.
And attach dev can request UUID room successfully.

Signed-off-by: Yi Li <yili@...hong.com>
Signed-off-by: Li bing <libing@...hong.com>
---
 drivers/md/bcache/super.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 0e06d721cd8e..f7ad1e26b013 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -34,10 +34,7 @@ static const char bcache_magic[] = {
 	0x82, 0x65, 0xf5, 0x7f, 0x48, 0xba, 0x6d, 0x81
 };
 
-static const char invalid_uuid[] = {
-	0xa0, 0x3e, 0xf8, 0xed, 0x3e, 0xe1, 0xb8, 0x78,
-	0xc8, 0x50, 0xfc, 0x5e, 0xcb, 0x16, 0xcd, 0x99
-};
+static const char zero_uuid[16] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
 
 static struct kobject *bcache_kobj;
 struct mutex bch_register_lock;
@@ -515,13 +512,6 @@ static struct uuid_entry *uuid_find(struct cache_set *c, const char *uuid)
 	return NULL;
 }
 
-static struct uuid_entry *uuid_find_empty(struct cache_set *c)
-{
-	static const char zero_uuid[16] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
-
-	return uuid_find(c, zero_uuid);
-}
-
 /*
  * Bucket priorities/gens:
  *
@@ -803,7 +793,7 @@ static void bcache_device_detach(struct bcache_device *d)
 		struct uuid_entry *u = d->c->uuids + d->id;
 
 		SET_UUID_FLASH_ONLY(u, 0);
-		memcpy(u->uuid, invalid_uuid, 16);
+		memcpy(u->uuid, zero_uuid, 16);
 		u->invalidated = cpu_to_le32((u32)ktime_get_real_seconds());
 		bch_uuid_write(d->c);
 	}
@@ -1211,7 +1201,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
 	if (u &&
 	    (BDEV_STATE(&dc->sb) == BDEV_STATE_STALE ||
 	     BDEV_STATE(&dc->sb) == BDEV_STATE_NONE)) {
-		memcpy(u->uuid, invalid_uuid, 16);
+		memcpy(u->uuid, zero_uuid, 16);
 		u->invalidated = cpu_to_le32((u32)ktime_get_real_seconds());
 		u = NULL;
 	}
@@ -1223,7 +1213,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
 			return -ENOENT;
 		}
 
-		u = uuid_find_empty(c);
+		u = uuid_find(c, zero_uuid);
 		if (!u) {
 			pr_err("Not caching %s, no room for UUID\n",
 			       dc->backing_dev_name);
@@ -1554,7 +1544,7 @@ int bch_flash_dev_create(struct cache_set *c, uint64_t size)
 	if (!test_bit(CACHE_SET_RUNNING, &c->flags))
 		return -EPERM;
 
-	u = uuid_find_empty(c);
+	u = uuid_find(c, zero_uuid);
 	if (!u) {
 		pr_err("Can't create volume, no room for UUID\n");
 		return -EINVAL;
-- 
2.25.3



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ