[dpdk-stable] patch 'pci: reject negative values in PCI id' has been queued to stable release 19.11.3

luca.boccassi at gmail.com luca.boccassi at gmail.com
Fri May 22 11:40:13 CEST 2020


Hi,

FYI, your patch has been queued to stable release 19.11.3

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 05/24/20. 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 a7413810b94b89763b3af7ba97a9a91f17737732 Mon Sep 17 00:00:00 2001
From: Gaetan Rivet <grive at u256.net>
Date: Wed, 13 May 2020 12:47:50 +0200
Subject: [PATCH] pci: reject negative values in PCI id

[ upstream commit 21a61fae51804cfdf7c6f7e6189c63f02025de89 ]

The function strtoul will not return ERANGE if the input is negative, as
one might expect.

   0000:-FFFFFFFFFFFFFFFB:00.0

is not a better way to write 0000:05:00.0.
To simplify checking for '-', forbid using spaces before the field value.

   0000: 00:   2c.0

Should not be accepted.

Fixes: af75078fece3 ("first public release")

Signed-off-by: Gaetan Rivet <grive at u256.net>
Acked-by: Darek Stojaczyk <dariusz.stojaczyk at intel.com>
---
 lib/librte_pci/rte_pci.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lib/librte_pci/rte_pci.c b/lib/librte_pci/rte_pci.c
index ad2cdfebb2..5f7726fa89 100644
--- a/lib/librte_pci/rte_pci.c
+++ b/lib/librte_pci/rte_pci.c
@@ -35,6 +35,12 @@ get_u8_pciaddr_field(const char *in, void *_u8, char dlm)
 	if (*in == '\0')
 		return NULL;
 
+	/* PCI field starting with spaces is forbidden.
+	 * Negative wrap-around is not reported as an error by strtoul.
+	 */
+	if (*in == ' ' || *in == '-')
+		return NULL;
+
 	errno = 0;
 	val = strtoul(in, &end, 16);
 	if (errno != 0 || end[0] != dlm || val > UINT8_MAX) {
@@ -70,6 +76,12 @@ pci_dbdf_parse(const char *input, struct rte_pci_addr *dev_addr)
 	unsigned long val;
 	char *end;
 
+	/* PCI id starting with spaces is forbidden.
+	 * Negative wrap-around is not reported as an error by strtoul.
+	 */
+	if (*in == ' ' || *in == '-')
+		return -EINVAL;
+
 	errno = 0;
 	val = strtoul(in, &end, 16);
 	if (errno != 0 || end[0] != ':' || val > UINT32_MAX)
-- 
2.20.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2020-05-22 10:37:40.590667334 +0100
+++ 0034-pci-reject-negative-values-in-PCI-id.patch	2020-05-22 10:37:39.240414721 +0100
@@ -1,8 +1,10 @@
-From 21a61fae51804cfdf7c6f7e6189c63f02025de89 Mon Sep 17 00:00:00 2001
+From a7413810b94b89763b3af7ba97a9a91f17737732 Mon Sep 17 00:00:00 2001
 From: Gaetan Rivet <grive at u256.net>
 Date: Wed, 13 May 2020 12:47:50 +0200
 Subject: [PATCH] pci: reject negative values in PCI id
 
+[ upstream commit 21a61fae51804cfdf7c6f7e6189c63f02025de89 ]
+
 The function strtoul will not return ERANGE if the input is negative, as
 one might expect.
 
@@ -16,7 +18,6 @@
 Should not be accepted.
 
 Fixes: af75078fece3 ("first public release")
-Cc: stable at dpdk.org
 
 Signed-off-by: Gaetan Rivet <grive at u256.net>
 Acked-by: Darek Stojaczyk <dariusz.stojaczyk at intel.com>


More information about the stable mailing list