DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] crypto/ccp: Check for the NULL pointer after calling rte_malloc
@ 2022-07-09 11:01 835703180
  2022-07-20  6:29 ` Namburu, Chandu-babu
  0 siblings, 1 reply; 6+ messages in thread
From: 835703180 @ 2022-07-09 11:01 UTC (permalink / raw)
  To: chandu; +Cc: dev, Shiqi Liu

From: Shiqi Liu <835703180@qq.com>

As the possible failure of the rte_malloc(), the not_checked and
checked could be NULL pointer.
Therefore, it should be better to check it in order to avoid
the dereference of the NULL pointer.

Fixes: 09a0fd736a0 ("crypto/ccp: enable IOMMU")
Signed-off-by: Shiqi Liu <835703180@qq.com>
---
 drivers/crypto/ccp/rte_ccp_pmd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/crypto/ccp/rte_ccp_pmd.c b/drivers/crypto/ccp/rte_ccp_pmd.c
index a35a8cd775..776f928864 100644
--- a/drivers/crypto/ccp/rte_ccp_pmd.c
+++ b/drivers/crypto/ccp/rte_ccp_pmd.c
@@ -301,6 +301,9 @@ cryptodev_ccp_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	};
 
 	sha_ctx = (void *)rte_malloc(NULL, SHA512_DIGEST_SIZE, 64);
+	if (sha_ctx == NULL) {
+		return -ENOMEM;
+	}
 	if (ccp_pmd_init_done) {
 		RTE_LOG(INFO, PMD, "CCP PMD already initialized\n");
 		return -EFAULT;
-- 
2.35.1.windows.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH] crypto/ccp: Check for the NULL pointer after calling rte_malloc
  2022-07-09 11:01 [PATCH] crypto/ccp: Check for the NULL pointer after calling rte_malloc 835703180
@ 2022-07-20  6:29 ` Namburu, Chandu-babu
  2022-07-20 13:43   ` David Marchand
  2022-07-20 15:42   ` Stephen Hemminger
  0 siblings, 2 replies; 6+ messages in thread
From: Namburu, Chandu-babu @ 2022-07-20  6:29 UTC (permalink / raw)
  To: 835703180; +Cc: dev

[Public]

Acked-by: Chandubabu Namburu <chandu@amd.com>

-----Original Message-----
From: 835703180@qq.com <835703180@qq.com> 
Sent: Saturday, July 9, 2022 4:31 PM
To: Namburu, Chandu-babu <chandu@amd.com>
Cc: dev@dpdk.org; Shiqi Liu <835703180@qq.com>
Subject: [PATCH] crypto/ccp: Check for the NULL pointer after calling rte_malloc

From: Shiqi Liu <835703180@qq.com>

As the possible failure of the rte_malloc(), the not_checked and checked could be NULL pointer.
Therefore, it should be better to check it in order to avoid the dereference of the NULL pointer.

Fixes: 09a0fd736a0 ("crypto/ccp: enable IOMMU")
Signed-off-by: Shiqi Liu <835703180@qq.com>
---
 drivers/crypto/ccp/rte_ccp_pmd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/crypto/ccp/rte_ccp_pmd.c b/drivers/crypto/ccp/rte_ccp_pmd.c
index a35a8cd775..776f928864 100644
--- a/drivers/crypto/ccp/rte_ccp_pmd.c
+++ b/drivers/crypto/ccp/rte_ccp_pmd.c
@@ -301,6 +301,9 @@ cryptodev_ccp_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	};
 
 	sha_ctx = (void *)rte_malloc(NULL, SHA512_DIGEST_SIZE, 64);
+	if (sha_ctx == NULL) {
+		return -ENOMEM;
+	}
 	if (ccp_pmd_init_done) {
 		RTE_LOG(INFO, PMD, "CCP PMD already initialized\n");
 		return -EFAULT;
--
2.35.1.windows.2

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] crypto/ccp: Check for the NULL pointer after calling rte_malloc
  2022-07-20  6:29 ` Namburu, Chandu-babu
@ 2022-07-20 13:43   ` David Marchand
  2022-08-16 16:01     ` [EXT] " Akhil Goyal
  2022-07-20 15:42   ` Stephen Hemminger
  1 sibling, 1 reply; 6+ messages in thread
From: David Marchand @ 2022-07-20 13:43 UTC (permalink / raw)
  To: Namburu, Chandu-babu; +Cc: dev, 835703180

On Wed, Jul 20, 2022 at 8:29 AM Namburu, Chandu-babu <chandu@amd.com> wrote:
> From: Shiqi Liu <835703180@qq.com>
>
> As the possible failure of the rte_malloc(), the not_checked and checked could be NULL pointer.
> Therefore, it should be better to check it in order to avoid the dereference of the NULL pointer.
>
> Fixes: 09a0fd736a0 ("crypto/ccp: enable IOMMU")
> Signed-off-by: Shiqi Liu <835703180@qq.com>

This sha_ctx variable and its accesses are suspicious.

It seems to be used as some kind of intermediate buffer, but I fail to
see the need.
Can't the existing code rely on sess->auth.ctx ?

There is also a suspicious mention (in ccp_perform_sha) of sha_ctx but
with no calling rte_mem_virt2iova().


-- 
David Marchand


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] crypto/ccp: Check for the NULL pointer after calling rte_malloc
  2022-07-20  6:29 ` Namburu, Chandu-babu
  2022-07-20 13:43   ` David Marchand
@ 2022-07-20 15:42   ` Stephen Hemminger
  1 sibling, 0 replies; 6+ messages in thread
From: Stephen Hemminger @ 2022-07-20 15:42 UTC (permalink / raw)
  To: Namburu, Chandu-babu; +Cc: 835703180, dev

On Wed, 20 Jul 2022 06:29:06 +0000
"Namburu, Chandu-babu" <chandu@amd.com> wrote:

>  	sha_ctx = (void *)rte_malloc(NULL, SHA512_DIGEST_SIZE, 64);
> +	if (sha_ctx == NULL) {
> +		return -ENOMEM;
> +	}

There is unnecessary cast here (pre-existing).

rte_malloc() already returns void *

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [EXT] Re: [PATCH] crypto/ccp: Check for the NULL pointer after calling rte_malloc
  2022-07-20 13:43   ` David Marchand
@ 2022-08-16 16:01     ` Akhil Goyal
  2022-08-23  6:14       ` Namburu, Chandu-babu
  0 siblings, 1 reply; 6+ messages in thread
From: Akhil Goyal @ 2022-08-16 16:01 UTC (permalink / raw)
  To: Namburu, Chandu-babu, 835703180; +Cc: dev, David Marchand

Hi,
Could you please reply to David and Stephen's comments?

Regards,
Akhil
> On Wed, Jul 20, 2022 at 8:29 AM Namburu, Chandu-babu <chandu@amd.com>
> wrote:
> > From: Shiqi Liu <835703180@qq.com>
> >
> > As the possible failure of the rte_malloc(), the not_checked and checked could
> be NULL pointer.
> > Therefore, it should be better to check it in order to avoid the dereference of
> the NULL pointer.
> >
> > Fixes: 09a0fd736a0 ("crypto/ccp: enable IOMMU")
> > Signed-off-by: Shiqi Liu <835703180@qq.com>
> 
> This sha_ctx variable and its accesses are suspicious.
> 
> It seems to be used as some kind of intermediate buffer, but I fail to
> see the need.
> Can't the existing code rely on sess->auth.ctx ?
> 
> There is also a suspicious mention (in ccp_perform_sha) of sha_ctx but
> with no calling rte_mem_virt2iova().
> 
> 
> --
> David Marchand


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [EXT] Re: [PATCH] crypto/ccp: Check for the NULL pointer after calling rte_malloc
  2022-08-16 16:01     ` [EXT] " Akhil Goyal
@ 2022-08-23  6:14       ` Namburu, Chandu-babu
  0 siblings, 0 replies; 6+ messages in thread
From: Namburu, Chandu-babu @ 2022-08-23  6:14 UTC (permalink / raw)
  To: Akhil Goyal, 835703180, Uttarwar, Sunil Prakashrao; +Cc: dev, David Marchand

[Public]

+ sunil

-----Original Message-----
From: Akhil Goyal <gakhil@marvell.com> 
Sent: Tuesday, August 16, 2022 9:31 PM
To: Namburu, Chandu-babu <chandu@amd.com>; 835703180@qq.com
Cc: dev@dpdk.org; David Marchand <david.marchand@redhat.com>
Subject: RE: [EXT] Re: [PATCH] crypto/ccp: Check for the NULL pointer after calling rte_malloc

Hi,
Could you please reply to David and Stephen's comments?

Regards,
Akhil
> On Wed, Jul 20, 2022 at 8:29 AM Namburu, Chandu-babu <chandu@amd.com>
> wrote:
> > From: Shiqi Liu <835703180@qq.com>
> >
> > As the possible failure of the rte_malloc(), the not_checked and 
> > checked could
> be NULL pointer.
> > Therefore, it should be better to check it in order to avoid the 
> > dereference of
> the NULL pointer.
> >
> > Fixes: 09a0fd736a0 ("crypto/ccp: enable IOMMU")
> > Signed-off-by: Shiqi Liu <835703180@qq.com>
> 
> This sha_ctx variable and its accesses are suspicious.
> 
> It seems to be used as some kind of intermediate buffer, but I fail to 
> see the need.
> Can't the existing code rely on sess->auth.ctx ?
> 
> There is also a suspicious mention (in ccp_perform_sha) of sha_ctx but 
> with no calling rte_mem_virt2iova().
> 
> 
> --
> David Marchand

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-08-23  6:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-09 11:01 [PATCH] crypto/ccp: Check for the NULL pointer after calling rte_malloc 835703180
2022-07-20  6:29 ` Namburu, Chandu-babu
2022-07-20 13:43   ` David Marchand
2022-08-16 16:01     ` [EXT] " Akhil Goyal
2022-08-23  6:14       ` Namburu, Chandu-babu
2022-07-20 15:42   ` Stephen Hemminger

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).