From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 08778A04C1; Tue, 26 Nov 2019 08:36:54 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 479512A5D; Tue, 26 Nov 2019 08:36:54 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 5DAE6A3; Tue, 26 Nov 2019 08:36:52 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Nov 2019 23:36:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,244,1571727600"; d="scan'208";a="239831873" Received: from storage36.sh.intel.com ([10.67.110.177]) by fmsmga002.fm.intel.com with ESMTP; 25 Nov 2019 23:36:50 -0800 From: Jin Yu To: Maxime Coquelin , Tiwei Bie , Zhihong Wang Cc: dev@dpdk.org, Jin Yu , stable@dpdk.org Date: Tue, 26 Nov 2019 23:19:00 +0800 Message-Id: <20191126151900.70915-1-jin.yu@intel.com> X-Mailer: git-send-email 2.17.2 Subject: [dpdk-dev] [PATCH] vhost: fix insecure temporary file 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When using mkstemp(), remember to safely set the umask before to restrict the resulting temporary file permissions to only the owner. Coverity issue: 350367 Fixes: d87f1a1cb7b6 ("vhost: support inflight info sharing") Cc: stable@dpdk.org Signed-off-by: Jin Yu --- lib/librte_vhost/vhost_user.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 0cfb8b792..1a68e23e3 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -1342,6 +1342,7 @@ inflight_mem_alloc(const char *name, size_t size, int *fd) RTE_SET_USED(name); #endif if (mfd == -1) { + mode_t mask = umask(0600); mfd = mkstemp(fname); if (mfd == -1) { RTE_LOG(ERR, VHOST_CONFIG, @@ -1349,6 +1350,7 @@ inflight_mem_alloc(const char *name, size_t size, int *fd) return NULL; } + umask(mask); unlink(fname); } -- 2.17.2