DPDK patches and discussions
 help / color / mirror / Atom feed
From: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] ivshmem: fix segmentation fault in corner case
Date: Thu, 18 Jun 2015 13:27:30 +0100	[thread overview]
Message-ID: <1434630450-10497-1-git-send-email-sergio.gonzalez.monroy@intel.com> (raw)

Depending on the configured segments it is possible to hit a
segmentation fault as a result of decrementing an unsigned index with
value 0.

To avoid it, exit the loop if the index has value 0.

Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
---
 lib/librte_ivshmem/rte_ivshmem.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_ivshmem/rte_ivshmem.c b/lib/librte_ivshmem/rte_ivshmem.c
index 7ca55ed..9621906 100644
--- a/lib/librte_ivshmem/rte_ivshmem.c
+++ b/lib/librte_ivshmem/rte_ivshmem.c
@@ -377,6 +377,8 @@ build_config(struct rte_ivshmem_metadata * metadata)
 			for (j = biggest_idx - 1; j >= i; j--) {
 				memcpy(&pages[j+1], &pages[j], sizeof(struct rte_memseg));
 				memset(&pages[j], 0, sizeof(struct rte_memseg));
+				if (j == 0)
+					break;
 			}
 
 			/* put old biggest segment to its new place */
-- 
1.9.3

             reply	other threads:[~2015-06-18 12:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-18 12:27 Sergio Gonzalez Monroy [this message]
2015-06-22 16:40 ` Thomas Monjalon

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=1434630450-10497-1-git-send-email-sergio.gonzalez.monroy@intel.com \
    --to=sergio.gonzalez.monroy@intel.com \
    --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 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).