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: