Skip to contentSkip to conversation

examples/ipsec-secgw: return on encountering algo as NULL

PATCH Superseded Savinay Dharmappa 3 participants 6 messages Dec 12, 2019 – Jan 15, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 examples/ipsec-secgw: return on encountering algo as NULL

if algo is NULL set the status to error and return.

---
 examples/ipsec-secgw/sa.c | 9 +++++++++
 1 file changed, 9 insertions(+)
examples/ipsec-secgw/sa.c +9 -0
index 7f046e3ed..c75a5a15f 100644
@@ -314,6 +314,9 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 			APP_CHECK(algo != NULL, status, "unrecognized "
 				"input \"%s\"", tokens[ti]);
 
+			if (status->status < 0)
+				return;
+
 			rule->cipher_algo = algo->algo;
 			rule->block_size = algo->block_size;
 			rule->iv_len = algo->iv_len;
@@ -378,6 +381,9 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 			APP_CHECK(algo != NULL, status, "unrecognized "
 				"input \"%s\"", tokens[ti]);
 
+			if (status->status < 0)
+				return;
+
 			rule->auth_algo = algo->algo;
 			rule->auth_key_len = algo->key_len;
 			rule->digest_len = algo->digest_len;
@@ -433,6 +439,9 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 			APP_CHECK(algo != NULL, status, "unrecognized "
 				"input \"%s\"", tokens[ti]);
 
+			if (status->status < 0)
+				return;
+
 			rule->aead_algo = algo->algo;
 			rule->cipher_key_len = algo->key_len;
 			rule->digest_len = algo->digest_len;
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw

Hi,

Quoted 1 line

if algo is NULL set the status to error and return.

As this is a bug fix please add 'fix' to the commit header:
examples/ipsec-secgw: fix ...

Also probably worth to add 1-2 line explanation why this is needed into the commit message.

Apart from that:

Quoted 42 lines
---
 examples/ipsec-secgw/sa.c | 9 +++++++++
 1 file changed, 9 insertions(+)
examples/ipsec-secgw/sa.c +9 -1
index 7f046e3ed..c75a5a15f 100644
@@ -314,6 +314,9 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 			APP_CHECK(algo != NULL, status, "unrecognized "
 				"input \"%s\"", tokens[ti]);
 
+			if (status->status < 0)
+				return;
+
 			rule->cipher_algo = algo->algo;
 			rule->block_size = algo->block_size;
 			rule->iv_len = algo->iv_len;
@@ -378,6 +381,9 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 			APP_CHECK(algo != NULL, status, "unrecognized "
 				"input \"%s\"", tokens[ti]);
 
+			if (status->status < 0)
+				return;
+
 			rule->auth_algo = algo->algo;
 			rule->auth_key_len = algo->key_len;
 			rule->digest_len = algo->digest_len;
@@ -433,6 +439,9 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 			APP_CHECK(algo != NULL, status, "unrecognized "
 				"input \"%s\"", tokens[ti]);
 
+			if (status->status < 0)
+				return;
+
 			rule->aead_algo = algo->algo;
 			rule->cipher_key_len = algo->key_len;
 			rule->digest_len = algo->digest_len;
--

2.17.1

#2 lore raw

PATCH v2 1/1 examples/ipsec-secgw: return on encountering algo as NULL

In reply to Savinay Dharmappa

if algo is NULL set the status to error and return. This change prevent crashing of ipsec-secgw application when a specific cipher/auth/aead algo are not supported by application.

Fixes 0d547ed03717 ("examples/ipsec-secgw: support configuration file")
---
 examples/ipsec-secgw/sa.c | 9 +++++++++
 1 file changed, 9 insertions(+)
examples/ipsec-secgw/sa.c +9 -0
index 7f046e3ed..c75a5a15f 100644
@@ -314,6 +314,9 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 			APP_CHECK(algo != NULL, status, "unrecognized "
 				"input \"%s\"", tokens[ti]);
 
+			if (status->status < 0)
+				return;
+
 			rule->cipher_algo = algo->algo;
 			rule->block_size = algo->block_size;
 			rule->iv_len = algo->iv_len;
@@ -378,6 +381,9 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 			APP_CHECK(algo != NULL, status, "unrecognized "
 				"input \"%s\"", tokens[ti]);
 
+			if (status->status < 0)
+				return;
+
 			rule->auth_algo = algo->algo;
 			rule->auth_key_len = algo->key_len;
 			rule->digest_len = algo->digest_len;
@@ -433,6 +439,9 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 			APP_CHECK(algo != NULL, status, "unrecognized "
 				"input \"%s\"", tokens[ti]);
 
+			if (status->status < 0)
+				return;
+
 			rule->aead_algo = algo->algo;
 			rule->cipher_key_len = algo->key_len;
 			rule->digest_len = algo->digest_len;
Signature · 1 line
2.17.1
#3 lore raw

Hi,

Quoted 3 lines

if algo is NULL set the status to error and return. This change prevent crashing of ipsec-secgw application when a specific cipher/auth/aead algo are not supported by application.

It seems you forgot 'fix' in the header 😊
examples/ipsec-secgw: fix ...

Quoted 45 lines
Fixes 0d547ed03717 ("examples/ipsec-secgw: support configuration file")
---
 examples/ipsec-secgw/sa.c | 9 +++++++++
 1 file changed, 9 insertions(+)
examples/ipsec-secgw/sa.c +9 -1
index 7f046e3ed..c75a5a15f 100644
@@ -314,6 +314,9 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 			APP_CHECK(algo != NULL, status, "unrecognized "
 				"input \"%s\"", tokens[ti]);
 
+			if (status->status < 0)
+				return;
+
 			rule->cipher_algo = algo->algo;
 			rule->block_size = algo->block_size;
 			rule->iv_len = algo->iv_len;
@@ -378,6 +381,9 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 			APP_CHECK(algo != NULL, status, "unrecognized "
 				"input \"%s\"", tokens[ti]);
 
+			if (status->status < 0)
+				return;
+
 			rule->auth_algo = algo->algo;
 			rule->auth_key_len = algo->key_len;
 			rule->digest_len = algo->digest_len;
@@ -433,6 +439,9 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 			APP_CHECK(algo != NULL, status, "unrecognized "
 				"input \"%s\"", tokens[ti]);
 
+			if (status->status < 0)
+				return;
+
 			rule->aead_algo = algo->algo;
 			rule->cipher_key_len = algo->key_len;
 			rule->digest_len = algo->digest_len;
--

2.17.1

Applied
#4 lore raw
Quoted 9 lines

Hi,

Quoted 3 lines

if algo is NULL set the status to error and return. This change prevent crashing of ipsec-secgw application when a specific cipher/auth/aead algo are not supported by application.

It seems you forgot 'fix' in the header 😊
examples/ipsec-secgw: fix ...

Fixed title.

Quoted 7 lines
Quoted 7 lines
Fixes 0d547ed03717 ("examples/ipsec-secgw: support configuration file")

---

Applied to dpdk-next-crypto

Thanks

#5 lore raw

PATCH v3 1/1 examples/ipsec-secgw: fix application crash.

In reply to Savinay Dharmappa

if algo is NULL set the status to error and return. This change prevent crashing of ipsec-secgw application when a specific cipher/auth/aead algo are not supported by application.

Fixes 0d547ed03717 ("examples/ipsec-secgw: support configuration file")
---
 examples/ipsec-secgw/sa.c | 9 +++++++++
 1 file changed, 9 insertions(+)
examples/ipsec-secgw/sa.c +9 -0
index 7f046e3ed..c75a5a15f 100644
@@ -314,6 +314,9 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 			APP_CHECK(algo != NULL, status, "unrecognized "
 				"input \"%s\"", tokens[ti]);
 
+			if (status->status < 0)
+				return;
+
 			rule->cipher_algo = algo->algo;
 			rule->block_size = algo->block_size;
 			rule->iv_len = algo->iv_len;
@@ -378,6 +381,9 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 			APP_CHECK(algo != NULL, status, "unrecognized "
 				"input \"%s\"", tokens[ti]);
 
+			if (status->status < 0)
+				return;
+
 			rule->auth_algo = algo->algo;
 			rule->auth_key_len = algo->key_len;
 			rule->digest_len = algo->digest_len;
@@ -433,6 +439,9 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 			APP_CHECK(algo != NULL, status, "unrecognized "
 				"input \"%s\"", tokens[ti]);
 
+			if (status->status < 0)
+				return;
+
 			rule->aead_algo = algo->algo;
 			rule->cipher_key_len = algo->key_len;
 			rule->digest_len = algo->digest_len;
Signature · 1 line
2.17.1