DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Chautru, Nicolas" <nicolas.chautru@intel.com>
To: Maxime Coquelin <maxime.coquelin@redhat.com>,
	"Vargas, Hernan" <hernan.vargas@intel.com>,
	"dev@dpdk.org" <dev@dpdk.org>,
	"gakhil@marvell.com" <gakhil@marvell.com>,
	"trix@redhat.com" <trix@redhat.com>
Cc: "Zhang, Qi Z" <qi.z.zhang@intel.com>
Subject: RE: [PATCH v1 1/1] baseband/acc: fix check after deref and dead code
Date: Tue, 8 Nov 2022 18:00:12 +0000	[thread overview]
Message-ID: <BY5PR11MB4451E679E8055400B5BB886DF83F9@BY5PR11MB4451.namprd11.prod.outlook.com> (raw)
In-Reply-To: <BY5PR11MB445134D09D35B0A95992256DF83B9@BY5PR11MB4451.namprd11.prod.outlook.com>

Hi Maxime, Akhil, 
This patch is not applied yet.
Any concern to apply this as is?
Maxime, unclear whether you recommend a change for this in the context of the coverify fix. Please kindly clarify. Do you want to keep the q == null in the PMD? 
Thanks
Nic

> -----Original Message-----
> From: Chautru, Nicolas
> Sent: Friday, November 4, 2022 10:39 AM
> To: Maxime Coquelin <maxime.coquelin@redhat.com>; Vargas, Hernan
> <Hernan.Vargas@intel.com>; dev@dpdk.org; gakhil@marvell.com;
> trix@redhat.com
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>
> Subject: RE: [PATCH v1 1/1] baseband/acc: fix check after deref and dead code
> 
> Hi Maxime,
> 
> > -----Original Message-----
> > From: Maxime Coquelin <maxime.coquelin@redhat.com>
> > Sent: Friday, November 4, 2022 1:52 AM
> > To: Vargas, Hernan <hernan.vargas@intel.com>; dev@dpdk.org;
> > gakhil@marvell.com; trix@redhat.com
> > Cc: Chautru, Nicolas <nicolas.chautru@intel.com>; Zhang, Qi Z
> > <qi.z.zhang@intel.com>
> > Subject: Re: [PATCH v1 1/1] baseband/acc: fix check after deref and
> > dead code
> >
> >
> >
> > On 11/4/22 04:52, Hernan Vargas wrote:
> > > Fix potential issue of dereferencing a pointer before null check.
> > > Remove null check for value that could never be null.
> > >
> > > Coverity issue: 381646, 381631
> > > Fixes: 989dec301a9 ("baseband/acc100: add ring companion address")
> > >
> > > Signed-off-by: Hernan Vargas <hernan.vargas@intel.com>
> > > ---
> > >   drivers/baseband/acc/rte_acc100_pmd.c | 4 ----
> > >   1 file changed, 4 deletions(-)
> > >
> > > diff --git a/drivers/baseband/acc/rte_acc100_pmd.c
> > > b/drivers/baseband/acc/rte_acc100_pmd.c
> > > index 96daef87bc..30a718916d 100644
> > > --- a/drivers/baseband/acc/rte_acc100_pmd.c
> > > +++ b/drivers/baseband/acc/rte_acc100_pmd.c
> > > @@ -4122,15 +4122,11 @@ acc100_dequeue_ldpc_enc(struct
> > rte_bbdev_queue_data *q_data,
> > >   	struct rte_bbdev_enc_op *op;
> > >   	union acc_dma_desc *desc;
> > >
> > > -	if (q == NULL)
> > > -		return 0;
> >
> > Can we be sure it can never be NULL?
> >
> > static inline uint16_t
> > rte_bbdev_dequeue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
> > 		struct rte_bbdev_enc_op **ops, uint16_t num_ops) {
> > 	struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
> > 	struct rte_bbdev_queue_data *q_data = &dev->data-
> > >queues[queue_id];
> > 	return dev->dequeue_ldpc_enc_ops(q_data, ops, num_ops); }
> >
> > If the application passes an invalid queue_id or dev_id you can easily
> > get garbage.
> >
> > It may be worth adding some checks in all the helpers, to be sure
> > dev_id is valid, and same for queue_id. We do that in Vhost library to
> > improve robustness.
> >
> > I know there is this comment:
> > "
> >   * This function does not provide any error notification to avoid the
> >   * corresponding overhead.
> > "
> >
> > But to me this is not a good justification, the overhead would be minimal.
> >
> 
> Thanks.
> The rational is that this function needs to be very lightweight since this is a
> called in loop and hence this is was captured explicitly in bbdev.
> More generally I don’t believe that a change to bbdev would be relevant in that
> ticket, ok to move that discussion for later on in any case?
> 
> This ticket is purely about a Coverity fix for the ACC100 PMD. Note that we
> don’t check for q null during dequeue in most baseband PMD (including both
> intel and non-intel ones), this one was not required either, only historical.
> Does that sound fair in the context of that Coverity fix?
> Thanks
> Nic
> 
> 
> > Regards,
> > Maxime
> >
> > >   #ifdef RTE_LIBRTE_BBDEV_DEBUG
> > >   	if (unlikely(ops == 0))
> > >   		return 0;
> > >   #endif
> > >   	desc = q->ring_addr + (q->sw_ring_tail & q->sw_ring_wrap_mask);
> > > -	if (unlikely(desc == NULL))
> > > -		return 0;
> > >   	op = desc->req.op_addr;
> > >   	if (unlikely(ops == NULL || op == NULL))
> > >   		return 0;


  reply	other threads:[~2022-11-08 18:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-04  3:52 [PATCH v1 0/1] baseband/acc: coverity fix RC2 Hernan Vargas
2022-11-04  3:52 ` [PATCH v1 1/1] baseband/acc: fix check after deref and dead code Hernan Vargas
2022-11-04  8:51   ` Maxime Coquelin
2022-11-04 17:39     ` Chautru, Nicolas
2022-11-08 18:00       ` Chautru, Nicolas [this message]
2022-11-10  9:48   ` David Marchand
2022-11-10 21:15     ` Chautru, Nicolas
2022-11-15 15:17       ` Chautru, Nicolas
2022-11-15 15:59       ` David Marchand
2022-11-15 18:04         ` Chautru, Nicolas
2022-11-15 22:32           ` Chautru, Nicolas
2023-01-20 20:55 [PATCH v1 0/1] DPDK Coverity issue 381631, 381646 Hernan Vargas
2023-01-20 20:55 ` [PATCH v1 1/1] baseband/acc: fix check after deref and dead code Hernan Vargas
2023-02-06 15:22   ` Maxime Coquelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BY5PR11MB4451E679E8055400B5BB886DF83F9@BY5PR11MB4451.namprd11.prod.outlook.com \
    --to=nicolas.chautru@intel.com \
    --cc=dev@dpdk.org \
    --cc=gakhil@marvell.com \
    --cc=hernan.vargas@intel.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=qi.z.zhang@intel.com \
    --cc=trix@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).