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-next>] [day] [month] [year] [list]
Date:	Tue, 15 Dec 2015 17:45:59 -0500
From:	William Hua <william.hua@...onical.com>
To:	netdev@...r.kernel.org, Thomas Graf <tgraf@...g.ch>
Cc:	William Hua <william.hua@...onical.com>
Subject: [PATCH] rhashtable: Always allocate at least one bucket lock

No bucket locks are allocated when an rhashtable is initialized with
fewer than two elements. In this special case, we should allocate at
least one to prevent a segfault.

Signed-off-by: William Hua <william.hua@...onical.com>
---
 lib/rhashtable.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/rhashtable.c b/lib/rhashtable.c
index a54ff89..1b1b5b2 100644
--- a/lib/rhashtable.c
+++ b/lib/rhashtable.c
@@ -76,6 +76,9 @@ static int alloc_bucket_locks(struct rhashtable *ht, struct bucket_table *tbl,
 	/* Never allocate more than 0.5 locks per bucket */
 	size = min_t(unsigned int, size, tbl->size >> 1);
 
+	/* Always allocate at least one lock */
+	size = max_t(unsigned int, size, 1);
+
 	if (sizeof(spinlock_t) != 0) {
 #ifdef CONFIG_NUMA
 		if (size * sizeof(spinlock_t) > PAGE_SIZE &&
-- 
2.6.4
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ