Skip to contentSkip to conversation

crypto/qat: fix segmentation fault in QAT PMD

PATCH In review Bernard Iremonger 3 participants 5 messages Apr 8, 2019 – Apr 10, 2019 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto/qat: fix segmentation fault in QAT PMD

While running the IPsec unit test program the following segmentation fault is occurring:

Thread 1 "test" received signal SIGSEGV, Segmentation fault. 0x0000000000beaece in qat_sym_build_request(in_op=0x0, out_msg=0x100450580 "", op_cookie=0x101c6fd80, qat_dev_gen=QAT_GEN1) at /root/dpdk_ipsec_master-1/drivers/crypto/qat/qat_sym.c:165 165 if (unlikely(op->type != RTE_CRYPTO_OP_TYPE_SYMMETRIC)) {

Fixes c0f87eb5252b ("cryptodev: change burst API to be crypto op oriented")
---
 drivers/crypto/qat/qat_sym.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/crypto/qat/qat_sym.c +6 -0
index 8801ca5..4a7d11e 100644
@@ -162,6 +162,12 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
 	struct qat_sym_op_cookie *cookie =
 				(struct qat_sym_op_cookie *)op_cookie;
 
+	if (op == NULL) {
+		QAT_DP_LOG(ERR, "QAT PMD only supports symmetric crypto "
+				"operation requests, op (%p) is NULL", op);
+		return -EINVAL;
+	}
+
 	if (unlikely(op->type != RTE_CRYPTO_OP_TYPE_SYMMETRIC)) {
 		QAT_DP_LOG(ERR, "QAT PMD only supports symmetric crypto "
 				"operation requests, op (%p) is not a "
Signature · 1 line
2.7.4
#1 lore raw

Hi Bernard,

Quoted 23 lines

While running the IPsec unit test program the following segmentation fault is occurring:

Thread 1 "test" received signal SIGSEGV, Segmentation fault. 0x0000000000beaece in qat_sym_build_request(in_op=0x0, out_msg=0x100450580 "", op_cookie=0x101c6fd80, qat_dev_gen=QAT_GEN1) at /root/dpdk_ipsec_master-1/drivers/crypto/qat/qat_sym.c:165 165 if (unlikely(op->type != RTE_CRYPTO_OP_TYPE_SYMMETRIC)) {

Fixes c0f87eb5252b ("cryptodev: change burst API to be crypto op oriented")
---
 drivers/crypto/qat/qat_sym.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/crypto/qat/qat_sym.c +0 -0
index 8801ca5..4a7d11e 100644
@@ -162,6 +162,12 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
 	struct qat_sym_op_cookie *cookie =
 				(struct qat_sym_op_cookie *)op_cookie;

drivers/crypto/qat/qat_sym.c qat_sym_build_request(void *in_op, uint8_t *out_msg, · line 173

Quoted 10 lines
drivers/crypto/qat/qat_sym.c +6 -0
 
+	if (op == NULL) {
+		QAT_DP_LOG(ERR, "QAT PMD only supports symmetric crypto "
+				"operation requests, op (%p) is NULL", op);
+		return -EINVAL;
+	}
+
 	if (unlikely(op->type != RTE_CRYPTO_OP_TYPE_SYMMETRIC)) {
 		QAT_DP_LOG(ERR, "QAT PMD only supports symmetric crypto "
 				"operation requests, op (%p) is not a "

This is crypto-dev enqueue data-path, if I am not mistaken.
I think in that case it is caller responsibility to make sure that ops[] contain valid crypto-ops (as in majority of other data-path functions).
Suppose the main question here - why ipsec UT passes NULL as crypto-op here? Konstantin

#2 lore raw

Hi Konstantin,

<snip>

Quoted 31 lines

Subject: RE: [PATCH] crypto/qat: fix segmentation fault in QAT PMD

Hi Bernard,

Quoted 7 lines

While running the IPsec unit test program the following segmentation fault is occurring:

Thread 1 "test" received signal SIGSEGV, Segmentation fault. 0x0000000000beaece in qat_sym_build_request(in_op=0x0, out_msg=0x100450580 "", op_cookie=0x101c6fd80,

qat_dev_gen=QAT_GEN1)

drivers/crypto/qat/qat_sym.c qat_sym_build_request(void *in_op, uint8_t

Quoted 15 lines

at /root/dpdk_ipsec_master-1/drivers/crypto/qat/qat_sym.c:165 165 if (unlikely(op->type != RTE_CRYPTO_OP_TYPE_SYMMETRIC)) {

Fixes c0f87eb5252b ("cryptodev: change burst API to be crypto op

oriented")

---
 drivers/crypto/qat/qat_sym.c | 6 ++++++
 1 file changed, 6 insertions(+)
(quoted diff) +0 -0

b/drivers/crypto/qat/qat_sym.c index 8801ca5..4a7d11e 100644

drivers/crypto/qat/qat_sym.c +0 -0
@@ -162,6 +162,12 @@ qat_sym_build_request(void *in_op, uint8_t

*out_msg,

Quoted 3 lines
drivers/crypto/qat/qat_sym.c +0 -0
 	struct qat_sym_op_cookie *cookie =
 				(struct qat_sym_op_cookie *)op_cookie;
 
Quoted 15 lines

drivers/crypto/qat/qat_sym.c qat_sym_build_request(void *in_op, uint8_t *out_msg, · line 173

Quoted 9 lines
drivers/crypto/qat/qat_sym.c +6 -0
+	if (op == NULL) {
+		QAT_DP_LOG(ERR, "QAT PMD only supports symmetric crypto "
+				"operation requests, op (%p) is NULL", op);
+		return -EINVAL;
+	}
+
 	if (unlikely(op->type != RTE_CRYPTO_OP_TYPE_SYMMETRIC)) {
 		QAT_DP_LOG(ERR, "QAT PMD only supports symmetric crypto "
 				"operation requests, op (%p) is not a "

This is crypto-dev enqueue data-path, if I am not mistaken.
I think in that case it is caller responsibility to make sure that ops[] contain valid crypto-ops (as in majority of other data-path functions).
Suppose the main question here - why ipsec UT passes NULL as crypto-op here? Konstantin

I will investigate further.

Regards,

Bernard.

#3 lore raw
In reply to Ananyev, Konstantin

Hi Bernard, Konstantin,

Quoted 33 lines

-----Original Message-----
From: Ananyev, Konstantin
Sent: Monday, April 8, 2019 1:10 PM
To: Iremonger, Bernard <[email protected]>; [email protected]; Trahe, Fiona <[email protected]>; [email protected]
Subject: RE: [PATCH] crypto/qat: fix segmentation fault in QAT PMD

Hi Bernard,

Quoted 24 lines

While running the IPsec unit test program the following segmentation fault is occurring:

Thread 1 "test" received signal SIGSEGV, Segmentation fault. 0x0000000000beaece in qat_sym_build_request(in_op=0x0, out_msg=0x100450580 "", op_cookie=0x101c6fd80, qat_dev_gen=QAT_GEN1) at /root/dpdk_ipsec_master-1/drivers/crypto/qat/qat_sym.c:165 165 if (unlikely(op->type != RTE_CRYPTO_OP_TYPE_SYMMETRIC)) {

Fixes c0f87eb5252b ("cryptodev: change burst API to be crypto op oriented")
---
 drivers/crypto/qat/qat_sym.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/crypto/qat/qat_sym.c +0 -0
index 8801ca5..4a7d11e 100644
@@ -162,6 +162,12 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
 	struct qat_sym_op_cookie *cookie =
 				(struct qat_sym_op_cookie *)op_cookie;
 
Quoted 15 lines

drivers/crypto/qat/qat_sym.c qat_sym_build_request(void *in_op, uint8_t *out_msg, · line 173

Quoted 9 lines
drivers/crypto/qat/qat_sym.c +6 -0
+	if (op == NULL) {
+		QAT_DP_LOG(ERR, "QAT PMD only supports symmetric crypto "
+				"operation requests, op (%p) is NULL", op);
+		return -EINVAL;
+	}
+
 	if (unlikely(op->type != RTE_CRYPTO_OP_TYPE_SYMMETRIC)) {
 		QAT_DP_LOG(ERR, "QAT PMD only supports symmetric crypto "
 				"operation requests, op (%p) is not a "

This is crypto-dev enqueue data-path, if I am not mistaken.
I think in that case it is caller responsibility to make sure that ops[] contain valid crypto-ops (as in majority of other data-path functions).
Suppose the main question here - why ipsec UT passes NULL as crypto-op here? Konstantin

[Fiona] Agree with Konstantin - it's the data-path - we expect a valid op ptr. Can the real issue be related to the recent addition of asymmetric QAT PMD?
Not all QAT PMDs support symmetric crypto now.
Is IPSec unit test finding a QAT asymm PMD and not checking it's capabilities or checking but not handling the result well and following a path that passes a NULL op to it?

#4 lore raw

Hi Fiona,

<snip>

Quoted 47 lines
Quoted 11 lines

Subject: RE: [PATCH] crypto/qat: fix segmentation fault in QAT PMD

Hi Bernard,

Quoted 7 lines

While running the IPsec unit test program the following segmentation fault is occurring:

Thread 1 "test" received signal SIGSEGV, Segmentation fault. 0x0000000000beaece in qat_sym_build_request(in_op=0x0, out_msg=0x100450580 "", op_cookie=0x101c6fd80,

qat_dev_gen=QAT_GEN1)

Quoted 10 lines
Quoted 10 lines

at /root/dpdk_ipsec_master-1/drivers/crypto/qat/qat_sym.c:165 165 if (unlikely(op->type != RTE_CRYPTO_OP_TYPE_SYMMETRIC)) {

Fixes c0f87eb5252b ("cryptodev: change burst API to be crypto op

oriented")

---
 drivers/crypto/qat/qat_sym.c | 6 ++++++
 1 file changed, 6 insertions(+)
Quoted 5 lines

drivers/crypto/qat/qat_sym.c qat_sym_build_request(void *in_op, uint8_t

Quoted 5 lines
(quoted diff) +0 -0

b/drivers/crypto/qat/qat_sym.c index 8801ca5..4a7d11e 100644

drivers/crypto/qat/qat_sym.c +0 -0
@@ -162,6 +162,12 @@ qat_sym_build_request(void *in_op, uint8_t

*out_msg,

Quoted 5 lines

drivers/crypto/qat/qat_sym.c qat_sym_build_request(void *in_op, uint8_t *out_msg,

Quoted 5 lines
drivers/crypto/qat/qat_sym.c +2 -0
 	struct qat_sym_op_cookie *cookie =
 				(struct qat_sym_op_cookie *)op_cookie;
 
+	if (op == NULL) {
+		QAT_DP_LOG(ERR, "QAT PMD only supports symmetric

crypto "

Quoted 6 lines

drivers/crypto/qat/qat_sym.c qat_sym_build_request(void *in_op, uint8_t *out_msg,

Quoted 6 lines
drivers/crypto/qat/qat_sym.c +4 -0
+				"operation requests, op (%p) is NULL", op);
+		return -EINVAL;
+	}
+
 	if (unlikely(op->type != RTE_CRYPTO_OP_TYPE_SYMMETRIC)) {
 		QAT_DP_LOG(ERR, "QAT PMD only supports symmetric

crypto "

Quoted 6 lines

drivers/crypto/qat/qat_sym.c qat_sym_build_request(void *in_op, uint8_t *out_msg, · line 173

Quoted 1 line
drivers/crypto/qat/qat_sym.c +0 -0
 				"operation requests, op (%p) is not a "

This is crypto-dev enqueue data-path, if I am not mistaken.
I think in that case it is caller responsibility to make sure that ops[] contain valid crypto-ops (as in majority of other data-path functions). Suppose the main question here - why ipsec UT passes NULL as crypto-op

Quoted 8 lines

here?

Quoted 1 line

Konstantin

[Fiona] Agree with Konstantin - it's the data-path - we expect a valid op ptr. Can the real issue be related to the recent addition of asymmetric QAT PMD? Not all QAT PMDs support symmetric crypto now.
Is IPSec unit test finding a QAT asymm PMD and not checking it's capabilities or checking but not handling the result well and following a path that passes a NULL op to it?

Self NAK, issue found in test_ipsec code.

Regards,

Bernard.