From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f41.google.com (mail-pa0-f41.google.com [209.85.220.41]) by dpdk.org (Postfix) with ESMTP id B3F9C6882 for ; Fri, 7 Mar 2014 19:13:05 +0100 (CET) Received: by mail-pa0-f41.google.com with SMTP id fa1so4522684pad.0 for ; Fri, 07 Mar 2014 10:14:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:user-agent:date:from:to:cc:subject :references:content-disposition; bh=ukGgRObXAtFKMdsAQrN5r9tLUD+NQ/ZAYb/OKJanPcU=; b=Ql2Y/j/pOVr5Tfbac0WPZNlxVj/NOvODPrRjnlfxZRXWYNaCxPptwS5TXTkJeqNSnz xg7p8H6TCWUy1jj4bXw5ytUPbWMD7btZ55hw0Z6tPd4L9ZpznFTENxgk8OinNWM/dqXn qjS44wWFs/b0p43YqLy3vamB5drD8BmdRTUwj/sLd2O1V6Y6Ndhkxra6OtzwSKXHEpQh dAHwMtFGUKCMpkpP1Sv0gws1dCy3nIE4674B98EUx2bqIqaxWRLxC/LqJWWlFLpU8zYM 98+pptngzw3RKLieObEa+5jMOMhUG9sAm5nhvFM1P1E0dF1BJMrKIlRw8ST5pJ6cczj6 EB8g== X-Gm-Message-State: ALoCoQnCa0ROuSJiZkXNc4uCT9RHF3//kAX9c1obZp46trAS2Wradh6K1fMXK9zfiLSX4M7rqbSk X-Received: by 10.68.247.201 with SMTP id yg9mr23985872pbc.148.1394216074239; Fri, 07 Mar 2014 10:14:34 -0800 (PST) Received: from localhost (static-50-53-83-51.bvtn.or.frontiernet.net. [50.53.83.51]) by mx.google.com with ESMTPSA id oz7sm39895006pbc.41.2014.03.07.10.14.32 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 07 Mar 2014 10:14:33 -0800 (PST) Message-Id: <20140307181432.206702017@vyatta.com> User-Agent: quilt/0.60-1 Date: Fri, 07 Mar 2014 10:13:41 -0800 From: Stephen Hemminger To: "Venkatesan, Venky" References: <20140307181335.024904493@vyatta.com> Content-Disposition: inline; filename=ivshmem-fortify.patch Cc: dev@dpdk.org, Stephen Hemminger Subject: [dpdk-dev] [PATCH 6/6] ivshmem: fix errors identified by hardening X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Mar 2014 18:13:06 -0000 Need to pass mode argument to open with O_CREAT. Must check return value from ftruncate(). Signed-off-by: Stephen Hemminger 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);