DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] l2fwd-crypto: fix supported key size check
@ 2016-04-12 10:04 Pablo de Lara
  2016-04-19  8:41 ` Cao, Min
  2016-06-07 20:23 ` Thomas Monjalon
  0 siblings, 2 replies; 3+ messages in thread
From: Pablo de Lara @ 2016-04-12 10:04 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

When initializing crypto devices within the app,
the provided key sizes are checked against the supported
sizes from the crypto device capabilities.

When the supported sizes are not a range, but a single value,
the check may become an infinite loop (when size is not supported).

Fixes: a061e50a0d97 ("examples/l2fwd-crypto: fix ambiguous input key size")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 examples/l2fwd-crypto/main.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index d4e2d8d..e273f2f 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -1486,6 +1486,15 @@ check_supported_size(uint16_t length, uint16_t min, uint16_t max,
 {
 	uint16_t supp_size;
 
+	/* Single value */
+	if (increment == 0) {
+		if (length == min)
+			return 0;
+		else
+			return -1;
+	}
+
+	/* Range of values */
 	for (supp_size = min; supp_size <= max; supp_size += increment) {
 		if (length == supp_size)
 			return 0;
-- 
2.5.5

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] l2fwd-crypto: fix supported key size check
  2016-04-12 10:04 [dpdk-dev] [PATCH] l2fwd-crypto: fix supported key size check Pablo de Lara
@ 2016-04-19  8:41 ` Cao, Min
  2016-06-07 20:23 ` Thomas Monjalon
  1 sibling, 0 replies; 3+ messages in thread
From: Cao, Min @ 2016-04-19  8:41 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, dev; +Cc: Doherty, Declan, De Lara Guarch, Pablo

Tested-by: Min Cao <min.cao@intel.com>

- Tested Commit: b3b9719f18ee83773c6ed7adda300c5ac63c37e9
- OS: Fedora20 3.11.10-301.fc20.x86_64
- GCC: gcc (GCC) 4.8.3
- CPU: Intel(R) Xeon(R) CPU E5-2658 v3 @ 2.20GHz
- NIC: Niantic
- Default x86_64-native-linuxapp-gcc configuration
- Prerequisites:
- Total 1 cases, 1 passed, 0 failed

- test case 1: l2fwd-crypto with 64 bytes auth_key
    Total 1 cases, 1 passed, 0 failed

-----Original Message-----
From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Pablo de Lara
Sent: Tuesday, April 12, 2016 6:04 PM
To: dev@dpdk.org
Cc: Doherty, Declan; De Lara Guarch, Pablo
Subject: [dpdk-dev] [PATCH] l2fwd-crypto: fix supported key size check

When initializing crypto devices within the app, the provided key sizes are checked against the supported sizes from the crypto device capabilities.

When the supported sizes are not a range, but a single value, the check may become an infinite loop (when size is not supported).

Fixes: a061e50a0d97 ("examples/l2fwd-crypto: fix ambiguous input key size")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 examples/l2fwd-crypto/main.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index d4e2d8d..e273f2f 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -1486,6 +1486,15 @@ check_supported_size(uint16_t length, uint16_t min, uint16_t max,  {
 	uint16_t supp_size;
 
+	/* Single value */
+	if (increment == 0) {
+		if (length == min)
+			return 0;
+		else
+			return -1;
+	}
+
+	/* Range of values */
 	for (supp_size = min; supp_size <= max; supp_size += increment) {
 		if (length == supp_size)
 			return 0;
--
2.5.5

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] l2fwd-crypto: fix supported key size check
  2016-04-12 10:04 [dpdk-dev] [PATCH] l2fwd-crypto: fix supported key size check Pablo de Lara
  2016-04-19  8:41 ` Cao, Min
@ 2016-06-07 20:23 ` Thomas Monjalon
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2016-06-07 20:23 UTC (permalink / raw)
  To: Pablo de Lara; +Cc: dev, declan.doherty, Min Cao

> When initializing crypto devices within the app,
> the provided key sizes are checked against the supported
> sizes from the crypto device capabilities.
> 
> When the supported sizes are not a range, but a single value,
> the check may become an infinite loop (when size is not supported).
> 
> Fixes: a061e50a0d97 ("examples/l2fwd-crypto: fix ambiguous input key size")
> 
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

Tested-by: Min Cao <min.cao@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-06-07 20:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-12 10:04 [dpdk-dev] [PATCH] l2fwd-crypto: fix supported key size check Pablo de Lara
2016-04-19  8:41 ` Cao, Min
2016-06-07 20:23 ` Thomas Monjalon

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).