hash: fix race condition in iterate
authorYipeng Wang <yipeng1.wang@intel.com>
Mon, 22 Oct 2018 18:39:45 +0000 (11:39 -0700)
committerThomas Monjalon <thomas@monjalon.net>
Thu, 25 Oct 2018 22:33:51 +0000 (00:33 +0200)
commit99040943442426ebfef0ad69eca73559a9e3b730
treec48da4161318a453c0b3eafa202e8dc2f06b30ee
parent86c1ef20908eb1c7574f581569d2800d00a9846f
hash: fix race condition in iterate

In rte_hash_iterate, the reader lock did not protect the
while loop which checks empty entry. This created a race
condition that the entry may become empty when enters
the lock, then a wrong key data value would be read out.

This commit reads out the position in the while condition,
which makes sure that the position will not be changed
to empty before entering the lock.

Fixes: f2e3001b53ec ("hash: support read/write concurrency")
Cc: stable@dpdk.org
Reported-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Signed-off-by: Yipeng Wang <yipeng1.wang@intel.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Acked-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
lib/librte_hash/rte_cuckoo_hash.c