diff --git a/SOURCES/0001-Fix-use-after-free-of-fd.patch b/SOURCES/0001-Fix-use-after-free-of-fd.patch new file mode 100644 index 0000000..17129b5 --- /dev/null +++ b/SOURCES/0001-Fix-use-after-free-of-fd.patch @@ -0,0 +1,31 @@ +From 8ab1d293643201abb1dc58bcdc2f86c3ea56d49d Mon Sep 17 00:00:00 2001 +From: Michal Sekletar +Date: Tue, 22 Dec 2015 10:34:16 +0100 +Subject: [PATCH] Fix use-after-free of fd + +This bug got introduced in 51219cac581b5eaced5b172dbbb4586889cb27e1. I +overlooked that we are already properly closing fd on non-error code +path and I added redundant call to close. + +Closing already closed fd is harmless though. Function returns EBADF and +fails silently. + +(cherry picked from commit d1d62966032784f292e6875ba4373b18149a5754) +--- + src/dmidecode/util.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/src/dmidecode/util.c b/src/dmidecode/util.c +index 3340e1f..ea06663 100644 +--- a/src/dmidecode/util.c ++++ b/src/dmidecode/util.c +@@ -162,6 +162,5 @@ void *mem_chunk(size_t base, size_t len, const char *devmem) + if(close(fd)==-1) + perror(devmem); + +- close(fd); + return p; + } +-- +2.9.3 + diff --git a/SOURCES/0002-Ignore-naming-of-non-Ethernet-network-interfaces.patch b/SOURCES/0002-Ignore-naming-of-non-Ethernet-network-interfaces.patch new file mode 100644 index 0000000..78a47e7 --- /dev/null +++ b/SOURCES/0002-Ignore-naming-of-non-Ethernet-network-interfaces.patch @@ -0,0 +1,46 @@ +From eb7cb935f585d41163bb9bf0e64f267cb0597bdd Mon Sep 17 00:00:00 2001 +From: Sujith Pandel +Date: Tue, 14 Mar 2017 11:44:23 +0530 +Subject: [PATCH] Ignore naming of non-Ethernet network interfaces + +Support of biosdevname is to name Ethernet interfaces only, as per biosdevname spec. +Currently, manual call of biosdevname on other types of network interfaces will return interface names. +This code change is to ignore naming of Infiniband and other types of network interfaces. + +(cherry picked from commit 609f20c26f40ae4883f5e8c9b241470260722b3f) +--- + src/bios_device.c | 3 +++ + src/eths.h | 5 +++++ + 2 files changed, 8 insertions(+) + +diff --git a/src/bios_device.c b/src/bios_device.c +index 6636e67..e9d5177 100644 +--- a/src/bios_device.c ++++ b/src/bios_device.c +@@ -238,6 +238,9 @@ static void match_pci_and_eth_devs(struct libbiosdevname_state *state) + /* Loop through all ether devices to find match */ + unparse_pci_name(pci_name, sizeof(pci_name), p->pci_dev); + list_for_each_entry(n, &state->network_devices, node) { ++ //Accept only Ethernet devices, otherwise ignore. ++ if(!netdev_arphrd_type_is_eth(n)) ++ continue; + if (strncmp(n->drvinfo.bus_info, pci_name, sizeof(n->drvinfo.bus_info))) + continue; + /* Ignore if devtype is fcoe */ +diff --git a/src/eths.h b/src/eths.h +index a145b4f..b695d3d 100644 +--- a/src/eths.h ++++ b/src/eths.h +@@ -63,4 +63,9 @@ static inline int netdev_devtype_is_fcoe(const struct network_device *dev) + return (dev->devtype_is_fcoe == 1); + } + ++static inline int netdev_arphrd_type_is_eth(const struct network_device *dev) ++{ ++ return (dev->arphrd_type == ARPHRD_ETHER); ++} ++ + #endif /* __ETHS_H_INCLUDED */ +-- +2.9.3 + diff --git a/SOURCES/0003-Prevent-reading-of-VPD-DCM-strings-for-SRIOV-vfs.patch b/SOURCES/0003-Prevent-reading-of-VPD-DCM-strings-for-SRIOV-vfs.patch new file mode 100644 index 0000000..11ef7d8 --- /dev/null +++ b/SOURCES/0003-Prevent-reading-of-VPD-DCM-strings-for-SRIOV-vfs.patch @@ -0,0 +1,65 @@ +From dd33892e7e955ae036481a02c73803646286db95 Mon Sep 17 00:00:00 2001 +From: sujithpshankar +Date: Tue, 14 Mar 2017 12:55:24 +0530 +Subject: [PATCH] Prevent reading of VPD-DCM strings for SRIOV-vfs. + +Reading DCM strings of SRIOV-vfs results in a confusion that leads to interface being assumed as a NIC partition rather than a SRIOV-vf. +This patch prevents the reading and setting of VPD data to SRIOV-vf interfaces. +(cherry picked from commit 02811d5165c2eeecf8797fe9b5088d6e78bd25db) +--- + src/pci.c | 13 ++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + +diff --git a/src/pci.c b/src/pci.c +index 1724394..74ed9e6 100644 +--- a/src/pci.c ++++ b/src/pci.c +@@ -119,6 +119,10 @@ static void parse_dcm(struct libbiosdevname_state *state, struct pci_device *pde + struct vpd_tag *dcm; + const char *fmt; + ++ if (pdev->is_sriov_virtual_function) { ++ return ; ++ } ++ + fmt = "%1x%1x%2x"; + step = 10; + dcm = pci_vpd_findtag(vpd, len, "DCM"); +@@ -139,7 +143,7 @@ static void parse_dcm(struct libbiosdevname_state *state, struct pci_device *pde + vf = find_pci_dev_by_pci_addr(state, pdev->pci_dev->domain, + pdev->pci_dev->bus, + devfn >> 3, devfn & 7); +- if (vf != NULL) { ++ if (vf != NULL && !vf->is_sriov_virtual_function) { + add_port(vf, port, pfi); + if (vf->vpd_port == INT_MAX) { + vf->vpd_port = port; +@@ -157,7 +161,7 @@ static int read_pci_vpd(struct libbiosdevname_state *state, struct pci_device *p + int fd, len; + unsigned char *vpd; + +- if (!is_pci_network(pdev)) ++ if (!is_pci_network(pdev) || pdev->is_sriov_virtual_function) + return 1; + unparse_pci_name(pci_name, sizeof(pci_name), pdev->pci_dev); + snprintf(path, sizeof(path), "/sys/bus/pci/devices/%s/physfn/vpd", pci_name); +@@ -214,12 +218,15 @@ static void set_pci_vpd_instance(struct libbiosdevname_state *state) + /* Ignore already parsed devices */ + continue; + } ++ if (dev->is_sriov_virtual_function) { ++ continue; ++ } + read_pci_vpd(state, dev); + } + + /* Now match VPD master device */ + list_for_each_entry(dev, &state->pci_devices, node) { +- if (dev->vpd_port == INT_MAX) ++ if (dev->vpd_port == INT_MAX || dev->is_sriov_virtual_function) + continue; + list_for_each_entry(dev2, &state->pci_devices, node) { + if (dev2->pci_dev->domain == dev->pci_dev->domain && +-- +2.9.3 + diff --git a/SPECS/biosdevname.spec b/SPECS/biosdevname.spec index c62b9c2..0950182 100644 --- a/SPECS/biosdevname.spec +++ b/SPECS/biosdevname.spec @@ -1,6 +1,6 @@ Name: biosdevname Version: 0.7.2 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Udev helper for naming devices per BIOS names Group: System Environment/Base @@ -23,6 +23,9 @@ Requires: udev Patch0: biosdevname-0.6.1-rules.patch Patch1: 0001-Place-udev-rules-to-usr-lib.patch +Patch2: 0001-Fix-use-after-free-of-fd.patch +Patch3: 0002-Ignore-naming-of-non-Ethernet-network-interfaces.patch +Patch4: 0003-Prevent-reading-of-VPD-DCM-strings-for-SRIOV-vfs.patch %description biosdevname in its simplest form takes a kernel device name as an @@ -35,7 +38,9 @@ name (e.g. eth0). %setup -q %patch0 -p1 %patch1 -p1 - +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 %build autoreconf -iv @@ -59,6 +64,9 @@ make install install-data DESTDIR=%{buildroot} %changelog +* Fri Mar 31 2017 Michal Sekletar - 0.7.2-2 +- backport fixes from upstream (#1385889) + * Thu May 26 2016 Michal Sekletar - 0.7.2-1 - rebase to 0.7.2 (#1269524)