From: bugzilla@dpdk.org
To: dev@dpdk.org
Subject: [DPDK/other Bug 1588] sched: potential issue with memcmp of padding
Date: Wed, 20 Nov 2024 23:38:42 +0000 [thread overview]
Message-ID: <bug-1588-3@http.bugs.dpdk.org/> (raw)
[-- Attachment #1: Type: text/plain, Size: 1923 bytes --]
https://bugs.dpdk.org/show_bug.cgi?id=1588
Bug ID: 1588
Summary: sched: potential issue with memcmp of padding
Product: DPDK
Version: unspecified
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: normal
Priority: Normal
Component: other
Assignee: dev@dpdk.org
Reporter: stephen@networkplumber.org
Target Milestone: ---
The tool PVS-studio flagged this code as a potential bug because of using
memcmp on a padded structure.
int
rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
uint32_t subport_id,
struct rte_sched_pipe_params *params,
uint32_t *pipe_profile_id)
{
...
/* Pipe profile should not exists */
for (i = 0; i < s->n_pipe_profiles; i++)
if (memcmp(s->pipe_profiles + i, pp, sizeof(*pp)) == 0) {
The layout of the structure reported by pahole is:
struct rte_sched_pipe_profile {
uint64_t tb_period; /* 0 8 */
uint64_t tb_credits_per_period; /* 8 8 */
uint64_t tb_size; /* 16 8 */
uint64_t tc_period; /* 24 8 */
uint64_t tc_credits_per_period[13]; /* 32 104 */
/* --- cacheline 2 boundary (128 bytes) was 8 bytes ago --- */
uint8_t tc_ov_weight; /* 136 1 */
uint8_t wrr_cost[4]; /* 137 4 */
/* size: 144, cachelines: 3, members: 7 */
/* padding: 3 */
/* last cacheline: 16 bytes */
};
So the compiler will generate code comparing the last 3 bytes which is bad.
--
You are receiving this mail because:
You are the assignee for the bug.
[-- Attachment #2: Type: text/html, Size: 3805 bytes --]
reply other threads:[~2024-11-20 23:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=bug-1588-3@http.bugs.dpdk.org/ \
--to=bugzilla@dpdk.org \
--cc=dev@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.