[DPDK/other Bug 1588] sched: potential issue with memcmp of padding
bugzilla at dpdk.org
bugzilla at dpdk.org
Thu Nov 21 00:38:42 CET 2024
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 at dpdk.org
Reporter: stephen at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mails.dpdk.org/archives/dev/attachments/20241120/956639fa/attachment.htm>
More information about the dev
mailing list