DPDK patches and discussions
 help / color / mirror / Atom feed
From: Catalin Vasile <cata.vasile@nxp.com>
To: "dev@dpdk.org" <dev@dpdk.org>
Subject: [dpdk-dev] [app/test/test_cryptodev.c] setup_test_string() - buffer overflow, segfault
Date: Wed, 6 Jul 2016 09:23:21 +0000	[thread overview]
Message-ID: <DB5PR04MB1302A74963BB0F0D0DB57182EE3A0@DB5PR04MB1302.eurprd04.prod.outlook.com> (raw)

Hi,

I was trying to run cryptodev_aesni_mb_autotest with the "test" app.
I ran into an overflow which I think I debugged.
The initial symptom was at rte_mempool_lookup() called from rte_cryptodev_sym_session_pool_create(),
strncmp() went on a segfault, because "te"' 's members were NULL.
I set a watchpoint with gdb for that specific "te" memory location and it appears that it gets overwritten at memset() in setup_test_string().
If in setup_test_string() I add this code:
	struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
	int buf_len = rte_pktmbuf_data_room_size(mpool);
	size_t t_len = len - (blocksize ? (len % blocksize) : 0);


	printf("[SETUP STRING] m->buf_len = %d mpool->elt_size = %d room_size = %d\n ",
		(int) m->buf_len, (int) mpool->elt_size, buf_len);
	memset(m->buf_addr, 0, m->buf_len);
I get this output:
	[SETUP STRING] m->buf_len = 2816 mpool->elt_size = 2496 room_size = 2368

I am not very sure what should be used in that memset() (I do not know the API that well), but buf_len seems bigger then an element size from that memory pool.

If I change that memset() to plain buf_len, the tests run completely.

Cata

                 reply	other threads:[~2016-07-06  9:23 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=DB5PR04MB1302A74963BB0F0D0DB57182EE3A0@DB5PR04MB1302.eurprd04.prod.outlook.com \
    --to=cata.vasile@nxp.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).