diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9a9b9bf --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +SOURCES/libnl-3.5.0.tar.gz +SOURCES/libnl-doc-3.5.0.tar.gz diff --git a/.libnl3.metadata b/.libnl3.metadata new file mode 100644 index 0000000..f62ef88 --- /dev/null +++ b/.libnl3.metadata @@ -0,0 +1,2 @@ +54c476a3103add175a6a055fcf45c0a29d2c0948 SOURCES/libnl-3.5.0.tar.gz +e0857124974053ee7be34fbda6812b57961f0ae8 SOURCES/libnl-doc-3.5.0.tar.gz diff --git a/SOURCES/0001-coverity-fixes-rh1938776.patch b/SOURCES/0001-coverity-fixes-rh1938776.patch new file mode 100644 index 0000000..5e0daee --- /dev/null +++ b/SOURCES/0001-coverity-fixes-rh1938776.patch @@ -0,0 +1,168 @@ +From 5ab3bf7122eafe3bf06b147f8d936a976fe810ba Mon Sep 17 00:00:00 2001 +From: Beniamino Galvani +Date: Tue, 25 May 2021 14:18:10 +0200 +Subject: [PATCH 1/4] route/cls: fix cgroup's clone() function + +The destination object doesn't have to be allocated because it's +passed as _dst argument. Also, the function doesn't have to copy plain +fields. + +(cherry picked from commit 30552e849c38972dd11fafbb8085924987b002cc) +--- + lib/route/cls/cgroup.c | 15 +++++---------- + 1 file changed, 5 insertions(+), 10 deletions(-) + +diff --git a/lib/route/cls/cgroup.c b/lib/route/cls/cgroup.c +index b145261825f2..2461d22fd595 100644 +--- a/lib/route/cls/cgroup.c ++++ b/lib/route/cls/cgroup.c +@@ -36,17 +36,12 @@ static struct nla_policy cgroup_policy[TCA_CGROUP_MAX+1] = { + + static int cgroup_clone(void *_dst, void *_src) + { +- struct rtnl_cgroup *dst = NULL, *src = _src; ++ struct rtnl_cgroup *dst = _dst, *src = _src; + +- dst = calloc(1, sizeof(*dst)); +- if (!dst) +- return -NLE_NOMEM; +- +- dst->cg_mask = src->cg_mask; +- dst->cg_ematch = rtnl_ematch_tree_clone(src->cg_ematch); +- if (!dst) { +- free(dst); +- return -NLE_NOMEM; ++ if (src->cg_ematch) { ++ dst->cg_ematch = rtnl_ematch_tree_clone(src->cg_ematch); ++ if (!dst->cg_ematch) ++ return -NLE_NOMEM; + } + + return 0; +-- +2.31.1 + + +From 6a118c6b3cf8aa8638e057a282acbf06f09c41a8 Mon Sep 17 00:00:00 2001 +From: Beniamino Galvani +Date: Tue, 25 May 2021 14:33:21 +0200 +Subject: [PATCH 2/4] route/link: fix copy-paste error in geneve.c + +(cherry picked from commit aa092d1e729acb8b4aa5a3aaf2f228f46bafec5b) +--- + lib/route/link/geneve.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/route/link/geneve.c b/lib/route/link/geneve.c +index 7232b07f8452..9de1e8f1158f 100644 +--- a/lib/route/link/geneve.c ++++ b/lib/route/link/geneve.c +@@ -240,7 +240,7 @@ static void geneve_dump_details(struct rtnl_link *link, struct nl_dump_params *p + + if (geneve->mask & GENEVE_ATTR_UDP_ZERO_CSUM6_RX) { + nl_dump(p, " udp-zero-csum6-rx "); +- if (geneve->udp_zero_csum6_tx) ++ if (geneve->udp_zero_csum6_rx) + nl_dump_line(p, "enabled (%#x)\n", geneve->udp_zero_csum6_rx); + else + nl_dump_line(p, "disabled\n"); +-- +2.31.1 + + +From ed42caf2abdfa52fcb35416710bdcfd8189d8878 Mon Sep 17 00:00:00 2001 +From: Beniamino Galvani +Date: Tue, 25 May 2021 14:42:29 +0200 +Subject: [PATCH 3/4] route/qdisc: fix memory leak in netem.c + +'data' was leaked when returning -NLE_INVAL. Fix this by using the +cleanup attribute. + +(cherry picked from commit d1a151eb6fe603365d93526796b3fa7e64e1c0fd) +--- + lib/route/qdisc/netem.c | 10 ++++------ + 1 file changed, 4 insertions(+), 6 deletions(-) + +diff --git a/lib/route/qdisc/netem.c b/lib/route/qdisc/netem.c +index 17dee3b7efa4..20df8fd413b2 100644 +--- a/lib/route/qdisc/netem.c ++++ b/lib/route/qdisc/netem.c +@@ -26,6 +26,8 @@ + #include + #include + ++#include "netlink-private/utils.h" ++ + /** @cond SKIP */ + #define SCH_NETEM_ATTR_LATENCY 0x0001 + #define SCH_NETEM_ATTR_LIMIT 0x0002 +@@ -911,10 +913,10 @@ int rtnl_netem_set_delay_distribution(struct rtnl_qdisc *qdisc, const char *dist + int n = 0; + size_t i; + size_t len = 2048; +- char *line; ++ _nl_auto_free char *line = NULL; + char name[NAME_MAX]; + char dist_suffix[] = ".dist"; +- int16_t *data; ++ _nl_auto_free int16_t *data = NULL; + char *test_suffix; + + /* Check several locations for the dist file */ +@@ -955,7 +957,6 @@ int rtnl_netem_set_delay_distribution(struct rtnl_qdisc *qdisc, const char *dist + if (endp == p) break; + + if (n >= MAXDIST) { +- free(line); + fclose(f); + return -NLE_INVAL; + } +@@ -963,11 +964,8 @@ int rtnl_netem_set_delay_distribution(struct rtnl_qdisc *qdisc, const char *dist + } + } + +- free(line); + fclose(f); +- + i = rtnl_netem_set_delay_distribution_data(qdisc, data, n); +- free(data); + return i; + } + +-- +2.31.1 + + +From f60433f575beb927b69d6a857a0345d1a3206311 Mon Sep 17 00:00:00 2001 +From: Beniamino Galvani +Date: Wed, 16 Jun 2021 11:56:25 +0200 +Subject: [PATCH 4/4] route/qdisc: handle error of calloc() + +(cherry picked from commit 26f342d09947d5884014ec4a0553c094e41c60bc) +--- + lib/route/qdisc/netem.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/lib/route/qdisc/netem.c b/lib/route/qdisc/netem.c +index 20df8fd413b2..ceb2ad9871d2 100644 +--- a/lib/route/qdisc/netem.c ++++ b/lib/route/qdisc/netem.c +@@ -942,9 +942,12 @@ int rtnl_netem_set_delay_distribution(struct rtnl_qdisc *qdisc, const char *dist + if (f == NULL) + return -nl_syserr2nlerr(errno); + +- data = (int16_t *) calloc (MAXDIST, sizeof(int16_t)); +- +- line = (char *) calloc (sizeof(char), len + 1); ++ data = (int16_t *) calloc(MAXDIST, sizeof(int16_t)); ++ line = (char *) calloc(sizeof(char), len + 1); ++ if (!data || !line) { ++ fclose(f); ++ return -NLE_NOMEM; ++ } + + while (getline(&line, &len, f) != -1) { + char *p, *endp; +-- +2.31.1 + diff --git a/SPECS/libnl3.spec b/SPECS/libnl3.spec new file mode 100644 index 0000000..ab55b6e --- /dev/null +++ b/SPECS/libnl3.spec @@ -0,0 +1,371 @@ +Name: libnl3 +Version: 3.5.0 +Release: 10%{?dist} +Summary: Convenience library for kernel netlink sockets +License: LGPLv2 +URL: http://www.infradead.org/~tgr/libnl/ + +%define rcversion %{nil} +%define fullversion %{version}%{rcversion} + +%if 0%{?rhel} > 8 +# Disable python3 build by default +%bcond_with python3 +%else +%bcond_without python3 +%endif + +Source: http://www.infradead.org/~tgr/libnl/files/libnl-%{fullversion}.tar.gz +Source1: http://www.infradead.org/~tgr/libnl/files/libnl-doc-%{fullversion}.tar.gz + +#Patch1: some.patch +Patch0001: 0001-coverity-fixes-rh1938776.patch + + +BuildRequires: autoconf +BuildRequires: automake +BuildRequires: bison +BuildRequires: flex +BuildRequires: libtool +BuildRequires: swig + + +%description +This package contains a convenience library to simplify +using the Linux kernel's netlink sockets interface for +network manipulation + + +%package devel +Summary: Libraries and headers for using libnl3 +Requires: %{name} = %{version}-%{release} +Requires: %{name}-cli = %{version}-%{release} +Requires: kernel-headers + +%description devel +This package contains various headers for using libnl3 + + +%package cli +Summary: Command line interface utils for libnl3 +Requires: %{name} = %{version}-%{release} + +%description cli +This package contains various libnl3 utils and additional +libraries on which they depend + + +%package doc +Summary: API documentation for libnl3 +Requires: %{name} = %{version}-%{release} + +%description doc +This package contains libnl3 API documentation + + +%if %{with python3} +%package -n python3-libnl3 +Summary: libnl3 binding for Python 3 +%{?python_provide:%python_provide python3-libnl3} +BuildRequires: python3-devel +BuildRequires: make +Requires: %{name} = %{version}-%{release} + +%description -n python3-libnl3 +Python 3 bindings for libnl3 +%endif + +%prep +%autosetup -p1 -n libnl-%{fullversion} + +tar -xzf %SOURCE1 + +%build +autoreconf -vif +%configure --disable-static +make %{?_smp_mflags} + +%if %{with python3} +pushd ./python/ +# build twice, otherwise capi.py is not copied to the build directory. +CFLAGS="$RPM_OPT_FLAGS" %py3_build +CFLAGS="$RPM_OPT_FLAGS" %py3_build +popd +%endif + +%install +make install DESTDIR=$RPM_BUILD_ROOT + +find $RPM_BUILD_ROOT -name \*.la -delete + +%if %{with python3} +pushd ./python/ +%py3_install +popd +%endif + +%check +make check + +%if %{with python3} +pushd ./python/ +%{__python3} setup.py check +popd +%endif + +%ldconfig_scriptlets +%ldconfig_scriptlets cli + +%files +%doc COPYING +%exclude %{_libdir}/libnl-cli*.so.* +%{_libdir}/libnl-*.so.* +%config(noreplace) %{_sysconfdir}/* + +%files devel +%doc COPYING +%{_includedir}/libnl3/netlink/ +%dir %{_includedir}/libnl3/ +%{_libdir}/*.so +%{_libdir}/pkgconfig/*.pc + +%files cli +%doc COPYING +%{_libdir}/libnl-cli*.so.* +%{_libdir}/libnl/ +%{_bindir}/* +%{_mandir}/man8/* + +%files doc +%doc COPYING +%doc libnl-doc-%{fullversion}/*.html +%doc libnl-doc-%{fullversion}/*.css +%doc libnl-doc-%{fullversion}/stylesheets/* +%doc libnl-doc-%{fullversion}/images/* +%doc libnl-doc-%{fullversion}/images/icons/* +%doc libnl-doc-%{fullversion}/images/icons/callouts/* +%doc libnl-doc-%{fullversion}/api/* + +%if %{with python3} +%files -n python3-libnl3 +%{python3_sitearch}/netlink +%{python3_sitearch}/netlink-*.egg-info +%endif + +%changelog +* Mon Aug 09 2021 Mohan Boddu - 3.5.0-10 +- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags + Related: rhbz#1991688 + +* Fri Jul 2 2021 Thomas Haller - 3.5.0-9 +- Various fixes found by coverity (rh #1938776) + +* Tue Jun 8 2021 Thomas Haller - 3.5.0-8 +- Drop python3-libnl3 package (rh #1969549) + +* Fri Apr 16 2021 Mohan Boddu - 3.5.0-7 +- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937 + +* Tue Jan 26 2021 Fedora Release Engineering - 3.5.0-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Sat Aug 01 2020 Fedora Release Engineering - 3.5.0-5 +- Second attempt - Rebuilt for + https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Tue Jul 28 2020 Fedora Release Engineering - 3.5.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Tue May 26 2020 Miro Hrončok - 3.5.0-3 +- Rebuilt for Python 3.9 + +* Wed Jan 29 2020 Fedora Release Engineering - 3.5.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Sun Sep 1 2019 Thomas Haller - 3.5.0-1 +- Update to 3.5.0 release + +* Mon Aug 19 2019 Miro Hrončok - 3.4.0-10 +- Rebuilt for Python 3.8 + +* Thu Jul 25 2019 Fedora Release Engineering - 3.4.0-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Fri Feb 01 2019 Fedora Release Engineering - 3.4.0-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Tue Jan 15 2019 Miro Hrončok - 3.4.0-7 +- Subpackage python2-libnl3 has been removed + See https://fedoraproject.org/wiki/Changes/Mass_Python_2_Package_Removal + +* Fri Jul 13 2018 Fedora Release Engineering - 3.4.0-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Tue Jun 19 2018 Miro Hrončok - 3.4.0-5 +- Rebuilt for Python 3.7 + +* Fri Mar 16 2018 Charalampos Stratakis - 3.4.0-4 +- Conditionalize the Python 2 subpackage + +* Wed Feb 07 2018 Fedora Release Engineering - 3.4.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Tue Jan 09 2018 Iryna Shcherbina - 3.4.0-2 +- Update Python 2 dependency declarations to new packaging standards + (See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3) + +* Mon Oct 9 2017 Thomas Haller - 3.4.0-1 +- Update to 3.4.0 + +* Wed Sep 20 2017 Thomas Haller - 3.4.0-0.1 +- Update to 3.4.0-rc1 + +* Sat Aug 19 2017 Zbigniew Jędrzejewski-Szmek - 3.3.0-4 +- Python 2 binary package renamed to python2-libnl3 + See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3 + +* Thu Aug 03 2017 Fedora Release Engineering - 3.3.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Wed Jul 26 2017 Fedora Release Engineering - 3.3.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Wed May 3 2017 Thomas Haller - 3.3.0-1 +- Update to 3.3.0 + +* Mon Mar 6 2017 Thomas Haller - 3.3.0-0.1 +- Update to 3.3.0-rc1 + +* Fri Feb 10 2017 Fedora Release Engineering - 3.2.29-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Wed Jan 18 2017 Thomas Haller - 3.2.29-2 +- Update with patches from upstream +- check valid input arguments for nla_reserve() (rh#1414305, CVE-2017-0386) +- fix crash during SRIOV parsing +- lazyly read psched settings +- use O_CLOEXEC when creating file descriptors with fopen() + +* Fri Dec 30 2016 Thomas Haller - 3.2.29-1 +- Update to 3.2.29 + +* Mon Dec 19 2016 Miro Hrončok - 3.2.29-0.3 +- Rebuild for Python 3.6 + +* Fri Dec 16 2016 Thomas Haller - 3.2.29-0.2 +- macsec: fix endianness for MACSec's 'sci' parameter + +* Mon Dec 12 2016 Thomas Haller - 3.2.29-0.1 +- Update to 3.2.29-rc1 + +* Fri Aug 26 2016 Thomas Haller - 3.2.28-3 +- route: fix nl_object_identical() comparing AF_INET addresses (rh #1370526) + +* Tue Jul 19 2016 Fedora Release Engineering - 3.2.28-2 +- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages + +* Sat Jul 9 2016 Thomas Haller - 3.2.28-1 +- Update to 3.2.28 + +* Thu Jun 30 2016 Thomas Haller - 3.2.28-0.1 +- Update to 3.2.28-rc1 + +* Thu Feb 04 2016 Fedora Release Engineering - 3.2.27-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Tue Nov 10 2015 Fedora Release Engineering - 3.2.27-2 +- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5 + +* Fri Oct 16 2015 Thomas Haller - 3.2.27-1 +- Update to 3.2.27 + +* Mon Sep 21 2015 Thomas Haller - 3.2.27-0.1 +- Update to 3.2.27-rc1 + +* Wed Jun 17 2015 Fedora Release Engineering - 3.2.26-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Mon Mar 30 2015 Thomas Haller - 3.2.26-4 +- Update to 3.2.26 +- cli package brings more commands and installs them to /bin + +* Mon Mar 9 2015 Thomas Haller - 3.2.26-3 +- Update to 3.2.26-rc1 +- fix broken symbols from 3.2.26-1 +- backport upstream fix for nl_socket_set_fd() + +* Sat Mar 7 2015 Thomas Haller - 3.2.26-2 +- Revert update to 3.2.26-rc1 to previous 3.2.25-6 + +* Fri Mar 6 2015 Thomas Haller - 3.2.26-1 +- Update to 3.2.26-rc1 + +* Tue Feb 3 2015 Thomas Haller - 3.2.25-6 +- add new packages with language bindings for Python 2 and Python 3 (rh #1167112) + +* Tue Dec 9 2014 Thomas Haller - 3.2.25-5 +- Add support for IPv6 link local address generation + +* Fri Oct 10 2014 Lubomir Rintel - 3.2.25-4 +- Add support for IPv6 tokenized interface identifiers + +* Sun Aug 17 2014 Fedora Release Engineering - 3.2.25-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + +* Wed Jul 16 2014 Thomas Haller 3.2.25-2 +- Update to 3.2.25 + +* Fri Jul 4 2014 Thomas Haller 3.2.25-1 +- Update to 3.2.25-rc1 + +* Sun Jun 8 2014 Peter Robinson 3.2.24-5 +- Run autoreconf for new automake, cleanup spec + +* Sat Jun 07 2014 Fedora Release Engineering - 3.2.24-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Thu May 22 2014 Thomas Haller - 3.2.24-3 +- add nl_has_capability() function +- retry local port on ADDRINUSE (rh #1097175) +- python: fix passing wrong argument in netlink/core.py +- fix return value of nl_rtgen_request() +- fix nl_msec2str() +- fix crash in rtnl_act_msg_parse() +- fix rtnl_route_build_msg() not to guess the route scope if RT_SCOPE_NOWHERE + +* Fri Apr 4 2014 Thomas Haller - 3.2.24-2 +- fix breaking on older kernels due to IFA_FLAGS attribute (rh #1063885) + +* Thu Jan 23 2014 Thomas Haller - 3.2.24-1 +- Update to 3.2.24 (rhbz#963111) + +* Mon Sep 23 2013 Paul Wouters - 3.2.22-2 +- Update to 3.2.22 (rhbz#963111) +- Add patch for double tree crasher in rtnl_link_set_address_family() + +* Sat Aug 03 2013 Fedora Release Engineering - 3.2.21-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Fri Jan 25 2013 Jiri Pirko - 3.2.21-1 +- Update to 3.2.21 + +* Wed Jan 23 2013 Jiri Pirko - 3.2.20-1 +- Update to 3.2.20 + +* Sun Jan 20 2013 Jiri Pirko - 3.2.19-2 +- Age fix + +* Thu Jan 17 2013 Jiri Pirko - 3.2.19-1 +- Update to 3.2.19 + +* Tue Oct 30 2012 Dan Williams - 3.2.14-1 +- Update to 3.2.14 + +* Mon Sep 17 2012 Dan Williams - 3.2.13-1 +- Update to 3.2.13 + +* Fri Feb 10 2012 Dan Williams - 3.2.7-1 +- Update to 3.2.7 + +* Tue Jan 17 2012 Jiri Pirko - 3.2.6-1 +- Initial build