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 4A404A04F3 for ; Thu, 19 Dec 2019 15:35:38 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 41D52330; Thu, 19 Dec 2019 15:35:38 +0100 (CET) Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by dpdk.org (Postfix) with ESMTP id A46101BF71 for ; Thu, 19 Dec 2019 15:35:37 +0100 (CET) Received: by mail-wm1-f65.google.com with SMTP id t14so5833107wmi.5 for ; Thu, 19 Dec 2019 06:35:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JrBN1KPefPB9fYAU5XFQKrbrFWB9zyPtUuOVmHj4BL8=; b=lDZbP8U/hzpqGa5Ol+sbCL7vsJNiAJL48ctLb6Gd+6vsG01oJimnhRX5NHPva6H9D3 fzpRotqBC/63lLKwZOjYiRIDNjSmuih2QDO1xZsaLtd+cRuGlAimlix2jD/geVp/i06Z s/44FDFV14Nl7FqI08uoF19+9cn4YZJWiyQn7zgCIsVVk8bjdEbEir0J26cz0OpZ691A h7GlCTpnrjoxqibu7QNm0KdjGebs8rrrgGoBbthsw4Jg71uK3gyClLpc3VQ5QYUexDcO sSF0N8sNj23m7NvvcnUMKjmjJc08JUpRN1ktfOmMLzcDKlcE5dXv+9xuiSo+LoGlBgmm I8rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JrBN1KPefPB9fYAU5XFQKrbrFWB9zyPtUuOVmHj4BL8=; b=e1Gcy0xqu1wy5FIJPplnJX1xI0n+1/16yts3qv4rtoYqb7Ev/1YOfiO2pfBXxrtsK0 oA9ab8A1yqXuRN8maBJLP5VjWdfBqyeNzCmSg5X3ALvuz1BOmlDAqeVkX4NHimfMeb8v TjS+zoWEzlyQDNDTwLvsRRHu8fEpvY9mSHmEFh2niAl0sfzJgG13lPowdG4gYlrsehY5 UyObhA8iOO6FFhK4LkePmqA2/RE6KrRDAG6AcK50gRpWp5LwzcnSS//F28jdO9ZjFVH7 PNJOYj84RI9uxHlLI6t1Ny8cI/8x82+7n1PRCnMgDdFc5h6F65iRAOLsZvN4tZi6EtDs JUiQ== X-Gm-Message-State: APjAAAVDs0odZTStgtmo9wE1UQUHpFLSd89X/kCy3ffT6YXvUjqzemqi tjuGTvwM0p0UE8uu44BBFREkw5RS X-Google-Smtp-Source: APXvYqzJKWRZeq92HNqXIJm9ZG64Ly1owDlHmeXcEt5lL0UTpESgTVCDrZmKN0MQZwwsikD+HOXpSQ== X-Received: by 2002:a05:600c:224a:: with SMTP id a10mr10654526wmm.143.1576766137400; Thu, 19 Dec 2019 06:35:37 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id 16sm6259757wmi.0.2019.12.19.06.35.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 06:35:36 -0800 (PST) From: luca.boccassi@gmail.com To: Stephen Hemminger Cc: David Marchand , dpdk stable Date: Thu, 19 Dec 2019 14:32:45 +0000 Message-Id: <20191219143447.21506-18-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191219143447.21506-1-luca.boccassi@gmail.com> References: <20191219143447.21506-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'bus/pci: fix Intel IOMMU sysfs access check' has been queued to LTS release 17.11.10 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to LTS release 17.11.10 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 12/21/19. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Thanks. Luca Boccassi --- >From e87d0eb85b619ad48c6443e7429c15c6347eec77 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 13 Aug 2019 08:38:22 -0700 Subject: [PATCH] bus/pci: fix Intel IOMMU sysfs access check [ upstream commit 2e8d5cf7631cbc5efb4b3abf7393d2526dee0424 ] Just open the sysfs file and handle failure, rather than using access(). This eliminates Coverity warnings about TOCTOU "time of check versus time of use"; although for this sysfs file that is not really an issue anyway. Coverity issue: 347276 Fixes: 54a328f552ff ("bus/pci: forbid IOVA mode if IOMMU address width too small") Signed-off-by: Stephen Hemminger Reviewed-by: David Marchand --- drivers/bus/pci/linux/pci.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c index aabaa63009..a51d00ac80 100644 --- a/drivers/bus/pci/linux/pci.c +++ b/drivers/bus/pci/linux/pci.c @@ -593,18 +593,19 @@ pci_one_device_iommu_support_va(struct rte_pci_device *dev) "%s/" PCI_PRI_FMT "/iommu/intel-iommu/cap", rte_pci_get_sysfs_path(), addr->domain, addr->bus, addr->devid, addr->function); - if (access(filename, F_OK) == -1) { - /* We don't have an Intel IOMMU, assume VA supported*/ - return true; - } - /* We have an intel IOMMU */ fp = fopen(filename, "r"); if (fp == NULL) { - RTE_LOG(ERR, EAL, "%s(): can't open %s\n", __func__, filename); + /* We don't have an Intel IOMMU, assume VA supported */ + if (errno == ENOENT) + return true; + + RTE_LOG(ERR, EAL, "%s(): can't open %s: %s\n", + __func__, filename, strerror(errno)); return false; } + /* We have an Intel IOMMU */ if (fscanf(fp, "%" PRIx64, &vtd_cap_reg) != 1) { RTE_LOG(ERR, EAL, "%s(): can't read %s\n", __func__, filename); fclose(fp); -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2019-12-19 14:32:27.052853082 +0000 +++ 0018-bus-pci-fix-Intel-IOMMU-sysfs-access-check.patch 2019-12-19 14:32:25.453284896 +0000 @@ -1,8 +1,10 @@ -From 2e8d5cf7631cbc5efb4b3abf7393d2526dee0424 Mon Sep 17 00:00:00 2001 +From e87d0eb85b619ad48c6443e7429c15c6347eec77 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 13 Aug 2019 08:38:22 -0700 Subject: [PATCH] bus/pci: fix Intel IOMMU sysfs access check +[ upstream commit 2e8d5cf7631cbc5efb4b3abf7393d2526dee0424 ] + Just open the sysfs file and handle failure, rather than using access(). This eliminates Coverity warnings about TOCTOU "time of check versus time of use"; although for this sysfs file that is @@ -10,7 +12,6 @@ Coverity issue: 347276 Fixes: 54a328f552ff ("bus/pci: forbid IOVA mode if IOMMU address width too small") -Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger Reviewed-by: David Marchand @@ -19,10 +20,10 @@ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c -index 1ac2bff779..318db19532 100644 +index aabaa63009..a51d00ac80 100644 --- a/drivers/bus/pci/linux/pci.c +++ b/drivers/bus/pci/linux/pci.c -@@ -511,18 +511,19 @@ pci_device_iommu_support_va(const struct rte_pci_device *dev) +@@ -593,18 +593,19 @@ pci_one_device_iommu_support_va(struct rte_pci_device *dev) "%s/" PCI_PRI_FMT "/iommu/intel-iommu/cap", rte_pci_get_sysfs_path(), addr->domain, addr->bus, addr->devid, addr->function);