crypto/octeontx2: fix member overlap
Subsystems (2)
PATCH 1/3 crypto/octeontx2: fix member overlap
The member 'dir' should not overlap with 'ip'. Usage of union for all members would mean dir would get corrupt.
--- drivers/crypto/octeontx2/otx2_security.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/crypto/octeontx2/otx2_security.h +6 -4
@@ -20,14 +20,16 @@#define OTX2_SEC_AES_GCM_ROUNDUP_BYTE_LEN 4#define OTX2_SEC_AES_CBC_ROUNDUP_BYTE_LEN 16 -union otx2_sec_session_ipsec { -struct otx2_sec_session_ipsec_ip ip; -struct otx2_sec_session_ipsec_lp lp; +struct otx2_sec_session_ipsec { +union { +struct otx2_sec_session_ipsec_ip ip; +struct otx2_sec_session_ipsec_lp lp; + };enum rte_security_ipsec_sa_direction dir; };struct otx2_sec_session { -union otx2_sec_session_ipsec ipsec; +struct otx2_sec_session_ipsec ipsec;void *userdata;/**< Userdata registered by the application */ } __rte_cache_aligned;
Signature · 1 line
2.7.4
PATCH 2/3 net/octeontx2: add locking for inline IPsec tbl updates
Add locking for IPsec table updates.
Fixed error handling to clear SA entry if the SA
population functions encounters any error.
--- drivers/net/octeontx2/otx2_ethdev.h | 2 + drivers/net/octeontx2/otx2_ethdev_sec.c | 83 +++++++++++++++++++++++++-------- 2 files changed, 66 insertions(+), 19 deletions(-)
drivers/net/octeontx2/otx2_ethdev.h +2 -0
@@ -14,6 +14,7 @@#include <rte_mbuf.h> #include <rte_mempool.h> #include <rte_security_driver.h> +#include <rte_spinlock.h> #include <rte_string_fns.h> #include <rte_time.h>
@@ -356,6 +357,7 @@ struct otx2_eth_dev {bool sdp_link;/* SDP flag */ /* Inline IPsec params */ uint16_t ipsec_in_max_spi; +rte_spinlock_t ipsec_tbl_lock;uint8_t duplex;uint32_t speed; } __rte_cache_aligned;
drivers/net/octeontx2/otx2_ethdev_sec.c +64 -19
162 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH 3/3 net/octeontx2: clear SA valid during session destroy
In reply to Anoob JosephSA table entry would be reserved for inline inbound operations. Clear valid bit of the SA so that CPT would treat SA entry as invalid. Also, move setting of valid bit to the end in case of session_create() to eliminate possibility of hardware seeing partial data.
--- drivers/crypto/octeontx2/otx2_ipsec_fp.h | 1 - drivers/net/octeontx2/otx2_ethdev_sec.c | 28 ++++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-)
drivers/crypto/octeontx2/otx2_ipsec_fp.h +0 -1
@@ -365,7 +365,6 @@ ipsec_fp_sa_ctl_set(struct rte_security_ipsec_xform *ipsec, ctl->esn_en =1 ; ctl->spi =rte_cpu_to_be_32 (ipsec->spi); - ctl->valid =1 ;return 0 ; }
drivers/net/octeontx2/otx2_ethdev_sec.c +24 -4
@@ -455,6 +455,9 @@ eth_sec_ipsec_out_sess_create(struct rte_eth_dev *eth_dev, goto cpt_put; } +rte_io_wmb (); + ctl->valid =1 ; +return 0 ; cpt_put:otx2_sec_idev_tx_cpt_qp_put (sess->qp);
@@ -595,6 +598,9 @@ eth_sec_ipsec_in_sess_create(struct rte_eth_dev *eth_dev, sa->esn_hi =0 ; } +rte_io_wmb (); + ctl->valid =1 ; +rte_spinlock_unlock (&dev->ipsec_tbl_lock);return 0 ;
@@ -682,10 +688,12 @@ otx2_eth_sec_free_anti_replay(struct otx2_ipsec_fp_in_sa *sa) }static int -otx2_eth_sec_session_destroy(void *device __rte_unused, +otx2_eth_sec_session_destroy (void *device,struct rte_security_session *sess) { +struct otx2_eth_dev *dev =otx2_eth_pmd_priv (device);struct otx2_sec_session_ipsec_ip *sess_ip; +struct otx2_ipsec_fp_in_sa *sa;struct otx2_sec_session *priv;struct rte_mempool *sess_mp;int ret;
@@ -696,9 +704,21 @@ otx2_eth_sec_session_destroy(void *device __rte_unused, sess_ip = &priv->ipsec.ip; -/* Release the anti replay window */ -if (priv->ipsec.dir ==RTE_SECURITY_IPSEC_SA_DIR_INGRESS ) -otx2_eth_sec_free_anti_replay (sess_ip->in_sa); +if (priv->ipsec.dir ==RTE_SECURITY_IPSEC_SA_DIR_INGRESS ) { +rte_spinlock_lock (&dev->ipsec_tbl_lock); + sa = sess_ip->in_sa; + +/* Release the anti replay window */ +otx2_eth_sec_free_anti_replay (sa); + +/* Clear SA table entry */ +if (sa !=NULL ) { + sa->ctl.valid =0 ; +rte_io_wmb (); + } + +rte_spinlock_unlock (&dev->ipsec_tbl_lock); + }/* Release CPT LF used for this session */ if (sess_ip->qp !=NULL ) {
Signature · 1 line
2.7.4
Quoted 9 lines
The member 'dir' should not overlap with 'ip'. Usage of union for all members would mean dir would get corrupt.
Fixes e91b4f45ff54 ("net/octeontx2: support anti-replay for securitysession")
Cc: [email protected]Signed-off-by Anoob Joseph <[email protected]>
Series
Applied to dpdk-next-crypto
Thanks.