* [PATCH] crypto: octeontx2: fix NULL pointer dereference
@ 2022-01-21 14:03 Shijith Thotton
2022-01-21 17:43 ` [PATCH v2] " Shijith Thotton
0 siblings, 1 reply; 6+ messages in thread
From: Shijith Thotton @ 2022-01-21 14:03 UTC (permalink / raw)
To: Arnaud Ebalard, Herbert Xu, Boris Brezillon
Cc: Shijith Thotton, linux-crypto, jerinj, sgoutham, Srujana Challa,
David S. Miller, Lukasz Bartosik, Suheil Chandran, chiminghao,
Ovidiu Panait, open list
CONFIG_DM_CRYPT is checked before registering ciphers, but not before
unregister. This could lead to a NULL pointer dereference during driver
release (in unregister) if CONFIG_DM_CRYPT is enabled.
...
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008
...
Call trace:
crypto_unregister_alg+0x68/0xfc
crypto_unregister_skciphers+0x44/0x60
otx2_cpt_crypto_exit+0x100/0x1a0
otx2_cptvf_remove+0xf8/0x200
pci_device_remove+0x3c/0xd4
__device_release_driver+0x188/0x234
device_release_driver+0x2c/0x4c
...
Added a CONFIG_DM_CRYPT check, similar to register, in unregister to
avoid this.
Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c b/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
index 2748a3327e39..620fa9b23e78 100644
--- a/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
+++ b/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
@@ -1650,7 +1650,7 @@ static inline int cpt_register_algs(void)
err = crypto_register_aeads(otx2_cpt_aeads,
ARRAY_SIZE(otx2_cpt_aeads));
- if (err) {
+ if (err && !IS_ENABLED(CONFIG_DM_CRYPT)) {
crypto_unregister_skciphers(otx2_cpt_skciphers,
ARRAY_SIZE(otx2_cpt_skciphers));
return err;
@@ -1661,8 +1661,9 @@ static inline int cpt_register_algs(void)
static inline void cpt_unregister_algs(void)
{
- crypto_unregister_skciphers(otx2_cpt_skciphers,
- ARRAY_SIZE(otx2_cpt_skciphers));
+ if (!IS_ENABLED(CONFIG_DM_CRYPT))
+ crypto_unregister_skciphers(otx2_cpt_skciphers,
+ ARRAY_SIZE(otx2_cpt_skciphers));
crypto_unregister_aeads(otx2_cpt_aeads, ARRAY_SIZE(otx2_cpt_aeads));
}
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2] crypto: octeontx2: fix NULL pointer dereference
2022-01-21 14:03 [PATCH] crypto: octeontx2: fix NULL pointer dereference Shijith Thotton
@ 2022-01-21 17:43 ` Shijith Thotton
2022-01-28 5:43 ` Herbert Xu
2022-01-28 13:57 ` [PATCH v3] crypto: octeontx2: remove CONFIG_DM_CRYPT check Shijith Thotton
0 siblings, 2 replies; 6+ messages in thread
From: Shijith Thotton @ 2022-01-21 17:43 UTC (permalink / raw)
To: Arnaud Ebalard, Herbert Xu, Boris Brezillon
Cc: Shijith Thotton, linux-crypto, jerinj, sgoutham, Srujana Challa,
David S. Miller, chiminghao, Ovidiu Panait, Suheil Chandran,
Lukasz Bartosik, open list
CONFIG_DM_CRYPT is checked before registering ciphers, but not before
unregister. This could lead to a NULL pointer dereference during driver
release (in unregister) if CONFIG_DM_CRYPT is enabled.
...
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008
...
Call trace:
crypto_unregister_alg+0x68/0xfc
crypto_unregister_skciphers+0x44/0x60
otx2_cpt_crypto_exit+0x100/0x1a0
otx2_cptvf_remove+0xf8/0x200
pci_device_remove+0x3c/0xd4
__device_release_driver+0x188/0x234
device_release_driver+0x2c/0x4c
...
Added a CONFIG_DM_CRYPT check, similar to register, in unregister to
avoid this.
Fixes: 6f03f0e8b6c8 ("crypto: octeontx2 - register with linux crypto framework")
Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
v2:
- Added fixes line to commit message.
drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c b/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
index 2748a3327e39..620fa9b23e78 100644
--- a/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
+++ b/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
@@ -1650,7 +1650,7 @@ static inline int cpt_register_algs(void)
err = crypto_register_aeads(otx2_cpt_aeads,
ARRAY_SIZE(otx2_cpt_aeads));
- if (err) {
+ if (err && !IS_ENABLED(CONFIG_DM_CRYPT)) {
crypto_unregister_skciphers(otx2_cpt_skciphers,
ARRAY_SIZE(otx2_cpt_skciphers));
return err;
@@ -1661,8 +1661,9 @@ static inline int cpt_register_algs(void)
static inline void cpt_unregister_algs(void)
{
- crypto_unregister_skciphers(otx2_cpt_skciphers,
- ARRAY_SIZE(otx2_cpt_skciphers));
+ if (!IS_ENABLED(CONFIG_DM_CRYPT))
+ crypto_unregister_skciphers(otx2_cpt_skciphers,
+ ARRAY_SIZE(otx2_cpt_skciphers));
crypto_unregister_aeads(otx2_cpt_aeads, ARRAY_SIZE(otx2_cpt_aeads));
}
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] crypto: octeontx2: fix NULL pointer dereference
2022-01-21 17:43 ` [PATCH v2] " Shijith Thotton
@ 2022-01-28 5:43 ` Herbert Xu
2022-01-28 11:19 ` [EXT] " Shijith Thotton
2022-01-28 13:57 ` [PATCH v3] crypto: octeontx2: remove CONFIG_DM_CRYPT check Shijith Thotton
1 sibling, 1 reply; 6+ messages in thread
From: Herbert Xu @ 2022-01-28 5:43 UTC (permalink / raw)
To: Shijith Thotton
Cc: arno, bbrezillon, sthotton, linux-crypto, jerinj, sgoutham,
schalla, davem, chi.minghao, ovidiu.panait, schandran, lbartosik,
linux-kernel
Shijith Thotton <sthotton@marvell.com> wrote:
>
> diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c b/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
> index 2748a3327e39..620fa9b23e78 100644
> --- a/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
> +++ b/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
> @@ -1650,7 +1650,7 @@ static inline int cpt_register_algs(void)
>
> err = crypto_register_aeads(otx2_cpt_aeads,
> ARRAY_SIZE(otx2_cpt_aeads));
> - if (err) {
> + if (err && !IS_ENABLED(CONFIG_DM_CRYPT)) {
> crypto_unregister_skciphers(otx2_cpt_skciphers,
> ARRAY_SIZE(otx2_cpt_skciphers));
> return err;
A better fix would be to make the driver actually work with
dm-crypt. What exactly is the issue?
Even if we have to keep the kludge, please move this into Kconfig
as a dependency and simply disable the whole driver.
Thanks,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [EXT] Re: [PATCH v2] crypto: octeontx2: fix NULL pointer dereference
2022-01-28 5:43 ` Herbert Xu
@ 2022-01-28 11:19 ` Shijith Thotton
0 siblings, 0 replies; 6+ messages in thread
From: Shijith Thotton @ 2022-01-28 11:19 UTC (permalink / raw)
To: Herbert Xu
Cc: arno, bbrezillon, linux-crypto, Jerin Jacob Kollanukkaran,
Sunil Kovvuri Goutham, Srujana Challa, davem, chi.minghao,
ovidiu.panait, Suheil Chandran, Lukas Bartosik [C],
linux-kernel
>> diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
>b/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
>> index 2748a3327e39..620fa9b23e78 100644
>> --- a/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
>> +++ b/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
>> @@ -1650,7 +1650,7 @@ static inline int cpt_register_algs(void)
>>
>> err = crypto_register_aeads(otx2_cpt_aeads,
>> ARRAY_SIZE(otx2_cpt_aeads));
>> - if (err) {
>> + if (err && !IS_ENABLED(CONFIG_DM_CRYPT)) {
>> crypto_unregister_skciphers(otx2_cpt_skciphers,
>> ARRAY_SIZE(otx2_cpt_skciphers));
>> return err;
>
>A better fix would be to make the driver actually work with
>dm-crypt. What exactly is the issue?
>
>Even if we have to keep the kludge, please move this into Kconfig
>as a dependency and simply disable the whole driver.
>
I have tested the latest driver with dm-crypt and found no issues.
I will send next version without the checks.
Thanks,
Shijith
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3] crypto: octeontx2: remove CONFIG_DM_CRYPT check
2022-01-21 17:43 ` [PATCH v2] " Shijith Thotton
2022-01-28 5:43 ` Herbert Xu
@ 2022-01-28 13:57 ` Shijith Thotton
2022-02-05 4:32 ` Herbert Xu
1 sibling, 1 reply; 6+ messages in thread
From: Shijith Thotton @ 2022-01-28 13:57 UTC (permalink / raw)
To: Arnaud Ebalard, Herbert Xu, Boris Brezillon
Cc: Shijith Thotton, linux-crypto, jerinj, sgoutham, anoobj,
Srujana Challa, David S. Miller, Ovidiu Panait, chiminghao,
Suheil Chandran, Lukasz Bartosik, open list
No issues were found while using the driver with dm-crypt enabled. So
CONFIG_DM_CRYPT check in the driver can be removed.
This also fixes the NULL pointer dereference in driver release if
CONFIG_DM_CRYPT is enabled.
...
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008
...
Call trace:
crypto_unregister_alg+0x68/0xfc
crypto_unregister_skciphers+0x44/0x60
otx2_cpt_crypto_exit+0x100/0x1a0
otx2_cptvf_remove+0xf8/0x200
pci_device_remove+0x3c/0xd4
__device_release_driver+0x188/0x234
device_release_driver+0x2c/0x4c
...
Fixes: 6f03f0e8b6c8 ("crypto: octeontx2 - register with linux crypto framework")
Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
.../crypto/marvell/octeontx2/otx2_cptvf_algs.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c b/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
index 2748a3327e39..f8f8542ce3e4 100644
--- a/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
+++ b/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c
@@ -1634,16 +1634,13 @@ static inline int cpt_register_algs(void)
{
int i, err = 0;
- if (!IS_ENABLED(CONFIG_DM_CRYPT)) {
- for (i = 0; i < ARRAY_SIZE(otx2_cpt_skciphers); i++)
- otx2_cpt_skciphers[i].base.cra_flags &=
- ~CRYPTO_ALG_DEAD;
-
- err = crypto_register_skciphers(otx2_cpt_skciphers,
- ARRAY_SIZE(otx2_cpt_skciphers));
- if (err)
- return err;
- }
+ for (i = 0; i < ARRAY_SIZE(otx2_cpt_skciphers); i++)
+ otx2_cpt_skciphers[i].base.cra_flags &= ~CRYPTO_ALG_DEAD;
+
+ err = crypto_register_skciphers(otx2_cpt_skciphers,
+ ARRAY_SIZE(otx2_cpt_skciphers));
+ if (err)
+ return err;
for (i = 0; i < ARRAY_SIZE(otx2_cpt_aeads); i++)
otx2_cpt_aeads[i].base.cra_flags &= ~CRYPTO_ALG_DEAD;
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3] crypto: octeontx2: remove CONFIG_DM_CRYPT check
2022-01-28 13:57 ` [PATCH v3] crypto: octeontx2: remove CONFIG_DM_CRYPT check Shijith Thotton
@ 2022-02-05 4:32 ` Herbert Xu
0 siblings, 0 replies; 6+ messages in thread
From: Herbert Xu @ 2022-02-05 4:32 UTC (permalink / raw)
To: Shijith Thotton
Cc: Arnaud Ebalard, Boris Brezillon, linux-crypto, jerinj, sgoutham,
anoobj, Srujana Challa, David S. Miller, Ovidiu Panait,
chiminghao, Suheil Chandran, Lukasz Bartosik, open list
On Fri, Jan 28, 2022 at 07:27:42PM +0530, Shijith Thotton wrote:
> No issues were found while using the driver with dm-crypt enabled. So
> CONFIG_DM_CRYPT check in the driver can be removed.
>
> This also fixes the NULL pointer dereference in driver release if
> CONFIG_DM_CRYPT is enabled.
>
> ...
> Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008
> ...
> Call trace:
> crypto_unregister_alg+0x68/0xfc
> crypto_unregister_skciphers+0x44/0x60
> otx2_cpt_crypto_exit+0x100/0x1a0
> otx2_cptvf_remove+0xf8/0x200
> pci_device_remove+0x3c/0xd4
> __device_release_driver+0x188/0x234
> device_release_driver+0x2c/0x4c
> ...
>
> Fixes: 6f03f0e8b6c8 ("crypto: octeontx2 - register with linux crypto framework")
> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> ---
> .../crypto/marvell/octeontx2/otx2_cptvf_algs.c | 17 +++++++----------
> 1 file changed, 7 insertions(+), 10 deletions(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-02-05 4:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-21 14:03 [PATCH] crypto: octeontx2: fix NULL pointer dereference Shijith Thotton
2022-01-21 17:43 ` [PATCH v2] " Shijith Thotton
2022-01-28 5:43 ` Herbert Xu
2022-01-28 11:19 ` [EXT] " Shijith Thotton
2022-01-28 13:57 ` [PATCH v3] crypto: octeontx2: remove CONFIG_DM_CRYPT check Shijith Thotton
2022-02-05 4:32 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).