DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Dumitrescu, Cristian" <cristian.dumitrescu@intel.com>
To: "Simon Kågström" <simon.kagstrom@netinsight.net>,
	"dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] Unsafe array accesses in rte_sched.c
Date: Fri, 16 Oct 2015 13:39:39 +0000	[thread overview]
Message-ID: <3EB4FA525960D640B5BDFFD6A3D89126478F0C50@IRSMSX108.ger.corp.intel.com> (raw)
In-Reply-To: <5620BA12.9060702@netinsight.net>



> -----Original Message-----
> From: Simon Kågström [mailto:simon.kagstrom@netinsight.net]
> Sent: Friday, October 16, 2015 9:49 AM
> To: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>; dev@dpdk.org
> Subject: Unsafe array accesses in rte_sched.c
> 
> Hi!
> 
> I'm investigating DPDK support for pacing output streams and trying to
> understand the QoS framework. However, I quickly found some instances of
> unsafe array accesses. E.g., the rte_sched_port_config_qsize function
> looks like this:
> 
>   static void
>   rte_sched_port_config_qsize(struct rte_sched_port *port)
>   {
>         /* TC 0 */
>         port->qsize_add[0] = 0;
>         port->qsize_add[1] = port->qsize_add[0] + port->qsize[0];
>         port->qsize_add[2] = port->qsize_add[1] + port->qsize[0];
>         port->qsize_add[3] = port->qsize_add[2] + port->qsize[0];
> 
>   [...]
> 
>         /* TC 3 */
>         port->qsize_add[12] = port->qsize_add[11] + port->qsize[2];
>         port->qsize_add[13] = port->qsize_add[12] + port->qsize[3];
>         port->qsize_add[14] = port->qsize_add[13] + port->qsize[3];
>         port->qsize_add[15] = port->qsize_add[14] + port->qsize[3];
> 
>         port->qsize_sum = port->qsize_add[15] + port->qsize[3];
>   }
> 
> but port->qsize is actually defined as
> 
>   uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> 

Not sure what you see "unsafe" here: qsize is an array of 4 elements, while qsize_add is a different array of 16 elements? Please explain.

> There are similar problems in rte_sched_port_log_pipe_profile() and
> probably other places.
> 
> 
> I don't understand the code well enough to send patches for these,
> although the fixes should be fairly trivial. Perhaps this is already
> known as it should be fairly easy to trigger with static checkers?
> 
> // Simon


  reply	other threads:[~2015-10-16 13:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-16  8:49 Simon Kågström
2015-10-16 13:39 ` Dumitrescu, Cristian [this message]
2015-10-16 13:50   ` Simon Kågström
2015-10-16 16:10     ` 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=3EB4FA525960D640B5BDFFD6A3D89126478F0C50@IRSMSX108.ger.corp.intel.com \
    --to=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    --cc=simon.kagstrom@netinsight.net \
    /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).