patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Cc: dpdk stable <stable@dpdk.org>,
	Saikrishna Edupuganti <saikrishna.edupuganti@intel.com>
Subject: [dpdk-stable] patch 'hash: fix false zero signature key hit lookup' has been queued to stable release 16.07.1
Date: Wed, 12 Oct 2016 14:44:24 +0800	[thread overview]
Message-ID: <57fddbc8.ul6hqq31CfNtnNmN%yuanhan.liu@linux.intel.com> (raw)

Hi,

FYI, your patch has been queued to stable release 16.07.1

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable
yet. It will be pushed if I get no objections before this Friday.
So please shutout if anyone has objections.

Thanks.

	--yliu

---
>From f949b7c99ecfb5bf9c964b045df876c12ceb89c3 Mon Sep 17 00:00:00 2001
From: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Date: Fri, 26 Aug 2016 22:30:08 +0100
Subject: [PATCH] hash: fix false zero signature key hit lookup

[ upstream commit 24c20a7221e1220baa680c55fc577a5bfe0f4889 ]

This commit fixes a corner case scenario. When a key is deleted,
its signature in the hash table gets clear, which should prevent
a lookup of that same key, unless the signature of the key is all zeroes.

In that case, there will be a match, and key would be compared against
the key that is in the table (which does not get cleared,
as the performance penalty would be high), resulting in a wrong hit.

To prevent this from happening, the key index associated to that entry
should be set to zero when deleting it, so in case that same key
is looked up just after a deletion, it will point to the dummy key slot,
which guarantees a miss.

Fixes: 48a399119619 ("hash: replace with cuckoo hash implementation")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Saikrishna Edupuganti <saikrishna.edupuganti@intel.com>
---
 lib/librte_hash/rte_cuckoo_hash.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 63fa036..be1490a 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -815,6 +815,7 @@ __rte_hash_del_key_with_hash(const struct rte_hash *h, const void *key,
 	unsigned i;
 	struct rte_hash_bucket *bkt;
 	struct rte_hash_key *k, *keys = h->key_store;
+	int32_t ret;
 
 	bucket_idx = sig & h->bucket_bitmask;
 	bkt = &h->buckets[bucket_idx];
@@ -832,7 +833,9 @@ __rte_hash_del_key_with_hash(const struct rte_hash *h, const void *key,
 				 * Return index where key is stored,
 				 * substracting the first dummy index
 				 */
-				return bkt->key_idx[i] - 1;
+				ret = bkt->key_idx[i] - 1;
+				bkt->key_idx[i] = 0;
+				return ret;
 			}
 		}
 	}
@@ -855,7 +858,9 @@ __rte_hash_del_key_with_hash(const struct rte_hash *h, const void *key,
 				 * Return index where key is stored,
 				 * substracting the first dummy index
 				 */
-				return bkt->key_idx[i] - 1;
+				ret = bkt->key_idx[i] - 1;
+				bkt->key_idx[i] = 0;
+				return ret;
 			}
 		}
 	}
-- 
1.9.0

                 reply	other threads:[~2016-10-12  6:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57fddbc8.ul6hqq31CfNtnNmN%yuanhan.liu@linux.intel.com \
    --to=yuanhan.liu@linux.intel.com \
    --cc=pablo.de.lara.guarch@intel.com \
    --cc=saikrishna.edupuganti@intel.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).