From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
akhil.goyal@nxp.com, stable@dpdk.org,
Gagandeep Singh <g.singh@nxp.com>,
Hemant Agrawal <hemant.agrawal@nxp.com>,
Akhil Goyal <gakhil@marvell.com>
Subject: [PATCH 13/16] crypto/dpaa_sec: fix bitmask truncation
Date: Thu, 14 Nov 2024 22:05:50 -0800 [thread overview]
Message-ID: <20241115060738.313190-14-stephen@networkplumber.org> (raw)
In-Reply-To: <20241115060738.313190-1-stephen@networkplumber.org>
The dqrr_held mask is 64 bit but updates were getting truncated
because 1 is of type int (32 bit) and the result shift of int is of
type int (32 bit); therefore any value >= 32 would get truncated.
Link: https://pvs-studio.com/en/blog/posts/cpp/1183/
Fixes: fe3688ba7950 ("crypto/dpaa_sec: support event crypto adapter")
Cc: akhil.goyal@nxp.com
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/crypto/dpaa_sec/dpaa_sec.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index 3fa88ca968..e117cd77a6 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -1907,13 +1907,12 @@ dpaa_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops,
op = *(ops++);
if (*dpaa_seqn(op->sym->m_src) != 0) {
index = *dpaa_seqn(op->sym->m_src) - 1;
- if (DPAA_PER_LCORE_DQRR_HELD & (1 << index)) {
+ if (DPAA_PER_LCORE_DQRR_HELD & (UINT64_C(1) << index)) {
/* QM_EQCR_DCA_IDXMASK = 0x0f */
flags[loop] = ((index & 0x0f) << 8);
flags[loop] |= QMAN_ENQUEUE_FLAG_DCA;
DPAA_PER_LCORE_DQRR_SIZE--;
- DPAA_PER_LCORE_DQRR_HELD &=
- ~(1 << index);
+ DPAA_PER_LCORE_DQRR_HELD &= ~(UINT64_C(1) << index);
}
}
@@ -3500,7 +3499,7 @@ dpaa_sec_process_atomic_event(void *event,
/* Save active dqrr entries */
index = ((uintptr_t)dqrr >> 6) & (16/*QM_DQRR_SIZE*/ - 1);
DPAA_PER_LCORE_DQRR_SIZE++;
- DPAA_PER_LCORE_DQRR_HELD |= 1 << index;
+ DPAA_PER_LCORE_DQRR_HELD |= UINT64_C(1) << index;
DPAA_PER_LCORE_DQRR_MBUF(index) = ctx->op->sym->m_src;
ev->impl_opaque = index + 1;
*dpaa_seqn(ctx->op->sym->m_src) = (uint32_t)index + 1;
--
2.45.2
next prev parent reply other threads:[~2024-11-15 6:09 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-15 6:05 [PATCH 00/16] small bug fixes from PVS studio bug list Stephen Hemminger
2024-11-15 6:05 ` [PATCH 01/16] common/cnxk: remove duplicate condition Stephen Hemminger
2024-11-15 6:16 ` [EXTERNAL] " Anoob Joseph
2024-11-15 6:05 ` [PATCH 02/16] net/cpfl: avoid calling log (printf) with null Stephen Hemminger
2024-11-15 6:05 ` [PATCH 03/16] raw/cnxk_gpio: fix file descriptor leak Stephen Hemminger
2024-11-15 6:05 ` [PATCH 04/16] net/ntnic: remove dead code Stephen Hemminger
2024-11-15 6:05 ` [PATCH 05/16] net/i40e: remove duplicate code Stephen Hemminger
2024-11-15 6:05 ` [PATCH 06/16] eal: fix out of bounds access in devargs Stephen Hemminger
2024-11-15 6:05 ` [PATCH 07/16] net/qede: fix missing debug string Stephen Hemminger
2024-11-15 6:05 ` [PATCH 08/16] examples/ptpclient: replace rte_memcpy with assignment Stephen Hemminger
2024-11-15 6:05 ` [PATCH 09/16] examples/ptpclient: fix self memcmp Stephen Hemminger
2024-11-15 6:05 ` [PATCH 10/16] net/octeon_ep: remove duplicate code Stephen Hemminger
2024-11-15 6:05 ` [PATCH 11/16] net/hinic: fix flow type bitmask overflow Stephen Hemminger
2024-11-15 6:05 ` [PATCH 12/16] crypto/dpaa2_sec: fix bitmask truncation Stephen Hemminger
2024-11-15 6:05 ` Stephen Hemminger [this message]
2024-11-15 6:05 ` [PATCH 14/16] event/dpaa: " Stephen Hemminger
2024-11-15 6:05 ` [PATCH 15/16] net/dpaa: " Stephen Hemminger
2024-11-15 6:05 ` [PATCH 16/16] net/dpaa2: " Stephen Hemminger
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=20241115060738.313190-14-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=akhil.goyal@nxp.com \
--cc=dev@dpdk.org \
--cc=g.singh@nxp.com \
--cc=gakhil@marvell.com \
--cc=hemant.agrawal@nxp.com \
--cc=stable@dpdk.org \
/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).