From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f173.google.com (mail-pf0-f173.google.com [209.85.192.173]) by dpdk.org (Postfix) with ESMTP id E333E4CE4 for ; Wed, 31 May 2017 17:19:38 +0200 (CEST) Received: by mail-pf0-f173.google.com with SMTP id 9so12082607pfj.1 for ; Wed, 31 May 2017 08:19:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/CmaINpXyjRsooU5yAeEZRnu83KpXJkcvPbX8ADT2UY=; b=N5YGXScGJWVWtuNZmAOaRkm71kCrzE+Y8eSMg+qSd+MMBe8U033GeXngVnKN67vL1x yy9rYGZrSI0hPEJudYc6h5RdcATQb6Ir54I+XAZ5SOnmWZ/jyAurvySzvzwekwDv00UG OC5cJbsT4WoKKa3rDcZQ1Ga4i7UhQ8x9ziDChwSbkZGOtDGXfjmwebFN4jFOKYfTpZIU BLJcyaxRo4sD0J4eCtOR9qcEQ4u/qXxSKdxJ+1R5DObYJMN9b/3QWfbC1oyzDQ1US/hW 845H1/drsPRjoiVd0JvGREydjd9y3iWhzK9a0MtbpDHYnAws9Pjs9h+CHPCkK8aU8EVM l9Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/CmaINpXyjRsooU5yAeEZRnu83KpXJkcvPbX8ADT2UY=; b=Ltu48K3S8T/hkd0ABJFMBKNkpSpPocet+t6Lu10mSm4afXZ/tMCKkoC67FsOHvi3Kn KyiXUcyWg/K9EkF5lqdt3ZeosQhgxD4Z3wwpXg4ZCD/kZolYiG4SfRnClAxB+By76H8g lOZNIdgYfMScPaOz34wAlbvczyvdx9p33glMmGric6Y/U48jSyRp4HAceMxtUUz3xkS0 i7DhEzrwcIyUUgLaTkYPO599gz20nT2zbYzo9fi55+IlNrSH9wtBCw6lrTywuKqWQoTR 7eio96op8bOmgc/icwwIJhnM7vwCh5uKygm8TCXl7FXLHB8GedAHoZRa24DWmX8gzy/R CUMg== X-Gm-Message-State: AODbwcAhEAnjRfnx+gs9MVr6AbWt78rU2lGsh0RB6cwOMFahApiEeLCw J0XKIheo/HCHzJhIFLoHMA== X-Received: by 10.99.109.129 with SMTP id i123mr32865782pgc.103.1496243978030; Wed, 31 May 2017 08:19:38 -0700 (PDT) Received: from xeon-e3 (76-14-207-240.or.wavecable.com. [76.14.207.240]) by smtp.gmail.com with ESMTPSA id s68sm27422139pgc.5.2017.05.31.08.19.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 May 2017 08:19:37 -0700 (PDT) Date: Wed, 31 May 2017 08:19:36 -0700 From: Stephen Hemminger To: Gaetan Rivet Cc: dev@dpdk.org Message-ID: <20170531081936.2bbad988@xeon-e3> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v4 06/12] net/failsafe: add flexible device definition X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 May 2017 15:19:39 -0000 On Mon, 29 May 2017 15:42:18 +0200 Gaetan Rivet wrote: > > +- **exec()** parameter > + > + This parameter allows the user to provide a command to the fail-safe PMD to > + execute and define a sub-device. > + It is done within a regular shell context. > + The first line of its output is read by the fail-safe PMD and otherwise > + interpreted as if passed by the regular **dev** parameter. > + Any other line is discarded. > + If the command fail or output an incorrect string, the sub-device is not > + initialized. > + All commas within the ``shell command`` are replaced by spaces before > + executing the command. This helps using scripts to specify devices. > + Exec from a DPDK application seems like possible security hole since most DPDK applications have to run as root. > static int > +fs_execute_cmd(struct sub_device *sdev, char *cmdline) > +{ > + FILE *fp; > + /* store possible newline as well */ > + char output[DEVARGS_MAXLEN + 1]; > + size_t len; > + int old_err; > + int ret; > + > + assert(cmdline != NULL || sdev->cmdline != NULL); > + if (sdev->cmdline == NULL) { > + char *new_str; > + size_t i; > + > + len = strlen(cmdline) + 1; > + new_str = rte_realloc(sdev->cmdline, len, > + RTE_CACHE_LINE_SIZE); > + if (new_str == NULL) { > + ERROR("Command line allocation failed"); > + return -ENOMEM; > + } Using rte_malloc for cmdline is way over optimizing. rte_malloc comes from huge page area which is limited. The only reason to use it is if the memory needs to be shared by primary/slave. Also rte_malloc has much less protection (memleak checkers, guards etc) compared to regular malloc.