DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: "Venkatesan, Venky" <venky.venkatesan@intel.com>
Cc: dev@dpdk.org, Stephen Hemminger <shemming@brocade.com>
Subject: [dpdk-dev] [PATCH 6/6] ivshmem: fix errors identified by hardening
Date: Fri, 07 Mar 2014 10:13:41 -0800	[thread overview]
Message-ID: <20140307181432.206702017@vyatta.com> (raw)
In-Reply-To: <20140307181335.024904493@vyatta.com>

[-- Attachment #1: ivshmem-fortify.patch --]
[-- Type: text/plain, Size: 1076 bytes --]

Need to pass mode argument to open with O_CREAT.
Must check return value from ftruncate().

Signed-off-by: Stephen Hemminger <shemming@brocade.com>

diff --git a/lib/librte_eal/linuxapp/eal/eal_ivshmem.c b/lib/librte_eal/linuxapp/eal/eal_ivshmem.c
index 6191fef..5f64873 100644
--- a/lib/librte_eal/linuxapp/eal/eal_ivshmem.c
+++ b/lib/librte_eal/linuxapp/eal/eal_ivshmem.c
@@ -472,7 +472,7 @@ create_shared_config(void)
 	rte_snprintf(path, sizeof(path), IVSHMEM_CONFIG_PATH,
 			internal_config.hugefile_prefix);
 
-	fd = open(path, O_CREAT | O_RDWR);
+	fd = open(path, O_CREAT | O_RDWR, 0600);
 
 	if (fd < 0) {
 		RTE_LOG(ERR, EAL, "Could not open %s: %s\n", path, strerror(errno));
@@ -486,7 +486,10 @@ create_shared_config(void)
 		return -1;
 	}
 
-	ftruncate(fd, sizeof(struct ivshmem_shared_config));
+	if (ftruncate(fd, sizeof(struct ivshmem_shared_config)) < 0) {
+		RTE_LOG(ERR, EAL, "ftruncate failed: %s\n", strerror(errno));
+		return -1;
+	}
 
 	ivshmem_config = mmap(NULL, sizeof(struct ivshmem_shared_config),
 			PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);

  parent reply	other threads:[~2014-03-07 18:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-07 18:13 [dpdk-dev] [PATCH 0/6] DPDK 1.6.1 fixes Stephen Hemminger
2014-03-07 18:13 ` [dpdk-dev] [PATCH 1/6] rte_mbuf: copy offload flags when doing attach/clone of mbuf Stephen Hemminger
2014-03-24 18:21   ` Thomas Monjalon
2014-03-07 18:13 ` [dpdk-dev] [PATCH 2/6] qos: use rte_zmalloc instead of memzone for allocation Stephen Hemminger
2014-03-24 18:30   ` Thomas Monjalon
2014-03-07 18:13 ` [dpdk-dev] [PATCH 3/6] rte_jhash: make arg to rte_jhash2 const Stephen Hemminger
2014-03-24 18:22   ` Thomas Monjalon
2014-03-07 18:13 ` [dpdk-dev] [PATCH 4/6] mempool: use GCC push/pop Stephen Hemminger
2014-03-24 18:23   ` Thomas Monjalon
2014-03-07 18:13 ` [dpdk-dev] [PATCH 5/6] xen: dont create dependency on cmdline library Stephen Hemminger
2014-03-24 21:01   ` Thomas Monjalon
2014-03-07 18:13 ` Stephen Hemminger [this message]
2014-04-17 13:51   ` [dpdk-dev] [PATCH 6/6] ivshmem: fix errors identified by hardening 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=20140307181432.206702017@vyatta.com \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=shemming@brocade.com \
    --cc=venky.venkatesan@intel.com \
    /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).