* [PATCH v2] drivers/crypto/nx: fix init race, alignmasks and GCM bug @ 2013-03-20 14:22 Kent Yoder 2013-03-28 16:32 ` Fwd: " Kent Yoder 0 siblings, 1 reply; 4+ messages in thread From: Kent Yoder @ 2013-03-20 14:22 UTC (permalink / raw) To: linux-kernel; +Cc: linux-crypto, Benjamin Herrenschmidt Fixes a race on driver init with registering algorithms where the driver status flag wasn't being set before self testing started. Added the cra_alignmask field for CBC and ECB modes. Fixed a bug in GCM where AES block size was being used instead of authsize. Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com> --- Only changes in v2 were to leave stable off the cc and add Ben for PPC. drivers/crypto/nx/nx-aes-cbc.c | 1 + drivers/crypto/nx/nx-aes-ecb.c | 1 + drivers/crypto/nx/nx-aes-gcm.c | 2 +- drivers/crypto/nx/nx.c | 4 ++-- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/nx/nx-aes-cbc.c b/drivers/crypto/nx/nx-aes-cbc.c index a76d4c4..35d483f 100644 --- a/drivers/crypto/nx/nx-aes-cbc.c +++ b/drivers/crypto/nx/nx-aes-cbc.c @@ -126,6 +126,7 @@ struct crypto_alg nx_cbc_aes_alg = { .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct nx_crypto_ctx), .cra_type = &crypto_blkcipher_type, + .cra_alignmask = 0xf, .cra_module = THIS_MODULE, .cra_init = nx_crypto_ctx_aes_cbc_init, .cra_exit = nx_crypto_ctx_exit, diff --git a/drivers/crypto/nx/nx-aes-ecb.c b/drivers/crypto/nx/nx-aes-ecb.c index ba5f161..7bbc9a8 100644 --- a/drivers/crypto/nx/nx-aes-ecb.c +++ b/drivers/crypto/nx/nx-aes-ecb.c @@ -123,6 +123,7 @@ struct crypto_alg nx_ecb_aes_alg = { .cra_priority = 300, .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, .cra_blocksize = AES_BLOCK_SIZE, + .cra_alignmask = 0xf, .cra_ctxsize = sizeof(struct nx_crypto_ctx), .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, diff --git a/drivers/crypto/nx/nx-aes-gcm.c b/drivers/crypto/nx/nx-aes-gcm.c index c8109ed..6cca6c3 100644 --- a/drivers/crypto/nx/nx-aes-gcm.c +++ b/drivers/crypto/nx/nx-aes-gcm.c @@ -219,7 +219,7 @@ static int gcm_aes_nx_crypt(struct aead_request *req, int enc) if (enc) NX_CPB_FDM(csbcpb) |= NX_FDM_ENDE_ENCRYPT; else - nbytes -= AES_BLOCK_SIZE; + nbytes -= crypto_aead_authsize(crypto_aead_reqtfm(req)); csbcpb->cpb.aes_gcm.bit_length_data = nbytes * 8; diff --git a/drivers/crypto/nx/nx.c b/drivers/crypto/nx/nx.c index c767f23..7621d05 100644 --- a/drivers/crypto/nx/nx.c +++ b/drivers/crypto/nx/nx.c @@ -454,6 +454,8 @@ static int nx_register_algs(void) if (rc) goto out; + nx_driver.of.status = NX_OKAY; + rc = crypto_register_alg(&nx_ecb_aes_alg); if (rc) goto out; @@ -498,8 +500,6 @@ static int nx_register_algs(void) if (rc) goto out_unreg_s512; - nx_driver.of.status = NX_OKAY; - goto out; out_unreg_s512: -- 1.7.11.7 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Fwd: [PATCH v2] drivers/crypto/nx: fix init race, alignmasks and GCM bug 2013-03-20 14:22 [PATCH v2] drivers/crypto/nx: fix init race, alignmasks and GCM bug Kent Yoder @ 2013-03-28 16:32 ` Kent Yoder 2013-03-28 18:24 ` Benjamin Herrenschmidt 0 siblings, 1 reply; 4+ messages in thread From: Kent Yoder @ 2013-03-28 16:32 UTC (permalink / raw) To: Benjamin Herrenschmidt; +Cc: linux-kernel, linux-crypto Hi Ben, will you carry this patch in the linuxppc-dev tree? Thanks, Kent ---------- Forwarded message ---------- From: Kent Yoder <shpedoikal@gmail.com> Date: Wed, Mar 20, 2013 at 9:22 AM Subject: [PATCH v2] drivers/crypto/nx: fix init race, alignmasks and GCM bug To: linux-kernel@vger.kernel.org Cc: linux-crypto@vger.kernel.org, Benjamin Herrenschmidt <benh@kernel.crashing.org> Fixes a race on driver init with registering algorithms where the driver status flag wasn't being set before self testing started. Added the cra_alignmask field for CBC and ECB modes. Fixed a bug in GCM where AES block size was being used instead of authsize. Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com> --- Only changes in v2 were to leave stable off the cc and add Ben for PPC. drivers/crypto/nx/nx-aes-cbc.c | 1 + drivers/crypto/nx/nx-aes-ecb.c | 1 + drivers/crypto/nx/nx-aes-gcm.c | 2 +- drivers/crypto/nx/nx.c | 4 ++-- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/nx/nx-aes-cbc.c b/drivers/crypto/nx/nx-aes-cbc.c index a76d4c4..35d483f 100644 --- a/drivers/crypto/nx/nx-aes-cbc.c +++ b/drivers/crypto/nx/nx-aes-cbc.c @@ -126,6 +126,7 @@ struct crypto_alg nx_cbc_aes_alg = { .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct nx_crypto_ctx), .cra_type = &crypto_blkcipher_type, + .cra_alignmask = 0xf, .cra_module = THIS_MODULE, .cra_init = nx_crypto_ctx_aes_cbc_init, .cra_exit = nx_crypto_ctx_exit, diff --git a/drivers/crypto/nx/nx-aes-ecb.c b/drivers/crypto/nx/nx-aes-ecb.c index ba5f161..7bbc9a8 100644 --- a/drivers/crypto/nx/nx-aes-ecb.c +++ b/drivers/crypto/nx/nx-aes-ecb.c @@ -123,6 +123,7 @@ struct crypto_alg nx_ecb_aes_alg = { .cra_priority = 300, .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, .cra_blocksize = AES_BLOCK_SIZE, + .cra_alignmask = 0xf, .cra_ctxsize = sizeof(struct nx_crypto_ctx), .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, diff --git a/drivers/crypto/nx/nx-aes-gcm.c b/drivers/crypto/nx/nx-aes-gcm.c index c8109ed..6cca6c3 100644 --- a/drivers/crypto/nx/nx-aes-gcm.c +++ b/drivers/crypto/nx/nx-aes-gcm.c @@ -219,7 +219,7 @@ static int gcm_aes_nx_crypt(struct aead_request *req, int enc) if (enc) NX_CPB_FDM(csbcpb) |= NX_FDM_ENDE_ENCRYPT; else - nbytes -= AES_BLOCK_SIZE; + nbytes -= crypto_aead_authsize(crypto_aead_reqtfm(req)); csbcpb->cpb.aes_gcm.bit_length_data = nbytes * 8; diff --git a/drivers/crypto/nx/nx.c b/drivers/crypto/nx/nx.c index c767f23..7621d05 100644 --- a/drivers/crypto/nx/nx.c +++ b/drivers/crypto/nx/nx.c @@ -454,6 +454,8 @@ static int nx_register_algs(void) if (rc) goto out; + nx_driver.of.status = NX_OKAY; + rc = crypto_register_alg(&nx_ecb_aes_alg); if (rc) goto out; @@ -498,8 +500,6 @@ static int nx_register_algs(void) if (rc) goto out_unreg_s512; - nx_driver.of.status = NX_OKAY; - goto out; out_unreg_s512: -- 1.7.11.7 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: Fwd: [PATCH v2] drivers/crypto/nx: fix init race, alignmasks and GCM bug 2013-03-28 16:32 ` Fwd: " Kent Yoder @ 2013-03-28 18:24 ` Benjamin Herrenschmidt 2013-04-10 20:04 ` Kent Yoder 0 siblings, 1 reply; 4+ messages in thread From: Benjamin Herrenschmidt @ 2013-03-28 18:24 UTC (permalink / raw) To: Kent Yoder; +Cc: linux-kernel, linux-crypto On Thu, 2013-03-28 at 11:32 -0500, Kent Yoder wrote: > Hi Ben, will you carry this patch in the linuxppc-dev tree? I can but I'm on vacation until end of April roughly. Cheers, Ben. > Thanks, > Kent > > ---------- Forwarded message ---------- > From: Kent Yoder <shpedoikal@gmail.com> > Date: Wed, Mar 20, 2013 at 9:22 AM > Subject: [PATCH v2] drivers/crypto/nx: fix init race, alignmasks and GCM bug > To: linux-kernel@vger.kernel.org > Cc: linux-crypto@vger.kernel.org, Benjamin Herrenschmidt > <benh@kernel.crashing.org> > > > Fixes a race on driver init with registering algorithms where the > driver status flag wasn't being set before self testing started. > > Added the cra_alignmask field for CBC and ECB modes. > > Fixed a bug in GCM where AES block size was being used instead of > authsize. > > Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com> > --- > Only changes in v2 were to leave stable off the cc and add Ben for PPC. > > drivers/crypto/nx/nx-aes-cbc.c | 1 + > drivers/crypto/nx/nx-aes-ecb.c | 1 + > drivers/crypto/nx/nx-aes-gcm.c | 2 +- > drivers/crypto/nx/nx.c | 4 ++-- > 4 files changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/crypto/nx/nx-aes-cbc.c b/drivers/crypto/nx/nx-aes-cbc.c > index a76d4c4..35d483f 100644 > --- a/drivers/crypto/nx/nx-aes-cbc.c > +++ b/drivers/crypto/nx/nx-aes-cbc.c > @@ -126,6 +126,7 @@ struct crypto_alg nx_cbc_aes_alg = { > .cra_blocksize = AES_BLOCK_SIZE, > .cra_ctxsize = sizeof(struct nx_crypto_ctx), > .cra_type = &crypto_blkcipher_type, > + .cra_alignmask = 0xf, > .cra_module = THIS_MODULE, > .cra_init = nx_crypto_ctx_aes_cbc_init, > .cra_exit = nx_crypto_ctx_exit, > diff --git a/drivers/crypto/nx/nx-aes-ecb.c b/drivers/crypto/nx/nx-aes-ecb.c > index ba5f161..7bbc9a8 100644 > --- a/drivers/crypto/nx/nx-aes-ecb.c > +++ b/drivers/crypto/nx/nx-aes-ecb.c > @@ -123,6 +123,7 @@ struct crypto_alg nx_ecb_aes_alg = { > .cra_priority = 300, > .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, > .cra_blocksize = AES_BLOCK_SIZE, > + .cra_alignmask = 0xf, > .cra_ctxsize = sizeof(struct nx_crypto_ctx), > .cra_type = &crypto_blkcipher_type, > .cra_module = THIS_MODULE, > diff --git a/drivers/crypto/nx/nx-aes-gcm.c b/drivers/crypto/nx/nx-aes-gcm.c > index c8109ed..6cca6c3 100644 > --- a/drivers/crypto/nx/nx-aes-gcm.c > +++ b/drivers/crypto/nx/nx-aes-gcm.c > @@ -219,7 +219,7 @@ static int gcm_aes_nx_crypt(struct aead_request > *req, int enc) > if (enc) > NX_CPB_FDM(csbcpb) |= NX_FDM_ENDE_ENCRYPT; > else > - nbytes -= AES_BLOCK_SIZE; > + nbytes -= crypto_aead_authsize(crypto_aead_reqtfm(req)); > > csbcpb->cpb.aes_gcm.bit_length_data = nbytes * 8; > > diff --git a/drivers/crypto/nx/nx.c b/drivers/crypto/nx/nx.c > index c767f23..7621d05 100644 > --- a/drivers/crypto/nx/nx.c > +++ b/drivers/crypto/nx/nx.c > @@ -454,6 +454,8 @@ static int nx_register_algs(void) > if (rc) > goto out; > > + nx_driver.of.status = NX_OKAY; > + > rc = crypto_register_alg(&nx_ecb_aes_alg); > if (rc) > goto out; > @@ -498,8 +500,6 @@ static int nx_register_algs(void) > if (rc) > goto out_unreg_s512; > > - nx_driver.of.status = NX_OKAY; > - > goto out; > > out_unreg_s512: > -- > 1.7.11.7 > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Fwd: [PATCH v2] drivers/crypto/nx: fix init race, alignmasks and GCM bug 2013-03-28 18:24 ` Benjamin Herrenschmidt @ 2013-04-10 20:04 ` Kent Yoder 0 siblings, 0 replies; 4+ messages in thread From: Kent Yoder @ 2013-04-10 20:04 UTC (permalink / raw) To: Benjamin Herrenschmidt; +Cc: linux-kernel@vger.kernel.org, linux-crypto No problem, turns out I had a few more updates I needed to sneak into the patch anyway. Please see v3 in a new thread, applied to the ppc-dev-next tree. Thanks, Kent On Thu, Mar 28, 2013 at 1:24 PM, Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote: > On Thu, 2013-03-28 at 11:32 -0500, Kent Yoder wrote: >> Hi Ben, will you carry this patch in the linuxppc-dev tree? > > I can but I'm on vacation until end of April roughly. > > Cheers, > Ben. > >> Thanks, >> Kent >> >> ---------- Forwarded message ---------- >> From: Kent Yoder <shpedoikal@gmail.com> >> Date: Wed, Mar 20, 2013 at 9:22 AM >> Subject: [PATCH v2] drivers/crypto/nx: fix init race, alignmasks and GCM bug >> To: linux-kernel@vger.kernel.org >> Cc: linux-crypto@vger.kernel.org, Benjamin Herrenschmidt >> <benh@kernel.crashing.org> >> >> >> Fixes a race on driver init with registering algorithms where the >> driver status flag wasn't being set before self testing started. >> >> Added the cra_alignmask field for CBC and ECB modes. >> >> Fixed a bug in GCM where AES block size was being used instead of >> authsize. >> >> Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com> >> --- >> Only changes in v2 were to leave stable off the cc and add Ben for PPC. >> >> drivers/crypto/nx/nx-aes-cbc.c | 1 + >> drivers/crypto/nx/nx-aes-ecb.c | 1 + >> drivers/crypto/nx/nx-aes-gcm.c | 2 +- >> drivers/crypto/nx/nx.c | 4 ++-- >> 4 files changed, 5 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/crypto/nx/nx-aes-cbc.c b/drivers/crypto/nx/nx-aes-cbc.c >> index a76d4c4..35d483f 100644 >> --- a/drivers/crypto/nx/nx-aes-cbc.c >> +++ b/drivers/crypto/nx/nx-aes-cbc.c >> @@ -126,6 +126,7 @@ struct crypto_alg nx_cbc_aes_alg = { >> .cra_blocksize = AES_BLOCK_SIZE, >> .cra_ctxsize = sizeof(struct nx_crypto_ctx), >> .cra_type = &crypto_blkcipher_type, >> + .cra_alignmask = 0xf, >> .cra_module = THIS_MODULE, >> .cra_init = nx_crypto_ctx_aes_cbc_init, >> .cra_exit = nx_crypto_ctx_exit, >> diff --git a/drivers/crypto/nx/nx-aes-ecb.c b/drivers/crypto/nx/nx-aes-ecb.c >> index ba5f161..7bbc9a8 100644 >> --- a/drivers/crypto/nx/nx-aes-ecb.c >> +++ b/drivers/crypto/nx/nx-aes-ecb.c >> @@ -123,6 +123,7 @@ struct crypto_alg nx_ecb_aes_alg = { >> .cra_priority = 300, >> .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, >> .cra_blocksize = AES_BLOCK_SIZE, >> + .cra_alignmask = 0xf, >> .cra_ctxsize = sizeof(struct nx_crypto_ctx), >> .cra_type = &crypto_blkcipher_type, >> .cra_module = THIS_MODULE, >> diff --git a/drivers/crypto/nx/nx-aes-gcm.c b/drivers/crypto/nx/nx-aes-gcm.c >> index c8109ed..6cca6c3 100644 >> --- a/drivers/crypto/nx/nx-aes-gcm.c >> +++ b/drivers/crypto/nx/nx-aes-gcm.c >> @@ -219,7 +219,7 @@ static int gcm_aes_nx_crypt(struct aead_request >> *req, int enc) >> if (enc) >> NX_CPB_FDM(csbcpb) |= NX_FDM_ENDE_ENCRYPT; >> else >> - nbytes -= AES_BLOCK_SIZE; >> + nbytes -= crypto_aead_authsize(crypto_aead_reqtfm(req)); >> >> csbcpb->cpb.aes_gcm.bit_length_data = nbytes * 8; >> >> diff --git a/drivers/crypto/nx/nx.c b/drivers/crypto/nx/nx.c >> index c767f23..7621d05 100644 >> --- a/drivers/crypto/nx/nx.c >> +++ b/drivers/crypto/nx/nx.c >> @@ -454,6 +454,8 @@ static int nx_register_algs(void) >> if (rc) >> goto out; >> >> + nx_driver.of.status = NX_OKAY; >> + >> rc = crypto_register_alg(&nx_ecb_aes_alg); >> if (rc) >> goto out; >> @@ -498,8 +500,6 @@ static int nx_register_algs(void) >> if (rc) >> goto out_unreg_s512; >> >> - nx_driver.of.status = NX_OKAY; >> - >> goto out; >> >> out_unreg_s512: >> -- >> 1.7.11.7 >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html >> Please read the FAQ at http://www.tux.org/lkml/ > > ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-04-10 20:04 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-03-20 14:22 [PATCH v2] drivers/crypto/nx: fix init race, alignmasks and GCM bug Kent Yoder 2013-03-28 16:32 ` Fwd: " Kent Yoder 2013-03-28 18:24 ` Benjamin Herrenschmidt 2013-04-10 20:04 ` Kent Yoder
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox