]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
rhashtable: Fix rhlist duplicates insertion
authorPaul Blakey <paulb@mellanox.com>
Sun, 4 Mar 2018 15:29:48 +0000 (17:29 +0200)
committerThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Mon, 2 Apr 2018 10:19:48 +0000 (07:19 -0300)
BugLink: http://bugs.launchpad.net/bugs/1760585
[ Upstream commit d3dcf8eb615537526bd42ff27a081d46d337816e ]

When inserting duplicate objects (those with the same key),
current rhlist implementation messes up the chain pointers by
updating the bucket pointer instead of prev next pointer to the
newly inserted node. This causes missing elements on removal and
travesal.

Fix that by properly updating pprev pointer to point to
the correct rhash_head next pointer.

Issue: 1241076
Change-Id: I86b2c140bcb4aeb10b70a72a267ff590bb2b17e7
Fixes: ca26893f05e8 ('rhashtable: Add rhlist interface')
Signed-off-by: Paul Blakey <paulb@mellanox.com>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
include/linux/rhashtable.h
lib/rhashtable.c

index 361c08e35dbc388f0acd2891706d4df8f33026b6..7fd514f36e74a9dbecd3664ed6c917c41326aee1 100644 (file)
@@ -750,8 +750,10 @@ slow_path:
                if (!key ||
                    (params.obj_cmpfn ?
                     params.obj_cmpfn(&arg, rht_obj(ht, head)) :
-                    rhashtable_compare(&arg, rht_obj(ht, head))))
+                    rhashtable_compare(&arg, rht_obj(ht, head)))) {
+                       pprev = &head->next;
                        continue;
+               }
 
                data = rht_obj(ht, head);
 
index ddd7dde87c3ca0db910d67a567f2a68c8d8e847e..b734ce731a7a5c6873cac5f931cd44ea8017e7cf 100644 (file)
@@ -537,8 +537,10 @@ static void *rhashtable_lookup_one(struct rhashtable *ht,
                if (!key ||
                    (ht->p.obj_cmpfn ?
                     ht->p.obj_cmpfn(&arg, rht_obj(ht, head)) :
-                    rhashtable_compare(&arg, rht_obj(ht, head))))
+                    rhashtable_compare(&arg, rht_obj(ht, head)))) {
+                       pprev = &head->next;
                        continue;
+               }
 
                if (!ht->rhlist)
                        return rht_obj(ht, head);