crypto: api - Change completion callback argument to void star
Subsystems (16)
Herbert Xu
maintainercover crypto: api - Change completion callback argument to void star
Hi:
The crypto completion function currently takes a pointer to a struct crypto_async_request object. However, in reality the API does not allow the use of any part of the object apart from the data field. For example, ahash/shash will create a fake object on the stack to pass along a different data field.
This leads to potential bugs where the user may try to dereference or otherwise use the crypto_async_request object.
This series changes the completion function to take a void * argument instead of crypto_async_request.
This series touches code in a number of different subsystems. Most of them are trivial except for tls which was actually buggy as it did exactly what was described above.
I'd like to pull all the changes through the crypto tree. But feel free to object if you'd like the relevant patches to go through your trees instead and I'll split this up.
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Herbert Xu
maintainerPATCH 1/17 dm: Add scaffolding to change completion function signature
This patch adds temporary scaffolding so that the Crypto API completion function can take a void * instead of crypto_async_request. Once affected users have been converted this can be removed.
---
drivers/md/dm-crypt.c | 8 +++----- drivers/md/dm-integrity.c | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-)
drivers/md/dm-crypt.c +3 -5
@@ -1458,8 +1458,7 @@ static int crypt_convert_block_skcipher(struct crypt_config *cc,return r; } -static void kcryptd_async_done (struct crypto_async_request *async_req, -int error); +static void kcryptd_async_done (crypto_completion_data_t *async_req,int error);static int crypt_alloc_req_skcipher (struct crypt_config *cc,struct convert_context *ctx)
@@ -2147,10 +2146,9 @@ static void kcryptd_crypt_read_convert(struct dm_crypt_io *io)crypt_dec_pending (io); } -static void kcryptd_async_done (struct crypto_async_request *async_req, -int error) +static void kcryptd_async_done (crypto_completion_data_t *data,int error) { -struct dm_crypt_request *dmreq = async_req->data; +struct dm_crypt_request *dmreq =crypto_get_completion_data (data);struct convert_context *ctx = dmreq->ctx; struct dm_crypt_io *io = container_of(ctx, struct dm_crypt_io, ctx);struct crypt_config *cc = io->cc;
drivers/md/dm-integrity.c +2 -2
@@ -955,9 +955,9 @@ static void xor_journal(struct dm_integrity_c *ic, bool encrypt, unsigned sectioasync_tx_issue_pending_all (); } -static void complete_journal_encrypt (struct crypto_async_request *req,int err) +static void complete_journal_encrypt (crypto_completion_data_t *data,int err) { -struct journal_completion *comp = req->data; +struct journal_completion *comp =crypto_get_completion_data (data);if (unlikely (err)) {if (likely (err == -EINPROGRESS )) {complete (&comp->ic->crypto_backoff);
This is an automated email and please do not reply to this email.
Dear Submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.
----- Output -----
error: patch failed: crypto/ahash.c:240
error: crypto/ahash.c: patch does not apply
error: patch failed: crypto/cryptd.c:281
error: crypto/cryptd.c: patch does not apply
error: patch failed: crypto/essiv.c:166
error: crypto/essiv.c: patch does not apply
error: patch failed: crypto/rsa-pkcs1pad.c:210
error: crypto/rsa-pkcs1pad.c: patch does not apply
error: patch failed: include/linux/crypto.h:176
error: include/linux/crypto.h: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch
Please resolve the issue and submit the patches again.
---
Regards,
Linux Bluetooth
Re: [PATCH 1/17] dm: Add scaffolding to change completion function signature
In reply to Herbert XuQuoted 5 lines · Herbert Xu
This patch adds temporary scaffolding so that the Crypto API completion function can take a void * instead of
crypto_async_request. Once affected users have been converted this can be removed.Signed-off-by Herbert Xu <[email protected]>
Herbert Xu
maintainerPATCH 2/17 net: macsec: Add scaffolding to change completion function signature
In reply to Herbert XuThis patch adds temporary scaffolding so that the Crypto API completion function can take a void * instead of crypto_async_request. Once affected users have been converted this can be removed.
---
drivers/net/macsec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/macsec.c +4 -4
@@ -528,9 +528,9 @@ static void count_tx(struct net_device *dev, int ret, int len) } } -static void macsec_encrypt_done (struct crypto_async_request *base,int err) +static void macsec_encrypt_done (crypto_completion_data_t *data,int err) { -struct sk_buff *skb = base->data; +struct sk_buff *skb =crypto_get_completion_data (data);struct net_device *dev = skb->dev;struct macsec_dev *macsec =macsec_priv (dev);struct macsec_tx_sa *sa =macsec_skb_cb (skb)->tx_sa;
@@ -835,9 +835,9 @@ static void count_rx(struct net_device *dev, int len)u64_stats_update_end (&stats->syncp); } -static void macsec_decrypt_done (struct crypto_async_request *base,int err) +static void macsec_decrypt_done (crypto_completion_data_t *data,int err) { -struct sk_buff *skb = base->data; +struct sk_buff *skb =crypto_get_completion_data (data);struct net_device *dev = skb->dev;struct macsec_dev *macsec =macsec_priv (dev);struct macsec_rx_sa *rx_sa =macsec_skb_cb (skb)->rx_sa;
Re: [PATCH 2/17] net: macsec: Add scaffolding to change completion function signature
Quoted 1 line · Herbert Xu
This patch adds temporary scaffolding so that the Crypto API
nit: "Add ..."
Quoted 27 lines
completion function can take a void * instead of
crypto_async_request. Once affected users have been converted this can be removed.Signed-off-by Herbert Xu <[email protected]>---
drivers/net/macsec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/net/macsec.c +2
-2@@ -528,9 +528,9 @@ static void count_tx(struct net_device *dev, int ret, int len) } } -static void macsec_encrypt_done (struct crypto_async_request *base,int err) +static void macsec_encrypt_done (crypto_completion_data_t *data,int err) { -struct sk_buff *skb = base->data; +struct sk_buff *skb =crypto_get_completion_data (data);struct net_device *dev = skb->dev;struct macsec_dev *macsec =macsec_priv (dev);struct macsec_tx_sa *sa =macsec_skb_cb (skb)->tx_sa;@@ -835,9 +835,9 @@ static void count_rx(struct net_device *dev, int len)u64_stats_update_end (&stats->syncp);
drivers/net/macsec.c static void count_rx(struct net_device *dev, int len) · line 843
Quoted 10 lines
drivers/net/macsec.c +2
-2} -static void macsec_decrypt_done (struct crypto_async_request *base,int err) +static void macsec_decrypt_done (crypto_completion_data_t *data,int err) { -struct sk_buff *skb = base->data; +struct sk_buff *skb =crypto_get_completion_data (data);struct net_device *dev = skb->dev;struct macsec_dev *macsec =macsec_priv (dev);struct macsec_rx_sa *rx_sa =macsec_skb_cb (skb)->rx_sa;
BR, Jarkko
Herbert Xu
maintainerPATCH 3/17 fs: ecryptfs: Use crypto_wait_req
In reply to Herbert XuThis patch replaces the custom crypto completion function with crypto_req_done.
---
fs/ecryptfs/crypto.c | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-)
fs/ecryptfs/crypto.c +3 -27
@@ -260,22 +260,6 @@ int virt_to_scatterlist(const void *addr, int size, struct scatterlist *sg,return i; } -struct extent_crypt_result { -struct completion completion; -int rc; -}; - -static void extent_crypt_complete (struct crypto_async_request *req,int rc) -{ -struct extent_crypt_result *ecr = req->data; - -if (rc == -EINPROGRESS ) -return ; - - ecr->rc = rc; -complete (&ecr->completion); -} -/** * crypt_scatterlist * @crypt_stat: Pointer to the crypt_stat struct to initialize.
@@ -293,7 +277,7 @@ static int crypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat, unsigned char *iv, int op) {struct skcipher_request *req =NULL ; -struct extent_crypt_result ecr; +DECLARE_CRYPTO_WAIT (ecr);int rc =0 ;if (unlikely (ecryptfs_verbosity >0 )) {
@@ -303,8 +287,6 @@ static int crypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat, crypt_stat->key_size); } -init_completion (&ecr.completion); -mutex_lock (&crypt_stat->cs_tfm_mutex); req =skcipher_request_alloc (crypt_stat->tfm,GFP_NOFS );if (!req) {
@@ -315,7 +297,7 @@ static int crypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,skcipher_request_set_callback (req,CRYPTO_TFM_REQ_MAY_BACKLOG |CRYPTO_TFM_REQ_MAY_SLEEP , - extent_crypt_complete, &ecr); + crypto_req_done, &ecr);/* Consider doing this once, when the file is opened */ if (!(crypt_stat->flags &ECRYPTFS_KEY_SET )) { rc = crypto_skcipher_setkey(crypt_stat->tfm, crypt_stat->key,
@@ -334,13 +316,7 @@ static int crypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,skcipher_request_set_crypt (req, src_sg, dst_sg, size, iv); rc = op ==ENCRYPT ?crypto_skcipher_encrypt (req) :crypto_skcipher_decrypt (req); -if (rc == -EINPROGRESS || rc == -EBUSY ) { -struct extent_crypt_result *ecr = req->base.data; - -wait_for_completion (&ecr->completion); - rc = ecr->rc; -reinit_completion (&ecr->completion); - } + rc =crypto_wait_req (rc, &ecr); out:skcipher_request_free (req);return rc;
Re: [PATCH 3/17] fs: ecryptfs: Use crypto_wait_req
Quoted 2 lines · Herbert Xu
This patch replaces the custom crypto completion function with
crypto_req_done.
nit: "Replace the custom crypto ..."
Quoted 66 lines
Signed-off-by Herbert Xu <[email protected]>---
fs/ecryptfs/crypto.c | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-)fs/ecryptfs/crypto.c +2
-21@@ -260,22 +260,6 @@ int virt_to_scatterlist(const void *addr, int size, struct scatterlist *sg,return i; } -struct extent_crypt_result { -struct completion completion; -int rc; -}; - -static void extent_crypt_complete (struct crypto_async_request *req,int rc) -{ -struct extent_crypt_result *ecr = req->data; - -if (rc == -EINPROGRESS ) -return ; - - ecr->rc = rc; -complete (&ecr->completion); -} -/** * crypt_scatterlist * @crypt_stat: Pointer to the crypt_stat struct to initialize. @@ -293,7 +277,7 @@ static int crypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat, unsigned char *iv, int op) {struct skcipher_request *req =NULL ; -struct extent_crypt_result ecr; +DECLARE_CRYPTO_WAIT (ecr);int rc =0 ;if (unlikely (ecryptfs_verbosity >0 )) {@@ -303,8 +287,6 @@ static int crypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat, crypt_stat->key_size); } -init_completion (&ecr.completion); -mutex_lock (&crypt_stat->cs_tfm_mutex); req =skcipher_request_alloc (crypt_stat->tfm,GFP_NOFS );if (!req) {@@ -315,7 +297,7 @@ static int crypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,skcipher_request_set_callback (req,CRYPTO_TFM_REQ_MAY_BACKLOG |CRYPTO_TFM_REQ_MAY_SLEEP , - extent_crypt_complete, &ecr); + crypto_req_done, &ecr);/* Consider doing this once, when the file is opened */ if (!(crypt_stat->flags &ECRYPTFS_KEY_SET )) { rc = crypto_skcipher_setkey(crypt_stat->tfm, crypt_stat->key,@@ -334,13 +316,7 @@ static int crypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,skcipher_request_set_crypt (req, src_sg, dst_sg, size, iv); rc = op ==ENCRYPT ?crypto_skcipher_encrypt (req) :crypto_skcipher_decrypt (req); -if (rc == -EINPROGRESS || rc == -EBUSY ) {
fs/ecryptfs/crypto.c static int crypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat, · line 322
Quoted 10 lines
fs/ecryptfs/crypto.c +1
-6-struct extent_crypt_result *ecr = req->base.data; - -wait_for_completion (&ecr->completion); - rc = ecr->rc; -reinit_completion (&ecr->completion); - } + rc =crypto_wait_req (rc, &ecr); out:skcipher_request_free (req);return rc;
BR, Jarkko
Herbert Xu
maintainerPATCH 4/17 Bluetooth: Use crypto_wait_req
In reply to Herbert XuThis patch replaces the custom crypto completion function with crypto_req_done.
---
net/bluetooth/ecdh_helper.c | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-)
net/bluetooth/ecdh_helper.c +6 -31
@@ -25,22 +25,6 @@#include <linux/scatterlist.h> #include <crypto/ecdh.h> -struct ecdh_completion { -struct completion completion; -int err; -}; - -static void ecdh_complete (struct crypto_async_request *req,int err) -{ -struct ecdh_completion *res = req->data; - -if (err == -EINPROGRESS ) -return ; - - res->err = err; -complete (&res->completion); -} -static inline void swap_digits (u64 *in,u64 *out,unsigned int ndigits) {int i;
@@ -60,9 +44,9 @@ static inline void swap_digits(u64 *in, u64 *out, unsigned int ndigits)int compute_ecdh_secret (struct crypto_kpp *tfm,const u8 public_key[64 ],u8 secret[32 ]) { +DECLARE_CRYPTO_WAIT (result);struct kpp_request *req;u8 *tmp; -struct ecdh_completion result;struct scatterlist src, dst;int err;
@@ -76,8 +60,6 @@ int compute_ecdh_secret(struct crypto_kpp *tfm, const u8 public_key[64], goto free_tmp; } -init_completion (&result.completion); -swap_digits ((u64 *)public_key, (u64 *)tmp,4 );/* x */ swap_digits ((u64 *)&public_key[32 ], (u64 *)&tmp[32 ],4 );/* y */
@@ -86,12 +68,9 @@ int compute_ecdh_secret(struct crypto_kpp *tfm, const u8 public_key[64],kpp_request_set_input (req, &src,64 );kpp_request_set_output (req, &dst,32 );kpp_request_set_callback (req,CRYPTO_TFM_REQ_MAY_BACKLOG , - ecdh_complete, &result); + crypto_req_done, &result); err =crypto_kpp_compute_shared_secret (req); -if (err == -EINPROGRESS ) { -wait_for_completion (&result.completion); - err = result.err; - } + err =crypto_wait_req (err, &result);if (err <0 ) {pr_err ("alg: ecdh: compute shared secret failed. err %d\n" , err);
@@ -165,9 +144,9 @@ int set_ecdh_privkey(struct crypto_kpp *tfm, const u8 private_key[32])*/ int generate_ecdh_public_key (struct crypto_kpp *tfm,u8 public_key[64 ]) { +DECLARE_CRYPTO_WAIT (result);struct kpp_request *req;u8 *tmp; -struct ecdh_completion result;struct scatterlist dst;int err;
@@ -181,18 +160,14 @@ int generate_ecdh_public_key(struct crypto_kpp *tfm, u8 public_key[64]) goto free_tmp; } -init_completion (&result.completion);sg_init_one (&dst, tmp,64 );kpp_request_set_input (req,NULL ,0 );kpp_request_set_output (req, &dst,64 );kpp_request_set_callback (req,CRYPTO_TFM_REQ_MAY_BACKLOG , - ecdh_complete, &result); + crypto_req_done, &result); err =crypto_kpp_generate_public_key (req); -if (err == -EINPROGRESS ) { -wait_for_completion (&result.completion); - err = result.err; - } + err =crypto_wait_req (err, &result);if (err <0 ) goto free_all;
Herbert Xu
maintainerPATCH 5/17 net: ipv4: Add scaffolding to change completion function signature
In reply to Herbert XuThis patch adds temporary scaffolding so that the Crypto API completion function can take a void * instead of crypto_async_request. Once affected users have been converted this can be removed.
---
net/ipv4/ah4.c | 8 ++++---- net/ipv4/esp4.c | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-)
net/ipv4/ah4.c +4 -4
@@ -117,11 +117,11 @@ static int ip_clear_mutable_options(const struct iphdr *iph, __be32 *daddr)return 0 ; } -static void ah_output_done (struct crypto_async_request *base,int err) +static void ah_output_done (crypto_completion_data_t *data,int err) {u8 *icv;struct iphdr *iph; -struct sk_buff *skb = base->data; +struct sk_buff *skb =crypto_get_completion_data (data);struct xfrm_state *x =skb_dst (skb)->xfrm;struct ah_data *ahp = x->data;struct iphdr *top_iph =ip_hdr (skb);
@@ -262,12 +262,12 @@ static int ah_output(struct xfrm_state *x, struct sk_buff *skb)return err; } -static void ah_input_done (struct crypto_async_request *base,int err) +static void ah_input_done (crypto_completion_data_t *data,int err) {u8 *auth_data;u8 *icv;struct iphdr *work_iph; -struct sk_buff *skb = base->data; +struct sk_buff *skb =crypto_get_completion_data (data);struct xfrm_state *x =xfrm_input_state (skb);struct ah_data *ahp = x->data;struct ip_auth_hdr *ah =ip_auth_hdr (skb);
net/ipv4/esp4.c +10 -10
@@ -244,9 +244,9 @@ static int esp_output_tail_tcp(struct xfrm_state *x, struct sk_buff *skb) }#endif -static void esp_output_done (struct crypto_async_request *base,int err) +static void esp_output_done (crypto_completion_data_t *data,int err) { -struct sk_buff *skb = base->data; +struct sk_buff *skb =crypto_get_completion_data (data);struct xfrm_offload *xo =xfrm_offload (skb);void *tmp;struct xfrm_state *x;
@@ -332,12 +332,12 @@ static struct ip_esp_hdr *esp_output_set_extra(struct sk_buff *skb,return esph; } -static void esp_output_done_esn (struct crypto_async_request *base,int err) +static void esp_output_done_esn (crypto_completion_data_t *data,int err) { -struct sk_buff *skb = base->data; +struct sk_buff *skb =crypto_get_completion_data (data);esp_output_restore_header (skb); -esp_output_done (base, err); +esp_output_done (data, err); } static struct ip_esp_hdr *esp_output_udp_encap(struct sk_buff *skb,
@@ -830,9 +830,9 @@ int esp_input_done2(struct sk_buff *skb, int err) }EXPORT_SYMBOL_GPL (esp_input_done2); -static void esp_input_done (struct crypto_async_request *base,int err) +static void esp_input_done (crypto_completion_data_t *data,int err) { -struct sk_buff *skb = base->data; +struct sk_buff *skb =crypto_get_completion_data (data);xfrm_input_resume (skb,esp_input_done2 (skb, err)); }
@@ -860,12 +860,12 @@ static void esp_input_set_header(struct sk_buff *skb, __be32 *seqhi) } } -static void esp_input_done_esn (struct crypto_async_request *base,int err) +static void esp_input_done_esn (crypto_completion_data_t *data,int err) { -struct sk_buff *skb = base->data; +struct sk_buff *skb =crypto_get_completion_data (data);esp_input_restore_header (skb); -esp_input_done (base, err); +esp_input_done (data, err); }/*
Herbert Xu
maintainerPATCH 6/17 net: ipv6: Add scaffolding to change completion function signature
In reply to Herbert XuThis patch adds temporary scaffolding so that the Crypto API completion function can take a void * instead of crypto_async_request. Once affected users have been converted this can be removed.
---
net/ipv6/ah6.c | 8 ++++---- net/ipv6/esp6.c | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-)
net/ipv6/ah6.c +4 -4
@@ -281,12 +281,12 @@ static int ipv6_clear_mutable_options(struct ipv6hdr *iph, int len, int dir)return 0 ; } -static void ah6_output_done (struct crypto_async_request *base,int err) +static void ah6_output_done (crypto_completion_data_t *data,int err) {int extlen;u8 *iph_base;u8 *icv; -struct sk_buff *skb = base->data; +struct sk_buff *skb =crypto_get_completion_data (data);struct xfrm_state *x =skb_dst (skb)->xfrm;struct ah_data *ahp = x->data;struct ipv6hdr *top_iph =ipv6_hdr (skb);
@@ -451,12 +451,12 @@ static int ah6_output(struct xfrm_state *x, struct sk_buff *skb)return err; } -static void ah6_input_done (struct crypto_async_request *base,int err) +static void ah6_input_done (crypto_completion_data_t *data,int err) {u8 *auth_data;u8 *icv;u8 *work_iph; -struct sk_buff *skb = base->data; +struct sk_buff *skb =crypto_get_completion_data (data);struct xfrm_state *x =xfrm_input_state (skb);struct ah_data *ahp = x->data;struct ip_auth_hdr *ah =ip_auth_hdr (skb);
net/ipv6/esp6.c +10 -10
@@ -278,9 +278,9 @@ static void esp_output_encap_csum(struct sk_buff *skb) } } -static void esp_output_done (struct crypto_async_request *base,int err) +static void esp_output_done (crypto_completion_data_t *data,int err) { -struct sk_buff *skb = base->data; +struct sk_buff *skb =crypto_get_completion_data (data);struct xfrm_offload *xo =xfrm_offload (skb);void *tmp;struct xfrm_state *x;
@@ -368,12 +368,12 @@ static struct ip_esp_hdr *esp_output_set_esn(struct sk_buff *skb,return esph; } -static void esp_output_done_esn (struct crypto_async_request *base,int err) +static void esp_output_done_esn (crypto_completion_data_t *data,int err) { -struct sk_buff *skb = base->data; +struct sk_buff *skb =crypto_get_completion_data (data);esp_output_restore_header (skb); -esp_output_done (base, err); +esp_output_done (data, err); } static struct ip_esp_hdr *esp6_output_udp_encap(struct sk_buff *skb,
@@ -879,9 +879,9 @@ int esp6_input_done2(struct sk_buff *skb, int err) }EXPORT_SYMBOL_GPL (esp6_input_done2); -static void esp_input_done (struct crypto_async_request *base,int err) +static void esp_input_done (crypto_completion_data_t *data,int err) { -struct sk_buff *skb = base->data; +struct sk_buff *skb =crypto_get_completion_data (data);xfrm_input_resume (skb,esp6_input_done2 (skb, err)); }
@@ -909,12 +909,12 @@ static void esp_input_set_header(struct sk_buff *skb, __be32 *seqhi) } } -static void esp_input_done_esn (struct crypto_async_request *base,int err) +static void esp_input_done_esn (crypto_completion_data_t *data,int err) { -struct sk_buff *skb = base->data; +struct sk_buff *skb =crypto_get_completion_data (data);esp_input_restore_header (skb); -esp_input_done (base, err); +esp_input_done (data, err); }static int esp6_input (struct xfrm_state *x,struct sk_buff *skb)
Herbert Xu
maintainerPATCH 7/17 tipc: Add scaffolding to change completion function signature
In reply to Herbert XuThis patch adds temporary scaffolding so that the Crypto API completion function can take a void * instead of crypto_async_request. Once affected users have been converted this can be removed.
---
net/tipc/crypto.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
net/tipc/crypto.c +6 -6
@@ -267,10 +267,10 @@ static int tipc_aead_encrypt(struct tipc_aead *aead, struct sk_buff *skb,struct tipc_bearer *b, struct tipc_media_addr *dst, struct tipc_node *__dnode); -static void tipc_aead_encrypt_done (struct crypto_async_request *base,int err); +static void tipc_aead_encrypt_done (crypto_completion_data_t *data,int err);static int tipc_aead_decrypt (struct net *net,struct tipc_aead *aead,struct sk_buff *skb,struct tipc_bearer *b); -static void tipc_aead_decrypt_done (struct crypto_async_request *base,int err); +static void tipc_aead_decrypt_done (crypto_completion_data_t *data,int err);static inline int tipc_ehdr_size (struct tipc_ehdr *ehdr); static int tipc_ehdr_build(struct net *net, struct tipc_aead *aead, u8 tx_key, struct sk_buff *skb,
@@ -830,9 +830,9 @@ static int tipc_aead_encrypt(struct tipc_aead *aead, struct sk_buff *skb,return rc; } -static void tipc_aead_encrypt_done (struct crypto_async_request *base,int err) +static void tipc_aead_encrypt_done (crypto_completion_data_t *data,int err) { -struct sk_buff *skb = base->data; +struct sk_buff *skb =crypto_get_completion_data (data);struct tipc_crypto_tx_ctx *tx_ctx =TIPC_SKB_CB (skb)->crypto_ctx;struct tipc_bearer *b = tx_ctx->bearer;struct tipc_aead *aead = tx_ctx->aead;
@@ -954,9 +954,9 @@ static int tipc_aead_decrypt(struct net *net, struct tipc_aead *aead,return rc; } -static void tipc_aead_decrypt_done (struct crypto_async_request *base,int err) +static void tipc_aead_decrypt_done (crypto_completion_data_t *data,int err) { -struct sk_buff *skb = base->data; +struct sk_buff *skb =crypto_get_completion_data (data);struct tipc_crypto_rx_ctx *rx_ctx =TIPC_SKB_CB (skb)->crypto_ctx;struct tipc_bearer *b = rx_ctx->bearer;struct tipc_aead *aead = rx_ctx->aead;
Herbert Xu
maintainerPATCH 8/17 tls: Only use data field in crypto completion function
In reply to Herbert XuThe crypto_async_request passed to the completion is not guaranteed to be the original request object. Only the data field can be relied upon.
Fix this by storing the socket pointer with the AEAD request.
---
net/tls/tls.h | 2 ++ net/tls/tls_sw.c | 40 +++++++++++++++++++++++++++++----------- 2 files changed, 31 insertions(+), 11 deletions(-)
net/tls/tls.h +2 -0
@@ -70,6 +70,8 @@ struct tls_rec {char content_type;struct scatterlist sg_content_type; +struct sock *sk; +char aad_space[TLS_AAD_SPACE_SIZE ];u8 iv_data[MAX_IV_SIZE ];struct aead_request aead_req;
net/tls/tls_sw.c +29 -11
@@ -38,6 +38,7 @@#include <linux/bug.h> #include <linux/sched/signal.h> #include <linux/module.h> +#include <linux/kernel.h> #include <linux/splice.h> #include <crypto/aead.h>
@@ -57,6 +58,7 @@ struct tls_decrypt_arg { };struct tls_decrypt_ctx { +struct sock *sk;u8 iv[MAX_IV_SIZE ];u8 aad[TLS_MAX_AAD_SIZE ];u8 tail;
@@ -177,18 +179,25 @@ static int tls_padding_length(struct tls_prot_info *prot, struct sk_buff *skb,return sub; } -static void tls_decrypt_done (struct crypto_async_request *req,int err) +static void tls_decrypt_done (crypto_completion_data_t *data,int err) { -struct aead_request *aead_req = (struct aead_request *)req; +struct aead_request *aead_req =crypto_get_completion_data (data); +struct crypto_aead *aead =crypto_aead_reqtfm (aead_req);struct scatterlist *sgout = aead_req->dst;struct scatterlist *sgin = aead_req->src;struct tls_sw_context_rx *ctx; +struct tls_decrypt_ctx *dctx;struct tls_context *tls_ctx;struct scatterlist *sg;unsigned int pages;struct sock *sk; +int aead_size; - sk = (struct sock *)req->data; + aead_size =sizeof (*aead_req) +crypto_aead_reqsize (aead); + aead_size = ALIGN(aead_size, __alignof__(*dctx)); + dctx = (void *)((u8 *)aead_req + aead_size); + + sk = dctx->sk; tls_ctx =tls_get_ctx (sk); ctx =tls_sw_ctx_rx (tls_ctx);
@@ -240,7 +249,7 @@ static int tls_do_decryption(struct sock *sk,if (darg->async) {aead_request_set_callback (aead_req,CRYPTO_TFM_REQ_MAY_BACKLOG , - tls_decrypt_done, sk); + tls_decrypt_done, aead_req);atomic_inc (&ctx->decrypt_pending); }else { aead_request_set_callback(aead_req,
@@ -336,6 +345,8 @@ static struct tls_rec *tls_get_rec(struct sock *sk)sg_set_buf (&rec->sg_aead_out[0 ], rec->aad_space, prot->aad_size);sg_unmark_end (&rec->sg_aead_out[1 ]); + rec->sk = sk; +return rec; }
@@ -417,22 +428,27 @@ int tls_tx_records(struct sock *sk, int flags)return rc; } -static void tls_encrypt_done (struct crypto_async_request *req,int err) +static void tls_encrypt_done (crypto_completion_data_t *data,int err) { -struct aead_request *aead_req = (struct aead_request *)req; -struct sock *sk = req->data; -struct tls_context *tls_ctx =tls_get_ctx (sk); -struct tls_prot_info *prot = &tls_ctx->prot_info; -struct tls_sw_context_tx *ctx =tls_sw_ctx_tx (tls_ctx); +struct aead_request *aead_req =crypto_get_completion_data (data); +struct tls_sw_context_tx *ctx; +struct tls_context *tls_ctx; +struct tls_prot_info *prot;struct scatterlist *sge;struct sk_msg *msg_en;struct tls_rec *rec;bool ready = false; +struct sock *sk;int pending; rec = container_of(aead_req, struct tls_rec, aead_req); msg_en = &rec->msg_encrypted; + sk = rec->sk; + tls_ctx =tls_get_ctx (sk); + prot = &tls_ctx->prot_info; + ctx =tls_sw_ctx_tx (tls_ctx); + sge =sk_msg_elem (msg_en, msg_en->sg.curr); sge->offset -= prot->prepend_size; sge->length += prot->prepend_size;
@@ -520,7 +536,7 @@ static int tls_do_encryption(struct sock *sk, data_len, rec->iv_data);aead_request_set_callback (aead_req,CRYPTO_TFM_REQ_MAY_BACKLOG , - tls_encrypt_done, sk); + tls_encrypt_done, aead_req);/* Add the record in tx_list */ list_add_tail ((struct list_head *)&rec->list, &ctx->tx_list);
@@ -1485,6 +1501,7 @@ static int tls_decrypt_sg(struct sock *sk, struct iov_iter *out_iov,* Both structs are variable length. */ aead_size =sizeof (*aead_req) +crypto_aead_reqsize (ctx->aead_recv); + aead_size = ALIGN(aead_size, __alignof__(*dctx)); mem =kmalloc (aead_size +struct_size (dctx, sg, n_sgin + n_sgout), sk->sk_allocation);if (!mem) {
@@ -1495,6 +1512,7 @@ static int tls_decrypt_sg(struct sock *sk, struct iov_iter *out_iov,/* Segment the allocated memory */ aead_req = (struct aead_request *)mem; dctx = (struct tls_decrypt_ctx *)(mem + aead_size); + dctx->sk = sk; sgin = &dctx->sg[0 ]; sgout = &dctx->sg[n_sgin];
Jakub Kicinski
maintainerRe: [PATCH 8/17] tls: Only use data field in crypto completion function
net/tls/tls_sw.c int tls_tx_records(struct sock *sk, int flags) · line 433
Quoted 9 lines · On Mon, 06 Feb 2023 18:22:27 +0800 Herbert Xu wrote:
net/tls/tls_sw.c +2
-6-static void tls_encrypt_done (struct crypto_async_request *req,int err) +static void tls_encrypt_done (crypto_completion_data_t *data,int err) { -struct aead_request *aead_req = (struct aead_request *)req; -struct sock *sk = req->data; -struct tls_context *tls_ctx =tls_get_ctx (sk); -struct tls_prot_info *prot = &tls_ctx->prot_info; -struct tls_sw_context_tx *ctx =tls_sw_ctx_tx (tls_ctx); +struct aead_request *aead_req =crypto_get_completion_data (data);
All we use aead_req for in this function now is to find rec...
Quoted 22 lines
net/tls/tls_sw.c +9
-0+struct tls_sw_context_tx *ctx; +struct tls_context *tls_ctx; +struct tls_prot_info *prot;struct scatterlist *sge;struct sk_msg *msg_en;struct tls_rec *rec;bool ready = false; +struct sock *sk;int pending; rec = container_of(aead_req, struct tls_rec, aead_req); msg_en = &rec->msg_encrypted; + sk = rec->sk; + tls_ctx =tls_get_ctx (sk); + prot = &tls_ctx->prot_info; + ctx =tls_sw_ctx_tx (tls_ctx); + sge =sk_msg_elem (msg_en, msg_en->sg.curr); sge->offset -= prot->prepend_size; sge->length += prot->prepend_size;
net/tls/tls_sw.c static int tls_do_encryption(struct sock *sk, · line 539
Quoted 5 lines
net/tls/tls_sw.c +1
-1@@ -520,7 +536,7 @@ static int tls_do_encryption(struct sock *sk, data_len, rec->iv_data);aead_request_set_callback (aead_req,CRYPTO_TFM_REQ_MAY_BACKLOG , - tls_encrypt_done, sk); + tls_encrypt_done, aead_req);
... let's just pass rec instead of aead_req here, then?
Quoted 2 lines
net/tls/tls_sw.c +0
-0/* Add the record in tx_list */ list_add_tail ((struct list_head *)&rec->list, &ctx->tx_list);
Herbert Xu
maintainerPATCH 1/1 tls: Pass rec instead of aead_req into tls_encrypt_done
Quoted 6 lines · Jakub Kicinski
Review
Quoted 4 lines
(quoted diff) +1
-1aead_request_set_callback(aead_req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tls_encrypt_done, sk); + tls_encrypt_done, aead_req);... let's just pass rec instead of
aead_reqhere, then?
Good point. Could we do this as a follow-up patch? Reposting the whole series would disturb a lot of people. Of course if other major issues crop up I can fold this into the existing patch.
Thanks!
---8<---
The function tls_encrypt_done only uses aead_req to get ahold of the tls_rec object. So we could pass that in instead of aead_req to simplify the code.
net/tls/tls_sw.c +2 -4
@@ -430,18 +430,16 @@ int tls_tx_records(struct sock *sk, int flags)static void tls_encrypt_done (void *data,int err) { -struct aead_request *aead_req = data;struct tls_sw_context_tx *ctx;struct tls_context *tls_ctx;struct tls_prot_info *prot; +struct tls_rec *rec = data;struct scatterlist *sge;struct sk_msg *msg_en; -struct tls_rec *rec;bool ready = false;struct sock *sk;int pending; - rec = container_of(aead_req, struct tls_rec, aead_req); msg_en = &rec->msg_encrypted; sk = rec->sk;
@@ -536,7 +534,7 @@ static int tls_do_encryption(struct sock *sk, data_len, rec->iv_data);aead_request_set_callback (aead_req,CRYPTO_TFM_REQ_MAY_BACKLOG , - tls_encrypt_done, aead_req); + tls_encrypt_done, rec);/* Add the record in tx_list */ list_add_tail ((struct list_head *)&rec->list, &ctx->tx_list);
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
RE: tls: Pass rec instead of aead_req into tls_encrypt_done
This is an automated email and please do not reply to this email.
Dear Submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.
----- Output -----
error: patch failed: net/tls/tls_sw.c:430
error: net/tls/tls_sw.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch
Please resolve the issue and submit the patches again.
---
Regards,
Linux Bluetooth
Re: [PATCH] tls: Pass rec instead of aead_req into tls_encrypt_done
In reply to Herbert XuQuoted 10 lines · On Tue, 7 Feb 2023 16:18:36 +0800 Herbert Xu wrote:
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +1
-1aead_request_set_callback(aead_req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tls_encrypt_done, sk); + tls_encrypt_done, aead_req);... let's just pass rec instead of
aead_reqhere, then?Good point. Could we do this as a follow-up patch? Reposting the whole series would disturb a lot of people. Of course if other major issues crop up I can fold this into the existing patch.
Whatever works best!
Herbert Xu
maintainerPATCH 9/17 KEYS: DH: Use crypto_wait_req
In reply to Herbert XuThis patch replaces the custom crypto completion function with crypto_req_done.
---
security/keys/dh.c | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-)
security/keys/dh.c +5 -25
@@ -64,22 +64,6 @@ static void dh_free_data(struct dh *dh)kfree_sensitive (dh->g); } -struct dh_completion { -struct completion completion; -int err; -}; - -static void dh_crypto_done (struct crypto_async_request *req,int err) -{ -struct dh_completion *compl = req->data; - -if (err == -EINPROGRESS ) -return ; - - compl->err = err; -complete (&compl->completion); -} -static int kdf_alloc (struct crypto_shash **hash,char *hashname) {struct crypto_shash *tfm;
@@ -146,7 +130,7 @@ long __keyctl_dh_compute(struct keyctl_dh_params __user *params,struct keyctl_dh_params pcopy;struct dh dh_inputs;struct scatterlist outsg; -struct dh_completion compl; +DECLARE_CRYPTO_WAIT (compl);struct crypto_kpp *tfm;struct kpp_request *req;uint8_t *secret;
@@ -266,22 +250,18 @@ long __keyctl_dh_compute(struct keyctl_dh_params __user *params,kpp_request_set_input (req,NULL ,0 );kpp_request_set_output (req, &outsg, outlen); -init_completion (&compl.completion);kpp_request_set_callback (req,CRYPTO_TFM_REQ_MAY_BACKLOG |CRYPTO_TFM_REQ_MAY_SLEEP , - dh_crypto_done, &compl); + crypto_req_done, &compl);/* * For DH, generate_public_key and generate_shared_secret are * the same calculation */ ret =crypto_kpp_generate_public_key (req); -if (ret == -EINPROGRESS ) { -wait_for_completion (&compl.completion); - ret = compl.err; -if (ret) - goto out6; - } + ret =crypto_wait_req (ret, &compl); +if (ret) + goto out6;if (kdfcopy) {/*
Herbert Xu
maintainerPATCH 10/17 crypto: api - Use data directly in completion function
In reply to Herbert XuThis patch does the final flag day conversion of all completion functions which are now all contained in the Crypto API.
---
crypto/adiantum.c | 5 +--- crypto/af_alg.c | 6 ++--- crypto/ahash.c | 12 +++++----- crypto/api.c | 4 +-- crypto/authenc.c | 14 +++++------- crypto/authencesn.c | 15 +++++------- crypto/ccm.c | 9 +++---- crypto/chacha20poly1305.c | 40 +++++++++++++++++----------------- crypto/cryptd.c | 52 ++++++++++++++++++++++----------------------- crypto/cts.c | 12 +++++----- crypto/dh.c | 5 +--- crypto/essiv.c | 8 +++--- crypto/gcm.c | 36 ++++++++++++++----------------- crypto/hctr2.c | 5 +--- crypto/lrw.c | 4 +-- crypto/pcrypt.c | 4 +-- crypto/rsa-pkcs1pad.c | 15 +++++------- crypto/seqiv.c | 5 +--- crypto/xts.c | 12 +++++----- drivers/crypto/atmel-sha.c | 5 +--- include/crypto/if_alg.h | 4 --- include/linux/crypto.h | 10 ++++---- 22 files changed, 132 insertions(+), 150 deletions(-)
crypto/adiantum.c +2 -3
@@ -308,10 +308,9 @@ static int adiantum_finish(struct skcipher_request *req)return 0 ; } -static void adiantum_streamcipher_done (struct crypto_async_request *areq, -int err) +static void adiantum_streamcipher_done (void *data,int err) { -struct skcipher_request *req = areq->data; +struct skcipher_request *req = data;if (!err) err =adiantum_finish (req);
crypto/af_alg.c +3 -3
@@ -1186,7 +1186,7 @@ EXPORT_SYMBOL_GPL(af_alg_free_resources);/** * af_alg_async_cb - AIO callback handler -* @_req: async request info +* @data: async request completion data * @err: if non-zero, error result to be returned via ki_complete(); * otherwise return the AIO output length via ki_complete(). *
@@ -1196,9 +1196,9 @@ EXPORT_SYMBOL_GPL(af_alg_free_resources);* The number of bytes to be generated with the AIO operation must be set * in areq->outlen before the AIO callback handler is invoked. */ -void af_alg_async_cb (struct crypto_async_request *_req,int err) +void af_alg_async_cb (void *data,int err) { -struct af_alg_async_req *areq = _req->data; +struct af_alg_async_req *areq = data;struct sock *sk = areq->sk;struct kiocb *iocb = areq->iocb;unsigned int resultlen;
crypto/ahash.c +6 -6
@@ -240,9 +240,9 @@ static void ahash_restore_req(struct ahash_request *req, int err)kfree_sensitive (subreq); } -static void ahash_op_unaligned_done (struct crypto_async_request *req,int err) +static void ahash_op_unaligned_done (void *data,int err) { -struct ahash_request *areq = req->data; +struct ahash_request *areq = data;if (err == -EINPROGRESS ) goto out;
@@ -330,9 +330,9 @@ int crypto_ahash_digest(struct ahash_request *req) }EXPORT_SYMBOL_GPL (crypto_ahash_digest); -static void ahash_def_finup_done2 (struct crypto_async_request *req,int err) +static void ahash_def_finup_done2 (void *data,int err) { -struct ahash_request *areq = req->data; +struct ahash_request *areq = data;if (err == -EINPROGRESS )return ;
@@ -360,9 +360,9 @@ static int ahash_def_finup_finish1(struct ahash_request *req, int err)return err; } -static void ahash_def_finup_done1 (struct crypto_async_request *req,int err) +static void ahash_def_finup_done1 (void *data,int err) { -struct ahash_request *areq = req->data; +struct ahash_request *areq = data;struct ahash_request *subreq;if (err == -EINPROGRESS )
crypto/api.c +2 -2
@@ -643,9 +643,9 @@ int crypto_has_alg(const char *name, u32 type, u32 mask) }EXPORT_SYMBOL_GPL (crypto_has_alg); -void crypto_req_done (struct crypto_async_request *req,int err) +void crypto_req_done (void *data,int err) { -struct crypto_wait *wait = req->data; +struct crypto_wait *wait = data;if (err == -EINPROGRESS )return ;
crypto/authenc.c +6 -8
@@ -109,9 +109,9 @@ static int crypto_authenc_setkey(struct crypto_aead *authenc, const u8 *key,return err; } -static void authenc_geniv_ahash_done (struct crypto_async_request *areq,int err) +static void authenc_geniv_ahash_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;struct crypto_aead *authenc =crypto_aead_reqtfm (req);struct aead_instance *inst =aead_alg_instance (authenc);struct authenc_instance_ctx *ictx =aead_instance_ctx (inst);
@@ -160,10 +160,9 @@ static int crypto_authenc_genicv(struct aead_request *req, unsigned int flags)return 0 ; } -static void crypto_authenc_encrypt_done (struct crypto_async_request *req, -int err) +static void crypto_authenc_encrypt_done (void *data,int err) { -struct aead_request *areq = req->data; +struct aead_request *areq = data;if (err) goto out;
@@ -261,10 +260,9 @@ static int crypto_authenc_decrypt_tail(struct aead_request *req,return crypto_skcipher_decrypt (skreq); } -static void authenc_verify_ahash_done (struct crypto_async_request *areq, -int err) +static void authenc_verify_ahash_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;if (err) goto out;
crypto/authencesn.c +6 -9
@@ -107,10 +107,9 @@ static int crypto_authenc_esn_genicv_tail(struct aead_request *req,return 0 ; } -static void authenc_esn_geniv_ahash_done (struct crypto_async_request *areq, -int err) +static void authenc_esn_geniv_ahash_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data; err = err ?:crypto_authenc_esn_genicv_tail (req,0 );aead_request_complete (req, err);
@@ -153,10 +152,9 @@ static int crypto_authenc_esn_genicv(struct aead_request *req, } -static void crypto_authenc_esn_encrypt_done (struct crypto_async_request *req, -int err) +static void crypto_authenc_esn_encrypt_done (void *data,int err) { -struct aead_request *areq = req->data; +struct aead_request *areq = data;if (!err) err =crypto_authenc_esn_genicv (areq,0 );
@@ -258,10 +256,9 @@ static int crypto_authenc_esn_decrypt_tail(struct aead_request *req,return crypto_skcipher_decrypt (skreq); } -static void authenc_esn_verify_ahash_done (struct crypto_async_request *areq, -int err) +static void authenc_esn_verify_ahash_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data; err = err ?:crypto_authenc_esn_decrypt_tail (req,0 );authenc_esn_request_complete (req, err);
crypto/ccm.c +4 -5
@@ -224,9 +224,9 @@ static int crypto_ccm_auth(struct aead_request *req, struct scatterlist *plain,return err; } -static void crypto_ccm_encrypt_done (struct crypto_async_request *areq,int err) +static void crypto_ccm_encrypt_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;struct crypto_aead *aead =crypto_aead_reqtfm (req);struct crypto_ccm_req_priv_ctx *pctx =crypto_ccm_reqctx (req);u8 *odata = pctx->odata;
@@ -320,10 +320,9 @@ static int crypto_ccm_encrypt(struct aead_request *req)return err; } -static void crypto_ccm_decrypt_done (struct crypto_async_request *areq, -int err) +static void crypto_ccm_decrypt_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;struct crypto_ccm_req_priv_ctx *pctx =crypto_ccm_reqctx (req);struct crypto_aead *aead =crypto_aead_reqtfm (req);unsigned int authsize =crypto_aead_authsize (aead);
crypto/chacha20poly1305.c +20 -20
@@ -115,9 +115,9 @@ static int poly_copy_tag(struct aead_request *req)return 0 ; } -static void chacha_decrypt_done (struct crypto_async_request *areq,int err) +static void chacha_decrypt_done (void *data,int err) { -async_done_continue (areq->data, err, poly_verify_tag); +async_done_continue (data, err, poly_verify_tag); }static int chacha_decrypt (struct aead_request *req)
@@ -161,9 +161,9 @@ static int poly_tail_continue(struct aead_request *req)return chacha_decrypt (req); } -static void poly_tail_done (struct crypto_async_request *areq,int err) +static void poly_tail_done (void *data,int err) { -async_done_continue (areq->data, err, poly_tail_continue); +async_done_continue (data, err, poly_tail_continue); }static int poly_tail (struct aead_request *req)
@@ -191,9 +191,9 @@ static int poly_tail(struct aead_request *req)return poly_tail_continue (req); } -static void poly_cipherpad_done (struct crypto_async_request *areq,int err) +static void poly_cipherpad_done (void *data,int err) { -async_done_continue (areq->data, err, poly_tail); +async_done_continue (data, err, poly_tail); }static int poly_cipherpad (struct aead_request *req)
@@ -220,9 +220,9 @@ static int poly_cipherpad(struct aead_request *req)return poly_tail (req); } -static void poly_cipher_done (struct crypto_async_request *areq,int err) +static void poly_cipher_done (void *data,int err) { -async_done_continue (areq->data, err, poly_cipherpad); +async_done_continue (data, err, poly_cipherpad); }static int poly_cipher (struct aead_request *req)
@@ -250,9 +250,9 @@ static int poly_cipher(struct aead_request *req)return poly_cipherpad (req); } -static void poly_adpad_done (struct crypto_async_request *areq,int err) +static void poly_adpad_done (void *data,int err) { -async_done_continue (areq->data, err, poly_cipher); +async_done_continue (data, err, poly_cipher); }static int poly_adpad (struct aead_request *req)
@@ -279,9 +279,9 @@ static int poly_adpad(struct aead_request *req)return poly_cipher (req); } -static void poly_ad_done (struct crypto_async_request *areq,int err) +static void poly_ad_done (void *data,int err) { -async_done_continue (areq->data, err, poly_adpad); +async_done_continue (data, err, poly_adpad); }static int poly_ad (struct aead_request *req)
@@ -303,9 +303,9 @@ static int poly_ad(struct aead_request *req)return poly_adpad (req); } -static void poly_setkey_done (struct crypto_async_request *areq,int err) +static void poly_setkey_done (void *data,int err) { -async_done_continue (areq->data, err, poly_ad); +async_done_continue (data, err, poly_ad); }static int poly_setkey (struct aead_request *req)
@@ -329,9 +329,9 @@ static int poly_setkey(struct aead_request *req)return poly_ad (req); } -static void poly_init_done (struct crypto_async_request *areq,int err) +static void poly_init_done (void *data,int err) { -async_done_continue (areq->data, err, poly_setkey); +async_done_continue (data, err, poly_setkey); }static int poly_init (struct aead_request *req)
@@ -352,9 +352,9 @@ static int poly_init(struct aead_request *req)return poly_setkey (req); } -static void poly_genkey_done (struct crypto_async_request *areq,int err) +static void poly_genkey_done (void *data,int err) { -async_done_continue (areq->data, err, poly_init); +async_done_continue (data, err, poly_init); }static int poly_genkey (struct aead_request *req)
@@ -391,9 +391,9 @@ static int poly_genkey(struct aead_request *req)return poly_init (req); } -static void chacha_encrypt_done (struct crypto_async_request *areq,int err) +static void chacha_encrypt_done (void *data,int err) { -async_done_continue (areq->data, err, poly_genkey); +async_done_continue (data, err, poly_genkey); }static int chacha_encrypt (struct aead_request *req)
crypto/cryptd.c +26 -26
115 lines not on this page · raw message
crypto/cts.c +6 -6
@@ -85,9 +85,9 @@ static int crypto_cts_setkey(struct crypto_skcipher *parent, const u8 *key,return crypto_skcipher_setkey (child, key, keylen); } -static void cts_cbc_crypt_done (struct crypto_async_request *areq,int err) +static void cts_cbc_crypt_done (void *data,int err) { -struct skcipher_request *req = areq->data; +struct skcipher_request *req = data;if (err == -EINPROGRESS )return ;
@@ -125,9 +125,9 @@ static int cts_cbc_encrypt(struct skcipher_request *req)return crypto_skcipher_encrypt (subreq); } -static void crypto_cts_encrypt_done (struct crypto_async_request *areq,int err) +static void crypto_cts_encrypt_done (void *data,int err) { -struct skcipher_request *req = areq->data; +struct skcipher_request *req = data;if (err) goto out;
@@ -219,9 +219,9 @@ static int cts_cbc_decrypt(struct skcipher_request *req)return crypto_skcipher_decrypt (subreq); } -static void crypto_cts_decrypt_done (struct crypto_async_request *areq,int err) +static void crypto_cts_decrypt_done (void *data,int err) { -struct skcipher_request *req = areq->data; +struct skcipher_request *req = data;if (err) goto out;
crypto/dh.c +2 -3
@@ -503,10 +503,9 @@ static int dh_safe_prime_set_secret(struct crypto_kpp *tfm, const void *buffer,return err; } -static void dh_safe_prime_complete_req (struct crypto_async_request *dh_req, -int err) +static void dh_safe_prime_complete_req (void *data,int err) { -struct kpp_request *req = dh_req->data; +struct kpp_request *req = data;kpp_request_complete (req, err); }
crypto/essiv.c +4 -4
@@ -131,9 +131,9 @@ static int essiv_aead_setauthsize(struct crypto_aead *tfm,return crypto_aead_setauthsize (tctx->u.aead, authsize); } -static void essiv_skcipher_done (struct crypto_async_request *areq,int err) +static void essiv_skcipher_done (void *data,int err) { -struct skcipher_request *req = areq->data; +struct skcipher_request *req = data;skcipher_request_complete (req, err); }
@@ -166,9 +166,9 @@ static int essiv_skcipher_decrypt(struct skcipher_request *req)return essiv_skcipher_crypt (req, false); } -static void essiv_aead_done (struct crypto_async_request *areq,int err) +static void essiv_aead_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;struct essiv_aead_request_ctx *rctx =aead_request_ctx (req);if (err == -EINPROGRESS )
crypto/gcm.c +17 -19
@@ -197,7 +197,7 @@ static inline unsigned int gcm_remain(unsigned int len)return len ?16 - len :0 ; } -static void gcm_hash_len_done (struct crypto_async_request *areq,int err); +static void gcm_hash_len_done (void *data,int err); static int gcm_hash_update(struct aead_request *req, crypto_completion_t compl,
@@ -246,9 +246,9 @@ static int gcm_hash_len_continue(struct aead_request *req, u32 flags)return gctx->complete (req, flags); } -static void gcm_hash_len_done (struct crypto_async_request *areq,int err) +static void gcm_hash_len_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;if (err) goto out;
@@ -267,10 +267,9 @@ static int gcm_hash_crypt_remain_continue(struct aead_request *req, u32 flags)gcm_hash_len_continue (req, flags); } -static void gcm_hash_crypt_remain_done (struct crypto_async_request *areq, -int err) +static void gcm_hash_crypt_remain_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;if (err) goto out;
@@ -298,9 +297,9 @@ static int gcm_hash_crypt_continue(struct aead_request *req, u32 flags)return gcm_hash_crypt_remain_continue (req, flags); } -static void gcm_hash_crypt_done (struct crypto_async_request *areq,int err) +static void gcm_hash_crypt_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;if (err) goto out;
@@ -326,10 +325,9 @@ static int gcm_hash_assoc_remain_continue(struct aead_request *req, u32 flags)return gcm_hash_crypt_remain_continue (req, flags); } -static void gcm_hash_assoc_remain_done (struct crypto_async_request *areq, -int err) +static void gcm_hash_assoc_remain_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;if (err) goto out;
@@ -355,9 +353,9 @@ static int gcm_hash_assoc_continue(struct aead_request *req, u32 flags)return gcm_hash_assoc_remain_continue (req, flags); } -static void gcm_hash_assoc_done (struct crypto_async_request *areq,int err) +static void gcm_hash_assoc_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;if (err) goto out;
@@ -380,9 +378,9 @@ static int gcm_hash_init_continue(struct aead_request *req, u32 flags)return gcm_hash_assoc_remain_continue (req, flags); } -static void gcm_hash_init_done (struct crypto_async_request *areq,int err) +static void gcm_hash_init_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;if (err) goto out;
@@ -433,9 +431,9 @@ static int gcm_encrypt_continue(struct aead_request *req, u32 flags)return gcm_hash (req, flags); } -static void gcm_encrypt_done (struct crypto_async_request *areq,int err) +static void gcm_encrypt_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;if (err) goto out;
@@ -477,9 +475,9 @@ static int crypto_gcm_verify(struct aead_request *req)return crypto_memneq (iauth_tag, auth_tag, authsize) ? -EBADMSG :0 ; } -static void gcm_decrypt_done (struct crypto_async_request *areq,int err) +static void gcm_decrypt_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;if (!err) err =crypto_gcm_verify (req);
crypto/hctr2.c +2 -3
@@ -252,10 +252,9 @@ static int hctr2_finish(struct skcipher_request *req)return 0 ; } -static void hctr2_xctr_done (struct crypto_async_request *areq, -int err) +static void hctr2_xctr_done (void *data,int err) { -struct skcipher_request *req = areq->data; +struct skcipher_request *req = data;if (!err) err =hctr2_finish (req);
crypto/lrw.c +2 -2
@@ -205,9 +205,9 @@ static int lrw_xor_tweak_post(struct skcipher_request *req)return lrw_xor_tweak (req, true); } -static void lrw_crypt_done (struct crypto_async_request *areq,int err) +static void lrw_crypt_done (void *data,int err) { -struct skcipher_request *req = areq->data; +struct skcipher_request *req = data;if (!err) {struct lrw_request_ctx *rctx =skcipher_request_ctx (req);
crypto/pcrypt.c +2 -2
@@ -63,9 +63,9 @@ static void pcrypt_aead_serial(struct padata_priv *padata)aead_request_complete (req->base.data, padata->info); } -static void pcrypt_aead_done (struct crypto_async_request *areq,int err) +static void pcrypt_aead_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;struct pcrypt_request *preq =aead_request_ctx (req);struct padata_priv *padata =pcrypt_request_padata (preq);
crypto/rsa-pkcs1pad.c +6 -9
@@ -210,10 +210,9 @@ static int pkcs1pad_encrypt_sign_complete(struct akcipher_request *req, int err)return err; } -static void pkcs1pad_encrypt_sign_complete_cb ( -struct crypto_async_request *child_async_req,int err) +static void pkcs1pad_encrypt_sign_complete_cb (void *data,int err) { -struct akcipher_request *req = child_async_req->data; +struct akcipher_request *req = data;if (err == -EINPROGRESS ) goto out;
@@ -326,10 +325,9 @@ static int pkcs1pad_decrypt_complete(struct akcipher_request *req, int err)return err; } -static void pkcs1pad_decrypt_complete_cb ( -struct crypto_async_request *child_async_req,int err) +static void pkcs1pad_decrypt_complete_cb (void *data,int err) { -struct akcipher_request *req = child_async_req->data; +struct akcipher_request *req = data;if (err == -EINPROGRESS ) goto out;
@@ -506,10 +504,9 @@ static int pkcs1pad_verify_complete(struct akcipher_request *req, int err)return err; } -static void pkcs1pad_verify_complete_cb ( -struct crypto_async_request *child_async_req,int err) +static void pkcs1pad_verify_complete_cb (void *data,int err) { -struct akcipher_request *req = child_async_req->data; +struct akcipher_request *req = data;if (err == -EINPROGRESS ) goto out;
crypto/seqiv.c +2 -3
@@ -36,10 +36,9 @@ static void seqiv_aead_encrypt_complete2(struct aead_request *req, int err)kfree_sensitive (subreq->iv); } -static void seqiv_aead_encrypt_complete (struct crypto_async_request *base, -int err) +static void seqiv_aead_encrypt_complete (void *data,int err) { -struct aead_request *req = base->data; +struct aead_request *req = data;seqiv_aead_encrypt_complete2 (req, err);aead_request_complete (req, err);
crypto/xts.c +6 -6
@@ -140,9 +140,9 @@ static int xts_xor_tweak_post(struct skcipher_request *req, bool enc)return xts_xor_tweak (req, true, enc); } -static void xts_cts_done (struct crypto_async_request *areq,int err) +static void xts_cts_done (void *data,int err) { -struct skcipher_request *req = areq->data; +struct skcipher_request *req = data;le128 b;if (!err) {
@@ -196,9 +196,9 @@ static int xts_cts_final(struct skcipher_request *req,return 0 ; } -static void xts_encrypt_done (struct crypto_async_request *areq,int err) +static void xts_encrypt_done (void *data,int err) { -struct skcipher_request *req = areq->data; +struct skcipher_request *req = data;if (!err) {struct xts_request_ctx *rctx =skcipher_request_ctx (req);
@@ -216,9 +216,9 @@ static void xts_encrypt_done(struct crypto_async_request *areq, int err)skcipher_request_complete (req, err); } -static void xts_decrypt_done (struct crypto_async_request *areq,int err) +static void xts_decrypt_done (void *data,int err) { -struct skcipher_request *req = areq->data; +struct skcipher_request *req = data;if (!err) {struct xts_request_ctx *rctx =skcipher_request_ctx (req);
drivers/crypto/atmel-sha.c +2 -3
@@ -2099,10 +2099,9 @@ struct atmel_sha_authenc_reqctx {unsigned int digestlen; }; -static void atmel_sha_authenc_complete (struct crypto_async_request *areq, -int err) +static void atmel_sha_authenc_complete (void *data,int err) { -struct ahash_request *req = areq->data; +struct ahash_request *req = data;struct atmel_sha_authenc_reqctx *authctx =ahash_request_ctx (req); authctx->cb (authctx->aes_dev, err, authctx->base.dd->is_async);
include/crypto/if_alg.h +1 -3
@@ -21,8 +21,6 @@#define ALG_MAX_PAGES 16 -struct crypto_async_request ; -struct alg_sock {/* struct sock must be the first member of struct alg_sock */ struct sock sk;
@@ -235,7 +233,7 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,ssize_t af_alg_sendpage (struct socket *sock,struct page *page,int offset,size_t size,int flags);void af_alg_free_resources (struct af_alg_async_req *areq); -void af_alg_async_cb (struct crypto_async_request *_req,int err); +void af_alg_async_cb (void *data,int err);__poll_t af_alg_poll (struct file *file,struct socket *sock,poll_table *wait); struct af_alg_async_req *af_alg_alloc_areq(struct sock *sk,
include/linux/crypto.h +5 -5
@@ -176,8 +176,8 @@ struct crypto_async_request;struct crypto_tfm ;struct crypto_type ; -typedef struct crypto_async_request crypto_completion_data_t ; -typedef void (*crypto_completion_t )(struct crypto_async_request *req,int err); +typedef void crypto_completion_data_t ; +typedef void (*crypto_completion_t )(void *req,int err);/** * DOC: Block Cipher Context Data Structures
@@ -596,12 +596,12 @@ struct crypto_wait {/* * Async ops completion helper functioons */ -static inline void *crypto_get_completion_data (crypto_completion_data_t *req) +static inline void *crypto_get_completion_data (void *data) { -return req->data; +return data; } -void crypto_req_done (struct crypto_async_request *req,int err); +void crypto_req_done (void *req,int err);static inline int crypto_wait_req (int err,struct crypto_wait *wait) {
Herbert Xu
maintainerPATCH v2 10/17 crypto: api - Use data directly in completion function
v2 adds the actual algapi conversion which went missing.
---8<---
This patch does the final flag day conversion of all completion functions which are now all contained in the Crypto API.
---
crypto/adiantum.c | 5 +--- crypto/af_alg.c | 6 ++--- crypto/ahash.c | 12 +++++----- crypto/api.c | 4 +-- crypto/authenc.c | 14 +++++------- crypto/authencesn.c | 15 +++++------- crypto/ccm.c | 9 +++---- crypto/chacha20poly1305.c | 40 +++++++++++++++++----------------- crypto/cryptd.c | 52 ++++++++++++++++++++++----------------------- crypto/cts.c | 12 +++++----- crypto/dh.c | 5 +--- crypto/essiv.c | 8 +++--- crypto/gcm.c | 36 ++++++++++++++----------------- crypto/hctr2.c | 5 +--- crypto/lrw.c | 4 +-- crypto/pcrypt.c | 4 +-- crypto/rsa-pkcs1pad.c | 15 +++++------- crypto/seqiv.c | 5 +--- crypto/xts.c | 12 +++++----- drivers/crypto/atmel-sha.c | 5 +--- include/crypto/algapi.h | 3 -- include/crypto/if_alg.h | 4 --- include/linux/crypto.h | 10 ++++---- 23 files changed, 133 insertions(+), 152 deletions(-)
crypto/adiantum.c +2 -3
@@ -308,10 +308,9 @@ static int adiantum_finish(struct skcipher_request *req)return 0 ; } -static void adiantum_streamcipher_done (struct crypto_async_request *areq, -int err) +static void adiantum_streamcipher_done (void *data,int err) { -struct skcipher_request *req = areq->data; +struct skcipher_request *req = data;if (!err) err =adiantum_finish (req);
crypto/af_alg.c +3 -3
@@ -1186,7 +1186,7 @@ EXPORT_SYMBOL_GPL(af_alg_free_resources);/** * af_alg_async_cb - AIO callback handler -* @_req: async request info +* @data: async request completion data * @err: if non-zero, error result to be returned via ki_complete(); * otherwise return the AIO output length via ki_complete(). *
@@ -1196,9 +1196,9 @@ EXPORT_SYMBOL_GPL(af_alg_free_resources);* The number of bytes to be generated with the AIO operation must be set * in areq->outlen before the AIO callback handler is invoked. */ -void af_alg_async_cb (struct crypto_async_request *_req,int err) +void af_alg_async_cb (void *data,int err) { -struct af_alg_async_req *areq = _req->data; +struct af_alg_async_req *areq = data;struct sock *sk = areq->sk;struct kiocb *iocb = areq->iocb;unsigned int resultlen;
crypto/ahash.c +6 -6
@@ -240,9 +240,9 @@ static void ahash_restore_req(struct ahash_request *req, int err)kfree_sensitive (subreq); } -static void ahash_op_unaligned_done (struct crypto_async_request *req,int err) +static void ahash_op_unaligned_done (void *data,int err) { -struct ahash_request *areq = req->data; +struct ahash_request *areq = data;if (err == -EINPROGRESS ) goto out;
@@ -330,9 +330,9 @@ int crypto_ahash_digest(struct ahash_request *req) }EXPORT_SYMBOL_GPL (crypto_ahash_digest); -static void ahash_def_finup_done2 (struct crypto_async_request *req,int err) +static void ahash_def_finup_done2 (void *data,int err) { -struct ahash_request *areq = req->data; +struct ahash_request *areq = data;if (err == -EINPROGRESS )return ;
@@ -360,9 +360,9 @@ static int ahash_def_finup_finish1(struct ahash_request *req, int err)return err; } -static void ahash_def_finup_done1 (struct crypto_async_request *req,int err) +static void ahash_def_finup_done1 (void *data,int err) { -struct ahash_request *areq = req->data; +struct ahash_request *areq = data;struct ahash_request *subreq;if (err == -EINPROGRESS )
crypto/api.c +2 -2
@@ -643,9 +643,9 @@ int crypto_has_alg(const char *name, u32 type, u32 mask) }EXPORT_SYMBOL_GPL (crypto_has_alg); -void crypto_req_done (struct crypto_async_request *req,int err) +void crypto_req_done (void *data,int err) { -struct crypto_wait *wait = req->data; +struct crypto_wait *wait = data;if (err == -EINPROGRESS )return ;
crypto/authenc.c +6 -8
@@ -109,9 +109,9 @@ static int crypto_authenc_setkey(struct crypto_aead *authenc, const u8 *key,return err; } -static void authenc_geniv_ahash_done (struct crypto_async_request *areq,int err) +static void authenc_geniv_ahash_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;struct crypto_aead *authenc =crypto_aead_reqtfm (req);struct aead_instance *inst =aead_alg_instance (authenc);struct authenc_instance_ctx *ictx =aead_instance_ctx (inst);
@@ -160,10 +160,9 @@ static int crypto_authenc_genicv(struct aead_request *req, unsigned int flags)return 0 ; } -static void crypto_authenc_encrypt_done (struct crypto_async_request *req, -int err) +static void crypto_authenc_encrypt_done (void *data,int err) { -struct aead_request *areq = req->data; +struct aead_request *areq = data;if (err) goto out;
@@ -261,10 +260,9 @@ static int crypto_authenc_decrypt_tail(struct aead_request *req,return crypto_skcipher_decrypt (skreq); } -static void authenc_verify_ahash_done (struct crypto_async_request *areq, -int err) +static void authenc_verify_ahash_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;if (err) goto out;
crypto/authencesn.c +6 -9
@@ -107,10 +107,9 @@ static int crypto_authenc_esn_genicv_tail(struct aead_request *req,return 0 ; } -static void authenc_esn_geniv_ahash_done (struct crypto_async_request *areq, -int err) +static void authenc_esn_geniv_ahash_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data; err = err ?:crypto_authenc_esn_genicv_tail (req,0 );aead_request_complete (req, err);
@@ -153,10 +152,9 @@ static int crypto_authenc_esn_genicv(struct aead_request *req, } -static void crypto_authenc_esn_encrypt_done (struct crypto_async_request *req, -int err) +static void crypto_authenc_esn_encrypt_done (void *data,int err) { -struct aead_request *areq = req->data; +struct aead_request *areq = data;if (!err) err =crypto_authenc_esn_genicv (areq,0 );
@@ -258,10 +256,9 @@ static int crypto_authenc_esn_decrypt_tail(struct aead_request *req,return crypto_skcipher_decrypt (skreq); } -static void authenc_esn_verify_ahash_done (struct crypto_async_request *areq, -int err) +static void authenc_esn_verify_ahash_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data; err = err ?:crypto_authenc_esn_decrypt_tail (req,0 );authenc_esn_request_complete (req, err);
crypto/ccm.c +4 -5
@@ -224,9 +224,9 @@ static int crypto_ccm_auth(struct aead_request *req, struct scatterlist *plain,return err; } -static void crypto_ccm_encrypt_done (struct crypto_async_request *areq,int err) +static void crypto_ccm_encrypt_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;struct crypto_aead *aead =crypto_aead_reqtfm (req);struct crypto_ccm_req_priv_ctx *pctx =crypto_ccm_reqctx (req);u8 *odata = pctx->odata;
@@ -320,10 +320,9 @@ static int crypto_ccm_encrypt(struct aead_request *req)return err; } -static void crypto_ccm_decrypt_done (struct crypto_async_request *areq, -int err) +static void crypto_ccm_decrypt_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;struct crypto_ccm_req_priv_ctx *pctx =crypto_ccm_reqctx (req);struct crypto_aead *aead =crypto_aead_reqtfm (req);unsigned int authsize =crypto_aead_authsize (aead);
crypto/chacha20poly1305.c +20 -20
@@ -115,9 +115,9 @@ static int poly_copy_tag(struct aead_request *req)return 0 ; } -static void chacha_decrypt_done (struct crypto_async_request *areq,int err) +static void chacha_decrypt_done (void *data,int err) { -async_done_continue (areq->data, err, poly_verify_tag); +async_done_continue (data, err, poly_verify_tag); }static int chacha_decrypt (struct aead_request *req)
@@ -161,9 +161,9 @@ static int poly_tail_continue(struct aead_request *req)return chacha_decrypt (req); } -static void poly_tail_done (struct crypto_async_request *areq,int err) +static void poly_tail_done (void *data,int err) { -async_done_continue (areq->data, err, poly_tail_continue); +async_done_continue (data, err, poly_tail_continue); }static int poly_tail (struct aead_request *req)
@@ -191,9 +191,9 @@ static int poly_tail(struct aead_request *req)return poly_tail_continue (req); } -static void poly_cipherpad_done (struct crypto_async_request *areq,int err) +static void poly_cipherpad_done (void *data,int err) { -async_done_continue (areq->data, err, poly_tail); +async_done_continue (data, err, poly_tail); }static int poly_cipherpad (struct aead_request *req)
@@ -220,9 +220,9 @@ static int poly_cipherpad(struct aead_request *req)return poly_tail (req); } -static void poly_cipher_done (struct crypto_async_request *areq,int err) +static void poly_cipher_done (void *data,int err) { -async_done_continue (areq->data, err, poly_cipherpad); +async_done_continue (data, err, poly_cipherpad); }static int poly_cipher (struct aead_request *req)
@@ -250,9 +250,9 @@ static int poly_cipher(struct aead_request *req)return poly_cipherpad (req); } -static void poly_adpad_done (struct crypto_async_request *areq,int err) +static void poly_adpad_done (void *data,int err) { -async_done_continue (areq->data, err, poly_cipher); +async_done_continue (data, err, poly_cipher); }static int poly_adpad (struct aead_request *req)
@@ -279,9 +279,9 @@ static int poly_adpad(struct aead_request *req)return poly_cipher (req); } -static void poly_ad_done (struct crypto_async_request *areq,int err) +static void poly_ad_done (void *data,int err) { -async_done_continue (areq->data, err, poly_adpad); +async_done_continue (data, err, poly_adpad); }static int poly_ad (struct aead_request *req)
@@ -303,9 +303,9 @@ static int poly_ad(struct aead_request *req)return poly_adpad (req); } -static void poly_setkey_done (struct crypto_async_request *areq,int err) +static void poly_setkey_done (void *data,int err) { -async_done_continue (areq->data, err, poly_ad); +async_done_continue (data, err, poly_ad); }static int poly_setkey (struct aead_request *req)
@@ -329,9 +329,9 @@ static int poly_setkey(struct aead_request *req)return poly_ad (req); } -static void poly_init_done (struct crypto_async_request *areq,int err) +static void poly_init_done (void *data,int err) { -async_done_continue (areq->data, err, poly_setkey); +async_done_continue (data, err, poly_setkey); }static int poly_init (struct aead_request *req)
@@ -352,9 +352,9 @@ static int poly_init(struct aead_request *req)return poly_setkey (req); } -static void poly_genkey_done (struct crypto_async_request *areq,int err) +static void poly_genkey_done (void *data,int err) { -async_done_continue (areq->data, err, poly_init); +async_done_continue (data, err, poly_init); }static int poly_genkey (struct aead_request *req)
@@ -391,9 +391,9 @@ static int poly_genkey(struct aead_request *req)return poly_init (req); } -static void chacha_encrypt_done (struct crypto_async_request *areq,int err) +static void chacha_encrypt_done (void *data,int err) { -async_done_continue (areq->data, err, poly_genkey); +async_done_continue (data, err, poly_genkey); }static int chacha_encrypt (struct aead_request *req)
crypto/cryptd.c +26 -26
115 lines not on this page · raw message
crypto/cts.c +6 -6
@@ -85,9 +85,9 @@ static int crypto_cts_setkey(struct crypto_skcipher *parent, const u8 *key,return crypto_skcipher_setkey (child, key, keylen); } -static void cts_cbc_crypt_done (struct crypto_async_request *areq,int err) +static void cts_cbc_crypt_done (void *data,int err) { -struct skcipher_request *req = areq->data; +struct skcipher_request *req = data;if (err == -EINPROGRESS )return ;
@@ -125,9 +125,9 @@ static int cts_cbc_encrypt(struct skcipher_request *req)return crypto_skcipher_encrypt (subreq); } -static void crypto_cts_encrypt_done (struct crypto_async_request *areq,int err) +static void crypto_cts_encrypt_done (void *data,int err) { -struct skcipher_request *req = areq->data; +struct skcipher_request *req = data;if (err) goto out;
@@ -219,9 +219,9 @@ static int cts_cbc_decrypt(struct skcipher_request *req)return crypto_skcipher_decrypt (subreq); } -static void crypto_cts_decrypt_done (struct crypto_async_request *areq,int err) +static void crypto_cts_decrypt_done (void *data,int err) { -struct skcipher_request *req = areq->data; +struct skcipher_request *req = data;if (err) goto out;
crypto/dh.c +2 -3
@@ -503,10 +503,9 @@ static int dh_safe_prime_set_secret(struct crypto_kpp *tfm, const void *buffer,return err; } -static void dh_safe_prime_complete_req (struct crypto_async_request *dh_req, -int err) +static void dh_safe_prime_complete_req (void *data,int err) { -struct kpp_request *req = dh_req->data; +struct kpp_request *req = data;kpp_request_complete (req, err); }
crypto/essiv.c +4 -4
@@ -131,9 +131,9 @@ static int essiv_aead_setauthsize(struct crypto_aead *tfm,return crypto_aead_setauthsize (tctx->u.aead, authsize); } -static void essiv_skcipher_done (struct crypto_async_request *areq,int err) +static void essiv_skcipher_done (void *data,int err) { -struct skcipher_request *req = areq->data; +struct skcipher_request *req = data;skcipher_request_complete (req, err); }
@@ -166,9 +166,9 @@ static int essiv_skcipher_decrypt(struct skcipher_request *req)return essiv_skcipher_crypt (req, false); } -static void essiv_aead_done (struct crypto_async_request *areq,int err) +static void essiv_aead_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;struct essiv_aead_request_ctx *rctx =aead_request_ctx (req);if (err == -EINPROGRESS )
crypto/gcm.c +17 -19
@@ -197,7 +197,7 @@ static inline unsigned int gcm_remain(unsigned int len)return len ?16 - len :0 ; } -static void gcm_hash_len_done (struct crypto_async_request *areq,int err); +static void gcm_hash_len_done (void *data,int err); static int gcm_hash_update(struct aead_request *req, crypto_completion_t compl,
@@ -246,9 +246,9 @@ static int gcm_hash_len_continue(struct aead_request *req, u32 flags)return gctx->complete (req, flags); } -static void gcm_hash_len_done (struct crypto_async_request *areq,int err) +static void gcm_hash_len_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;if (err) goto out;
@@ -267,10 +267,9 @@ static int gcm_hash_crypt_remain_continue(struct aead_request *req, u32 flags)gcm_hash_len_continue (req, flags); } -static void gcm_hash_crypt_remain_done (struct crypto_async_request *areq, -int err) +static void gcm_hash_crypt_remain_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;if (err) goto out;
@@ -298,9 +297,9 @@ static int gcm_hash_crypt_continue(struct aead_request *req, u32 flags)return gcm_hash_crypt_remain_continue (req, flags); } -static void gcm_hash_crypt_done (struct crypto_async_request *areq,int err) +static void gcm_hash_crypt_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;if (err) goto out;
@@ -326,10 +325,9 @@ static int gcm_hash_assoc_remain_continue(struct aead_request *req, u32 flags)return gcm_hash_crypt_remain_continue (req, flags); } -static void gcm_hash_assoc_remain_done (struct crypto_async_request *areq, -int err) +static void gcm_hash_assoc_remain_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;if (err) goto out;
@@ -355,9 +353,9 @@ static int gcm_hash_assoc_continue(struct aead_request *req, u32 flags)return gcm_hash_assoc_remain_continue (req, flags); } -static void gcm_hash_assoc_done (struct crypto_async_request *areq,int err) +static void gcm_hash_assoc_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;if (err) goto out;
@@ -380,9 +378,9 @@ static int gcm_hash_init_continue(struct aead_request *req, u32 flags)return gcm_hash_assoc_remain_continue (req, flags); } -static void gcm_hash_init_done (struct crypto_async_request *areq,int err) +static void gcm_hash_init_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;if (err) goto out;
@@ -433,9 +431,9 @@ static int gcm_encrypt_continue(struct aead_request *req, u32 flags)return gcm_hash (req, flags); } -static void gcm_encrypt_done (struct crypto_async_request *areq,int err) +static void gcm_encrypt_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;if (err) goto out;
@@ -477,9 +475,9 @@ static int crypto_gcm_verify(struct aead_request *req)return crypto_memneq (iauth_tag, auth_tag, authsize) ? -EBADMSG :0 ; } -static void gcm_decrypt_done (struct crypto_async_request *areq,int err) +static void gcm_decrypt_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;if (!err) err =crypto_gcm_verify (req);
crypto/hctr2.c +2 -3
@@ -252,10 +252,9 @@ static int hctr2_finish(struct skcipher_request *req)return 0 ; } -static void hctr2_xctr_done (struct crypto_async_request *areq, -int err) +static void hctr2_xctr_done (void *data,int err) { -struct skcipher_request *req = areq->data; +struct skcipher_request *req = data;if (!err) err =hctr2_finish (req);
crypto/lrw.c +2 -2
@@ -205,9 +205,9 @@ static int lrw_xor_tweak_post(struct skcipher_request *req)return lrw_xor_tweak (req, true); } -static void lrw_crypt_done (struct crypto_async_request *areq,int err) +static void lrw_crypt_done (void *data,int err) { -struct skcipher_request *req = areq->data; +struct skcipher_request *req = data;if (!err) {struct lrw_request_ctx *rctx =skcipher_request_ctx (req);
crypto/pcrypt.c +2 -2
@@ -63,9 +63,9 @@ static void pcrypt_aead_serial(struct padata_priv *padata)aead_request_complete (req->base.data, padata->info); } -static void pcrypt_aead_done (struct crypto_async_request *areq,int err) +static void pcrypt_aead_done (void *data,int err) { -struct aead_request *req = areq->data; +struct aead_request *req = data;struct pcrypt_request *preq =aead_request_ctx (req);struct padata_priv *padata =pcrypt_request_padata (preq);
crypto/rsa-pkcs1pad.c +6 -9
@@ -210,10 +210,9 @@ static int pkcs1pad_encrypt_sign_complete(struct akcipher_request *req, int err)return err; } -static void pkcs1pad_encrypt_sign_complete_cb ( -struct crypto_async_request *child_async_req,int err) +static void pkcs1pad_encrypt_sign_complete_cb (void *data,int err) { -struct akcipher_request *req = child_async_req->data; +struct akcipher_request *req = data;if (err == -EINPROGRESS ) goto out;
@@ -326,10 +325,9 @@ static int pkcs1pad_decrypt_complete(struct akcipher_request *req, int err)return err; } -static void pkcs1pad_decrypt_complete_cb ( -struct crypto_async_request *child_async_req,int err) +static void pkcs1pad_decrypt_complete_cb (void *data,int err) { -struct akcipher_request *req = child_async_req->data; +struct akcipher_request *req = data;if (err == -EINPROGRESS ) goto out;
@@ -506,10 +504,9 @@ static int pkcs1pad_verify_complete(struct akcipher_request *req, int err)return err; } -static void pkcs1pad_verify_complete_cb ( -struct crypto_async_request *child_async_req,int err) +static void pkcs1pad_verify_complete_cb (void *data,int err) { -struct akcipher_request *req = child_async_req->data; +struct akcipher_request *req = data;if (err == -EINPROGRESS ) goto out;
crypto/seqiv.c +2 -3
@@ -36,10 +36,9 @@ static void seqiv_aead_encrypt_complete2(struct aead_request *req, int err)kfree_sensitive (subreq->iv); } -static void seqiv_aead_encrypt_complete (struct crypto_async_request *base, -int err) +static void seqiv_aead_encrypt_complete (void *data,int err) { -struct aead_request *req = base->data; +struct aead_request *req = data;seqiv_aead_encrypt_complete2 (req, err);aead_request_complete (req, err);
crypto/xts.c +6 -6
@@ -140,9 +140,9 @@ static int xts_xor_tweak_post(struct skcipher_request *req, bool enc)return xts_xor_tweak (req, true, enc); } -static void xts_cts_done (struct crypto_async_request *areq,int err) +static void xts_cts_done (void *data,int err) { -struct skcipher_request *req = areq->data; +struct skcipher_request *req = data;le128 b;if (!err) {
@@ -196,9 +196,9 @@ static int xts_cts_final(struct skcipher_request *req,return 0 ; } -static void xts_encrypt_done (struct crypto_async_request *areq,int err) +static void xts_encrypt_done (void *data,int err) { -struct skcipher_request *req = areq->data; +struct skcipher_request *req = data;if (!err) {struct xts_request_ctx *rctx =skcipher_request_ctx (req);
@@ -216,9 +216,9 @@ static void xts_encrypt_done(struct crypto_async_request *areq, int err)skcipher_request_complete (req, err); } -static void xts_decrypt_done (struct crypto_async_request *areq,int err) +static void xts_decrypt_done (void *data,int err) { -struct skcipher_request *req = areq->data; +struct skcipher_request *req = data;if (!err) {struct xts_request_ctx *rctx =skcipher_request_ctx (req);
drivers/crypto/atmel-sha.c +2 -3
@@ -2099,10 +2099,9 @@ struct atmel_sha_authenc_reqctx {unsigned int digestlen; }; -static void atmel_sha_authenc_complete (struct crypto_async_request *areq, -int err) +static void atmel_sha_authenc_complete (void *data,int err) { -struct ahash_request *req = areq->data; +struct ahash_request *req = data;struct atmel_sha_authenc_reqctx *authctx =ahash_request_ctx (req); authctx->cb (authctx->aes_dev, err, authctx->base.dd->is_async);
include/crypto/algapi.h +1 -2
@@ -305,8 +305,7 @@ enum {static inline void crypto_request_complete (struct crypto_async_request *req,int err) { -crypto_completion_t complete = req->complete; -complete (req, err); + req->complete (req->data, err); }#endif /* _CRYPTO_ALGAPI_H */
include/crypto/if_alg.h +1 -3
@@ -21,8 +21,6 @@#define ALG_MAX_PAGES 16 -struct crypto_async_request ; -struct alg_sock {/* struct sock must be the first member of struct alg_sock */ struct sock sk;
@@ -235,7 +233,7 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,ssize_t af_alg_sendpage (struct socket *sock,struct page *page,int offset,size_t size,int flags);void af_alg_free_resources (struct af_alg_async_req *areq); -void af_alg_async_cb (struct crypto_async_request *_req,int err); +void af_alg_async_cb (void *data,int err);__poll_t af_alg_poll (struct file *file,struct socket *sock,poll_table *wait); struct af_alg_async_req *af_alg_alloc_areq(struct sock *sk,
include/linux/crypto.h +5 -5
@@ -176,8 +176,8 @@ struct crypto_async_request;struct crypto_tfm ;struct crypto_type ; -typedef struct crypto_async_request crypto_completion_data_t ; -typedef void (*crypto_completion_t )(struct crypto_async_request *req,int err); +typedef void crypto_completion_data_t ; +typedef void (*crypto_completion_t )(void *req,int err);/** * DOC: Block Cipher Context Data Structures
@@ -596,12 +596,12 @@ struct crypto_wait {/* * Async ops completion helper functioons */ -static inline void *crypto_get_completion_data (crypto_completion_data_t *req) +static inline void *crypto_get_completion_data (void *data) { -return req->data; +return data; } -void crypto_req_done (struct crypto_async_request *req,int err); +void crypto_req_done (void *req,int err);static inline int crypto_wait_req (int err,struct crypto_wait *wait) {
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
RE: [v2,10/17] crypto: api - Use data directly in completion function
This is an automated email and please do not reply to this email.
Dear Submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.
----- Output -----
error: patch failed: crypto/ahash.c:240
error: crypto/ahash.c: patch does not apply
error: patch failed: crypto/cryptd.c:285
error: crypto/cryptd.c: patch does not apply
error: patch failed: crypto/essiv.c:166
error: crypto/essiv.c: patch does not apply
error: patch failed: crypto/rsa-pkcs1pad.c:210
error: crypto/rsa-pkcs1pad.c: patch does not apply
error: patch failed: include/crypto/algapi.h:305
error: include/crypto/algapi.h: patch does not apply
error: patch failed: include/linux/crypto.h:176
error: include/linux/crypto.h: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch
Please resolve the issue and submit the patches again.
---
Regards,
Linux Bluetooth
Herbert Xu
maintainerPATCH 11/17 dm: Remove completion function scaffolding
In reply to Herbert XuThis patch removes the temporary scaffolding now that the comletion function signature has been converted.
---
drivers/md/dm-crypt.c | 6 +++--- drivers/md/dm-integrity.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/md/dm-crypt.c +3 -3
@@ -1458,7 +1458,7 @@ static int crypt_convert_block_skcipher(struct crypt_config *cc,return r; } -static void kcryptd_async_done (crypto_completion_data_t *async_req,int error); +static void kcryptd_async_done (void *async_req,int error);static int crypt_alloc_req_skcipher (struct crypt_config *cc,struct convert_context *ctx)
@@ -2146,9 +2146,9 @@ static void kcryptd_crypt_read_convert(struct dm_crypt_io *io)crypt_dec_pending (io); } -static void kcryptd_async_done (crypto_completion_data_t *data,int error) +static void kcryptd_async_done (void *data,int error) { -struct dm_crypt_request *dmreq =crypto_get_completion_data (data); +struct dm_crypt_request *dmreq = data;struct convert_context *ctx = dmreq->ctx; struct dm_crypt_io *io = container_of(ctx, struct dm_crypt_io, ctx);struct crypt_config *cc = io->cc;
drivers/md/dm-integrity.c +2 -2
@@ -955,9 +955,9 @@ static void xor_journal(struct dm_integrity_c *ic, bool encrypt, unsigned sectioasync_tx_issue_pending_all (); } -static void complete_journal_encrypt (crypto_completion_data_t *data,int err) +static void complete_journal_encrypt (void *data,int err) { -struct journal_completion *comp =crypto_get_completion_data (data); +struct journal_completion *comp = data;if (unlikely (err)) {if (likely (err == -EINPROGRESS )) {complete (&comp->ic->crypto_backoff);
Re: [PATCH 11/17] dm: Remove completion function scaffolding
Quoted 4 lines · Herbert Xu
This patch removes the temporary scaffolding now that the comletion function signature has been converted.
Signed-off-by Herbert Xu <[email protected]>
Herbert Xu
maintainerPATCH 12/17 net: macsec: Remove completion function scaffolding
In reply to Herbert XuThis patch removes the temporary scaffolding now that the comletion function signature has been converted.
---
drivers/net/macsec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/macsec.c +4 -4
@@ -528,9 +528,9 @@ static void count_tx(struct net_device *dev, int ret, int len) } } -static void macsec_encrypt_done (crypto_completion_data_t *data,int err) +static void macsec_encrypt_done (void *data,int err) { -struct sk_buff *skb =crypto_get_completion_data (data); +struct sk_buff *skb = data;struct net_device *dev = skb->dev;struct macsec_dev *macsec =macsec_priv (dev);struct macsec_tx_sa *sa =macsec_skb_cb (skb)->tx_sa;
@@ -835,9 +835,9 @@ static void count_rx(struct net_device *dev, int len)u64_stats_update_end (&stats->syncp); } -static void macsec_decrypt_done (crypto_completion_data_t *data,int err) +static void macsec_decrypt_done (void *data,int err) { -struct sk_buff *skb =crypto_get_completion_data (data); +struct sk_buff *skb = data;struct net_device *dev = skb->dev;struct macsec_dev *macsec =macsec_priv (dev);struct macsec_rx_sa *rx_sa =macsec_skb_cb (skb)->rx_sa;
Herbert Xu
maintainerPATCH 13/17 net: ipv4: Remove completion function scaffolding
In reply to Herbert XuThis patch removes the temporary scaffolding now that the comletion function signature has been converted.
---
net/ipv4/ah4.c | 8 ++++---- net/ipv4/esp4.c | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-)
net/ipv4/ah4.c +4 -4
@@ -117,11 +117,11 @@ static int ip_clear_mutable_options(const struct iphdr *iph, __be32 *daddr)return 0 ; } -static void ah_output_done (crypto_completion_data_t *data,int err) +static void ah_output_done (void *data,int err) {u8 *icv;struct iphdr *iph; -struct sk_buff *skb =crypto_get_completion_data (data); +struct sk_buff *skb = data;struct xfrm_state *x =skb_dst (skb)->xfrm;struct ah_data *ahp = x->data;struct iphdr *top_iph =ip_hdr (skb);
@@ -262,12 +262,12 @@ static int ah_output(struct xfrm_state *x, struct sk_buff *skb)return err; } -static void ah_input_done (crypto_completion_data_t *data,int err) +static void ah_input_done (void *data,int err) {u8 *auth_data;u8 *icv;struct iphdr *work_iph; -struct sk_buff *skb =crypto_get_completion_data (data); +struct sk_buff *skb = data;struct xfrm_state *x =xfrm_input_state (skb);struct ah_data *ahp = x->data;struct ip_auth_hdr *ah =ip_auth_hdr (skb);
net/ipv4/esp4.c +8 -8
@@ -244,9 +244,9 @@ static int esp_output_tail_tcp(struct xfrm_state *x, struct sk_buff *skb) }#endif -static void esp_output_done (crypto_completion_data_t *data,int err) +static void esp_output_done (void *data,int err) { -struct sk_buff *skb =crypto_get_completion_data (data); +struct sk_buff *skb = data;struct xfrm_offload *xo =xfrm_offload (skb);void *tmp;struct xfrm_state *x;
@@ -332,9 +332,9 @@ static struct ip_esp_hdr *esp_output_set_extra(struct sk_buff *skb,return esph; } -static void esp_output_done_esn (crypto_completion_data_t *data,int err) +static void esp_output_done_esn (void *data,int err) { -struct sk_buff *skb =crypto_get_completion_data (data); +struct sk_buff *skb = data;esp_output_restore_header (skb);esp_output_done (data, err);
@@ -830,9 +830,9 @@ int esp_input_done2(struct sk_buff *skb, int err) }EXPORT_SYMBOL_GPL (esp_input_done2); -static void esp_input_done (crypto_completion_data_t *data,int err) +static void esp_input_done (void *data,int err) { -struct sk_buff *skb =crypto_get_completion_data (data); +struct sk_buff *skb = data;xfrm_input_resume (skb,esp_input_done2 (skb, err)); }
@@ -860,9 +860,9 @@ static void esp_input_set_header(struct sk_buff *skb, __be32 *seqhi) } } -static void esp_input_done_esn (crypto_completion_data_t *data,int err) +static void esp_input_done_esn (void *data,int err) { -struct sk_buff *skb =crypto_get_completion_data (data); +struct sk_buff *skb = data;esp_input_restore_header (skb);esp_input_done (data, err);
Herbert Xu
maintainerPATCH 14/17 net: ipv6: Remove completion function scaffolding
In reply to Herbert XuThis patch removes the temporary scaffolding now that the comletion function signature has been converted.
---
net/ipv6/ah6.c | 8 ++++---- net/ipv6/esp6.c | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-)
net/ipv6/ah6.c +4 -4
@@ -281,12 +281,12 @@ static int ipv6_clear_mutable_options(struct ipv6hdr *iph, int len, int dir)return 0 ; } -static void ah6_output_done (crypto_completion_data_t *data,int err) +static void ah6_output_done (void *data,int err) {int extlen;u8 *iph_base;u8 *icv; -struct sk_buff *skb =crypto_get_completion_data (data); +struct sk_buff *skb = data;struct xfrm_state *x =skb_dst (skb)->xfrm;struct ah_data *ahp = x->data;struct ipv6hdr *top_iph =ipv6_hdr (skb);
@@ -451,12 +451,12 @@ static int ah6_output(struct xfrm_state *x, struct sk_buff *skb)return err; } -static void ah6_input_done (crypto_completion_data_t *data,int err) +static void ah6_input_done (void *data,int err) {u8 *auth_data;u8 *icv;u8 *work_iph; -struct sk_buff *skb =crypto_get_completion_data (data); +struct sk_buff *skb = data;struct xfrm_state *x =xfrm_input_state (skb);struct ah_data *ahp = x->data;struct ip_auth_hdr *ah =ip_auth_hdr (skb);
net/ipv6/esp6.c +8 -8
@@ -278,9 +278,9 @@ static void esp_output_encap_csum(struct sk_buff *skb) } } -static void esp_output_done (crypto_completion_data_t *data,int err) +static void esp_output_done (void *data,int err) { -struct sk_buff *skb =crypto_get_completion_data (data); +struct sk_buff *skb = data;struct xfrm_offload *xo =xfrm_offload (skb);void *tmp;struct xfrm_state *x;
@@ -368,9 +368,9 @@ static struct ip_esp_hdr *esp_output_set_esn(struct sk_buff *skb,return esph; } -static void esp_output_done_esn (crypto_completion_data_t *data,int err) +static void esp_output_done_esn (void *data,int err) { -struct sk_buff *skb =crypto_get_completion_data (data); +struct sk_buff *skb = data;esp_output_restore_header (skb);esp_output_done (data, err);
@@ -879,9 +879,9 @@ int esp6_input_done2(struct sk_buff *skb, int err) }EXPORT_SYMBOL_GPL (esp6_input_done2); -static void esp_input_done (crypto_completion_data_t *data,int err) +static void esp_input_done (void *data,int err) { -struct sk_buff *skb =crypto_get_completion_data (data); +struct sk_buff *skb = data;xfrm_input_resume (skb,esp6_input_done2 (skb, err)); }
@@ -909,9 +909,9 @@ static void esp_input_set_header(struct sk_buff *skb, __be32 *seqhi) } } -static void esp_input_done_esn (crypto_completion_data_t *data,int err) +static void esp_input_done_esn (void *data,int err) { -struct sk_buff *skb =crypto_get_completion_data (data); +struct sk_buff *skb = data;esp_input_restore_header (skb);esp_input_done (data, err);
Herbert Xu
maintainerPATCH 15/17 tipc: Remove completion function scaffolding
In reply to Herbert XuThis patch removes the temporary scaffolding now that the comletion function signature has been converted.
---
net/tipc/crypto.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
net/tipc/crypto.c +6 -6
@@ -267,10 +267,10 @@ static int tipc_aead_encrypt(struct tipc_aead *aead, struct sk_buff *skb,struct tipc_bearer *b, struct tipc_media_addr *dst, struct tipc_node *__dnode); -static void tipc_aead_encrypt_done (crypto_completion_data_t *data,int err); +static void tipc_aead_encrypt_done (void *data,int err);static int tipc_aead_decrypt (struct net *net,struct tipc_aead *aead,struct sk_buff *skb,struct tipc_bearer *b); -static void tipc_aead_decrypt_done (crypto_completion_data_t *data,int err); +static void tipc_aead_decrypt_done (void *data,int err);static inline int tipc_ehdr_size (struct tipc_ehdr *ehdr); static int tipc_ehdr_build(struct net *net, struct tipc_aead *aead, u8 tx_key, struct sk_buff *skb,
@@ -830,9 +830,9 @@ static int tipc_aead_encrypt(struct tipc_aead *aead, struct sk_buff *skb,return rc; } -static void tipc_aead_encrypt_done (crypto_completion_data_t *data,int err) +static void tipc_aead_encrypt_done (void *data,int err) { -struct sk_buff *skb =crypto_get_completion_data (data); +struct sk_buff *skb = data;struct tipc_crypto_tx_ctx *tx_ctx =TIPC_SKB_CB (skb)->crypto_ctx;struct tipc_bearer *b = tx_ctx->bearer;struct tipc_aead *aead = tx_ctx->aead;
@@ -954,9 +954,9 @@ static int tipc_aead_decrypt(struct net *net, struct tipc_aead *aead,return rc; } -static void tipc_aead_decrypt_done (crypto_completion_data_t *data,int err) +static void tipc_aead_decrypt_done (void *data,int err) { -struct sk_buff *skb =crypto_get_completion_data (data); +struct sk_buff *skb = data;struct tipc_crypto_rx_ctx *rx_ctx =TIPC_SKB_CB (skb)->crypto_ctx;struct tipc_bearer *b = rx_ctx->bearer;struct tipc_aead *aead = rx_ctx->aead;
Herbert Xu
maintainerPATCH 16/17 tls: Remove completion function scaffolding
In reply to Herbert XuThis patch removes the temporary scaffolding now that the comletion function signature has been converted.
---
net/tls/tls_sw.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/tls/tls_sw.c +4 -4
@@ -179,9 +179,9 @@ static int tls_padding_length(struct tls_prot_info *prot, struct sk_buff *skb,return sub; } -static void tls_decrypt_done (crypto_completion_data_t *data,int err) +static void tls_decrypt_done (void *data,int err) { -struct aead_request *aead_req =crypto_get_completion_data (data); +struct aead_request *aead_req = data;struct crypto_aead *aead =crypto_aead_reqtfm (aead_req);struct scatterlist *sgout = aead_req->dst;struct scatterlist *sgin = aead_req->src;
@@ -428,9 +428,9 @@ int tls_tx_records(struct sock *sk, int flags)return rc; } -static void tls_encrypt_done (crypto_completion_data_t *data,int err) +static void tls_encrypt_done (void *data,int err) { -struct aead_request *aead_req =crypto_get_completion_data (data); +struct aead_request *aead_req = data;struct tls_sw_context_tx *ctx;struct tls_context *tls_ctx;struct tls_prot_info *prot;
Herbert Xu
maintainerPATCH 17/17 crypto: api - Remove completion function scaffolding
In reply to Herbert XuThis patch removes the temporary scaffolding now that the comletion function signature has been converted.
---
include/linux/crypto.h | 6 ------ 1 file changed, 6 deletions(-)
include/linux/crypto.h +0 -6
@@ -176,7 +176,6 @@ struct crypto_async_request;struct crypto_tfm ;struct crypto_type ; -typedef void crypto_completion_data_t ;typedef void (*crypto_completion_t )(void *req,int err);/**
@@ -596,11 +595,6 @@ struct crypto_wait {/* * Async ops completion helper functioons */ -static inline void *crypto_get_completion_data (void *data) -{ -return data; -} -void crypto_req_done (void *req,int err);static inline int crypto_wait_req (int err,struct crypto_wait *wait)
Re: [PATCH 17/17] crypto: api - Remove completion function scaffolding
Quoted 4 lines · Herbert Xu
This patch removes the temporary scaffolding now that the comletion function signature has been converted.
Signed-off-by Herbert Xu <[email protected]>
For the 1-17:
(nit applies tho to all of them but use your own judgement i guess)
Quoted 19 lines
---
include/linux/crypto.h | 6 ------ 1 file changed, 6 deletions(-)include/linux/crypto.h +0
-1@@ -176,7 +176,6 @@ struct crypto_async_request;struct crypto_tfm ;struct crypto_type ; -typedef void crypto_completion_data_t ;typedef void (*crypto_completion_t )(void *req,int err);/** @@ -596,11 +595,6 @@ struct crypto_wait {/*
include/linux/crypto.h struct crypto_wait { · line 600
Quoted 10 lines
include/linux/crypto.h +0
-5* Async ops completion helper functioons */ -static inline void *crypto_get_completion_data (void *data) -{ -return data; -} -void crypto_req_done (void *req,int err);static inline int crypto_wait_req (int err,struct crypto_wait *wait)
BR, Jarkko
Jakub Kicinski
maintainerQuoted 5 lines · On Mon, 6 Feb 2023 18:21:06 +0800 Herbert Xu wrote:
The crypto completion function currently takes a pointer to a struct
crypto_async_requestobject. However, in reality the API does not allow the use of any part of the object apart from the data field. For example, ahash/shash will create a fake object on the stack to pass along a different data field.
"different data field" == copy the value to a different structure? A bit hard to parse TBH.
Quoted 9 lines
This leads to potential bugs where the user may try to dereference or otherwise use the
crypto_async_requestobject.This series changes the completion function to take a void * argument instead of
crypto_async_request.This series touches code in a number of different subsystems. Most of them are trivial except for tls which was actually buggy as it did exactly what was described above.
Buggy means bug could be hit in real light or buggy == did not use the API right?
Quoted 3 lines
I'd like to pull all the changes through the crypto tree. But feel free to object if you'd like the relevant patches to go through your trees instead and I'll split this up.
Jakub Kicinski
maintainerQuoted 2 lines · On Mon, 6 Feb 2023 23:10:08 -0800 Jakub Kicinski wrote:
Buggy means bug could be hit in real light or buggy == did not use the API right?
"in real light"... time to sign off for the night. s/light/life/
Herbert Xu
maintainerQuoted 9 lines · Jakub Kicinski
Quoted 5 lines · On Mon, 6 Feb 2023 18:21:06 +0800 Herbert Xu wrote:
The crypto completion function currently takes a pointer to a struct
crypto_async_requestobject. However, in reality the API does not allow the use of any part of the object apart from the data field. For example, ahash/shash will create a fake object on the stack to pass along a different data field."different data field" == copy the value to a different structure? A bit hard to parse TBH.
The word data here refers to the data field in struct crypto_async_request.
Quoted 2 lines
Buggy means bug could be hit in real light or buggy == did not use the API right?
Yes this bug is real. If you hit a driver/algorithm that returns a different request object (of which there are many in the API) then you will be dereferencing random pointers.
Cheers,
Signature · 7 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- dm-devel mailing list [email protected] https://listman.redhat.com/mailman/listinfo/dm-devel
Jakub Kicinski
maintainerQuoted 6 lines · On Tue, 7 Feb 2023 16:03:52 +0800 Herbert Xu wrote:
Quoted 2 lines
Buggy means bug could be hit in real light or buggy == did not use the API right?
Yes this bug is real. If you hit a driver/algorithm that returns a different request object (of which there are many in the API) then you will be dereferencing random pointers.
Any aes-gcm or chacha-poly implementations which would do that come to mind? I'm asking 'cause we probably want to do stable if we know of a combination which would be broken, or the chances of one existing are high.
Otherwise no objections for the patches to go via the crypto tree, there should be no conflicts AFAIK. Feel free to add my ack on the networking changes if needed.
Herbert Xu
maintainerOn Tue, Feb 07, 2023 at 10:51:46AM -0800, Jakub Kicinski wrote:
.
Quoted 4 lines
Any aes-gcm or chacha-poly implementations which would do that come to mind? I'm asking 'cause we probably want to do stable if we know of a combination which would be broken, or the chances of one existing are high.
Good point. I had a quick look at tls_sw.c and it *appears* to be safe with the default software code. As tls_sw only uses the generic AEAD algorithms (rather than the IPsec-specific variants which aren't safe), the software-only paths *should* be OK.
However, drivers that support these algorithms may require fallbacks for esoteric reasons. For example, drivers/crypto/amcc appears to require a fallback for certain input parameters which may or may not be possible with TLS.
To be on the safe side I would do a backport once this has been in mainline for a little bit.
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt