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]
Message-Id: <1520510097-6396-1-git-send-email-paulb@mellanox.com>
Date:   Thu,  8 Mar 2018 13:54:57 +0200
From:   Paul Blakey <paulb@...lanox.com>
To:     Thomas Graf <tgraf@...g.ch>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        David Miller <davem@...emloft.net>
Cc:     netdev@...r.kernel.org, Paul Blakey <paulb@...lanox.com>
Subject: [PATCH net] test_rhashtable: Add missing rcu_read_lock()

Suppress "suspicious rcu_dereference_protected() usage!" on duplicate
insertion test.

Fixes: 499ac3b60f65 ('test_rhashtable: add test case for rhl_table with duplicate objects')
Signed-off-by: Paul Blakey <paulb@...lanox.com>
---
 lib/test_rhashtable.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/lib/test_rhashtable.c b/lib/test_rhashtable.c
index f4000c1..727d3ec 100644
--- a/lib/test_rhashtable.c
+++ b/lib/test_rhashtable.c
@@ -498,14 +498,16 @@ static unsigned int __init print_ht(struct rhltable *rhlt)
 	char buff[512] = "";
 	unsigned int i, cnt = 0;
 
+	rcu_read_lock();
+
 	ht = &rhlt->ht;
-	tbl = rht_dereference(ht->tbl, ht);
+	tbl = rht_dereference_rcu(ht->tbl, ht);
 	for (i = 0; i < tbl->size; i++) {
 		struct rhash_head *pos, *next;
 		struct test_obj_rhl *p;
 
-		pos = rht_dereference(tbl->buckets[i], ht);
-		next = !rht_is_a_nulls(pos) ? rht_dereference(pos->next, ht) : NULL;
+		pos = rht_dereference_rcu(tbl->buckets[i], ht);
+		next = !rht_is_a_nulls(pos) ? rht_dereference_rcu(pos->next, ht) : NULL;
 
 		if (!rht_is_a_nulls(pos)) {
 			sprintf(buff, "%s\nbucket[%d] -> ", buff, i);
@@ -516,7 +518,7 @@ static unsigned int __init print_ht(struct rhltable *rhlt)
 			sprintf(buff, "%s[[", buff);
 			do {
 				pos = &list->rhead;
-				list = rht_dereference(list->next, ht);
+				list = rht_dereference_rcu(list->next, ht);
 				p = rht_obj(ht, pos);
 
 				sprintf(buff, "%s val %d (tid=%d)%s", buff, p->value.id, p->value.tid,
@@ -526,13 +528,15 @@ static unsigned int __init print_ht(struct rhltable *rhlt)
 
 			pos = next,
 			next = !rht_is_a_nulls(pos) ?
-				rht_dereference(pos->next, ht) : NULL;
+				rht_dereference_rcu(pos->next, ht) : NULL;
 
 			sprintf(buff, "%s]]%s", buff, !rht_is_a_nulls(pos) ? " -> " : "");
 		}
 	}
 	printk(KERN_ERR "\n---- ht: ----%s\n-------------\n", buff);
 
+	rcu_read_unlock();
+
 	return cnt;
 }
 
-- 
1.8.4.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ