DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jerin Jacob <jerinjacobk@gmail.com>
To: Timothy McDaniel <timothy.mcdaniel@intel.com>
Cc: Jerin Jacob <jerinj@marvell.com>,
	John McNamara <john.mcnamara@intel.com>, dpdk-dev <dev@dpdk.org>
Subject: Re: [PATCH] event/dlb2: fix invalid shift value
Date: Thu, 3 Mar 2022 14:55:19 +0530	[thread overview]
Message-ID: <CALBAE1MB=yXH-xLNr2TE6+RnFzovLF49xSG9UaLXjJ113YqVOA@mail.gmail.com> (raw)
In-Reply-To: <1646233928-4124603-1-git-send-email-timothy.mcdaniel@intel.com>

On Wed, Mar 2, 2022 at 8:42 PM Timothy McDaniel
<timothy.mcdaniel@intel.com> wrote:
>
> Add a check to ensure that all shift counts are valid.
> Shifting by more than 63 bits may result in undefined behavior, as
> noted during coverity scan.
>
> Fixes: e697f35dbdd1 ("event/dlb2: update rolling mask used for dequeue")
> Coverity issue: 376527


Applied to dpdk-next-net-eventdev/for-main. Thanks


> Signed-off-by: Timothy McDaniel <timothy.mcdaniel@intel.com>
> ---
>  drivers/event/dlb2/dlb2.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/event/dlb2/dlb2.c b/drivers/event/dlb2/dlb2.c
> index 09abdd1660..7789dd74e0 100644
> --- a/drivers/event/dlb2/dlb2.c
> +++ b/drivers/event/dlb2/dlb2.c
> @@ -3916,15 +3916,17 @@ dlb2_hw_dequeue_sparse(struct dlb2_eventdev *dlb2,
>                                                                 &events[num],
>                                                                 &qes[0],
>                                                                 num_avail);
> -                       num += n_iter;
> -                       /* update rolling_mask for vector code support */
> -                       m_rshift = qm_port->cq_rolling_mask >> n_iter;
> -                       m_lshift = qm_port->cq_rolling_mask << (64 - n_iter);
> -                       m2_rshift = qm_port->cq_rolling_mask_2 >> n_iter;
> -                       m2_lshift = qm_port->cq_rolling_mask_2 <<
> +                       if (n_iter != 0) {
> +                               num += n_iter;
> +                               /* update rolling_mask for vector code support */
> +                               m_rshift = qm_port->cq_rolling_mask >> n_iter;
> +                               m_lshift = qm_port->cq_rolling_mask << (64 - n_iter);
> +                               m2_rshift = qm_port->cq_rolling_mask_2 >> n_iter;
> +                               m2_lshift = qm_port->cq_rolling_mask_2 <<
>                                         (64 - n_iter);
> -                       qm_port->cq_rolling_mask = (m_rshift | m2_lshift);
> -                       qm_port->cq_rolling_mask_2 = (m2_rshift | m_lshift);
> +                               qm_port->cq_rolling_mask = (m_rshift | m2_lshift);
> +                               qm_port->cq_rolling_mask_2 = (m2_rshift | m_lshift);
> +                       }
>                 } else { /* !use_scalar */
>                         num_avail = dlb2_recv_qe_sparse_vec(qm_port,
>                                                             &events[num],
> --
> 2.25.1
>

      reply	other threads:[~2022-03-03  9:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-02 15:12 Timothy McDaniel
2022-03-03  9:25 ` Jerin Jacob [this message]

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='CALBAE1MB=yXH-xLNr2TE6+RnFzovLF49xSG9UaLXjJ113YqVOA@mail.gmail.com' \
    --to=jerinjacobk@gmail.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=john.mcnamara@intel.com \
    --cc=timothy.mcdaniel@intel.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).