From 2a0aaf952c9d5c3256789d966ac7e3fccb702b64 Mon Sep 17 00:00:00 2001 From: Boris Ranto Date: Mar 04 2015 15:13:36 +0000 Subject: Fix several issues with spec file - Perform a hardened build - Use git-formatted patches - Add patch for pthreads rwlock unlock problem - Do not remove conf files on uninstall - Remove the cleanup function, it is only necessary for f20 and f21 --- diff --git a/0001-Switch-google-includes-to-gperftools-includes.patch b/0001-Switch-google-includes-to-gperftools-includes.patch new file mode 100644 index 0000000..58c11a3 --- /dev/null +++ b/0001-Switch-google-includes-to-gperftools-includes.patch @@ -0,0 +1,27 @@ +From 586893408fa1c274844941c74757c3364c0f701e Mon Sep 17 00:00:00 2001 +From: Boris Ranto +Date: Wed, 4 Mar 2015 15:23:53 +0100 +Subject: [PATCH 1/2] Switch google/* includes to gperftools/* includes + +--- + src/perfglue/heap_profiler.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/perfglue/heap_profiler.cc b/src/perfglue/heap_profiler.cc +index 6b079b8..cdd5ccb 100644 +--- a/src/perfglue/heap_profiler.cc ++++ b/src/perfglue/heap_profiler.cc +@@ -12,8 +12,8 @@ + * + */ + +-#include +-#include ++#include ++#include + #include "heap_profiler.h" + #include "common/environment.h" + #include "common/LogClient.h" +-- +1.9.3 + diff --git a/0002-common-do-not-unlock-rwlock-on-destruction.patch b/0002-common-do-not-unlock-rwlock-on-destruction.patch new file mode 100644 index 0000000..6649658 --- /dev/null +++ b/0002-common-do-not-unlock-rwlock-on-destruction.patch @@ -0,0 +1,62 @@ +From e77a5347aaeeb219512f77ae7a517906a51aca29 Mon Sep 17 00:00:00 2001 +From: Federico Simoncelli +Date: Sat, 15 Nov 2014 14:14:04 +0000 +Subject: [PATCH 2/2] common: do not unlock rwlock on destruction + +According to pthread_rwlock_unlock(3p): + + Results are undefined if the read-write lock rwlock is not held + by the calling thread. + +and: + + https://sourceware.org/bugzilla/show_bug.cgi?id=17561 + + Calling pthread_rwlock_unlock on an rwlock which is not locked + is undefined. + +calling pthread_rwlock_unlock on RWLock destruction could cause +an unknown behavior for two reasons: + +- the lock is acquired by another thread (undefined) +- the lock is not acquired (undefined) + +Moreover since glibc-2.20 calling pthread_rwlock_unlock on a +rwlock that is not locked results in a SIGILL that kills the +application. + +This patch removes the pthread_rwlock_unlock call on destruction +and replaces it with an assertion to check that the RWLock is +not in use. + +Any code that relied on the implicit release is now going to +break the assertion, e.g.: + + { + RWLock l; + l.get(for_write); + } // implicit release, wrong. + +Signed-off-by: Federico Simoncelli +--- + src/common/RWLock.h | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/common/RWLock.h b/src/common/RWLock.h +index e647e17..6f0ab8e 100644 +--- a/src/common/RWLock.h ++++ b/src/common/RWLock.h +@@ -46,7 +46,9 @@ public: + return (nwlock.read() > 0); + } + virtual ~RWLock() { +- pthread_rwlock_unlock(&L); ++ // The following check is racy but we are about to destroy ++ // the object and we assume that there are no other users. ++ assert(!is_locked()); + pthread_rwlock_destroy(&L); + } + +-- +1.9.3 + diff --git a/ceph-0.87-boost157.patch b/ceph-0.87-boost157.patch deleted file mode 100644 index d05e904..0000000 --- a/ceph-0.87-boost157.patch +++ /dev/null @@ -1,117 +0,0 @@ -diff -urp ceph-0.87/src/include/encoding.h ceph-0.87-pm/src/include/encoding.h ---- ceph-0.87/src/include/encoding.h 2014-10-29 19:09:14.000000000 +0100 -+++ ceph-0.87-pm/src/include/encoding.h 2015-01-29 02:47:10.392860344 +0100 -@@ -286,7 +286,7 @@ inline void decode(T &o, bufferlist& bl) - #include - #include - #include --#include -+#include - - #ifndef _BACKWARD_BACKWARD_WARNING_H - #define _BACKWARD_BACKWARD_WARNING_H // make gcc 4.3 shut up about hash_* -diff -urp ceph-0.87/src/os/DBObjectMap.h ceph-0.87-pm/src/os/DBObjectMap.h ---- ceph-0.87/src/os/DBObjectMap.h 2014-10-29 19:09:14.000000000 +0100 -+++ ceph-0.87-pm/src/os/DBObjectMap.h 2015-01-29 02:46:59.915044699 +0100 -@@ -17,7 +17,7 @@ - #include "common/Mutex.h" - #include "common/Cond.h" - #include "common/simple_cache.hpp" --#include -+#include - - /** - * DBObjectMap: Implements ObjectMap in terms of KeyValueDB -diff -urp ceph-0.87/src/osd/ECBackend.cc ceph-0.87-pm/src/osd/ECBackend.cc ---- ceph-0.87/src/osd/ECBackend.cc 2014-10-29 19:09:19.000000000 +0100 -+++ ceph-0.87-pm/src/osd/ECBackend.cc 2015-01-29 02:56:47.662703397 +0100 -@@ -13,7 +13,7 @@ - */ - - #include --#include -+#include - #include - #include - -@@ -81,7 +81,7 @@ ostream &operator<<(ostream &lhs, const - lhs << "read_result_t(r=" << rhs.r - << ", errors=" << rhs.errors; - if (rhs.attrs) { -- lhs << ", attrs=" << rhs.attrs; -+ lhs << ", attrs=" << (bool)rhs.attrs; - } else { - lhs << ", noattrs"; - } -diff -urp ceph-0.87/src/osd/ECBackend.h ceph-0.87-pm/src/osd/ECBackend.h ---- ceph-0.87/src/osd/ECBackend.h 2014-10-29 19:09:14.000000000 +0100 -+++ ceph-0.87-pm/src/osd/ECBackend.h 2015-01-29 02:47:01.716013012 +0100 -@@ -18,7 +18,7 @@ - #include "OSD.h" - #include "PGBackend.h" - #include "osd_types.h" --#include -+#include - #include "erasure-code/ErasureCodeInterface.h" - #include "ECTransaction.h" - #include "ECMsgTypes.h" -diff -urp ceph-0.87/src/osd/ECTransaction.cc ceph-0.87-pm/src/osd/ECTransaction.cc ---- ceph-0.87/src/osd/ECTransaction.cc 2014-10-29 19:09:19.000000000 +0100 -+++ ceph-0.87-pm/src/osd/ECTransaction.cc 2015-01-29 02:47:00.229039175 +0100 -@@ -13,7 +13,7 @@ - */ - - #include --#include -+#include - #include - #include - #include -diff -urp ceph-0.87/src/osd/ECTransaction.h ceph-0.87-pm/src/osd/ECTransaction.h ---- ceph-0.87/src/osd/ECTransaction.h 2014-10-29 19:09:14.000000000 +0100 -+++ ceph-0.87-pm/src/osd/ECTransaction.h 2015-01-29 02:47:01.383018871 +0100 -@@ -19,7 +19,7 @@ - #include "PGBackend.h" - #include "osd_types.h" - #include "ECUtil.h" --#include -+#include - #include "erasure-code/ErasureCodeInterface.h" - - class ECTransaction : public PGBackend::PGTransaction { -diff -urp ceph-0.87/src/osd/osd_types.h ceph-0.87-pm/src/osd/osd_types.h ---- ceph-0.87/src/osd/osd_types.h 2014-10-29 19:09:14.000000000 +0100 -+++ ceph-0.87-pm/src/osd/osd_types.h 2015-01-29 02:47:01.400018572 +0100 -@@ -22,7 +22,7 @@ - #include - #include - #include --#include -+#include - - #include "include/rados/rados_types.hpp" - -diff -urp ceph-0.87/src/osd/ReplicatedPG.h ceph-0.87-pm/src/osd/ReplicatedPG.h ---- ceph-0.87/src/osd/ReplicatedPG.h 2014-10-29 19:09:14.000000000 +0100 -+++ ceph-0.87-pm/src/osd/ReplicatedPG.h 2015-01-29 02:47:05.062954123 +0100 -@@ -17,7 +17,7 @@ - #ifndef CEPH_REPLICATEDPG_H - #define CEPH_REPLICATEDPG_H - --#include -+#include - #include - - #include "include/assert.h" -diff -urp ceph-0.87/src/common/map_cacher.hpp ceph-0.87-pm/src/common/map_cacher.hpp ---- ceph-0.87/src/common/map_cacher.hpp 2014-10-29 19:09:14.000000000 +0100 -+++ ceph-0.87-pm/src/common/map_cacher.hpp 2015-01-29 02:48:12.007776242 +0100 -@@ -16,7 +16,7 @@ - #define MAPCACHER_H - - #include --#include -+#include - #include "include/memory.h" - #include - #include diff --git a/ceph-google-gperftools.patch b/ceph-google-gperftools.patch deleted file mode 100644 index 5c24871..0000000 --- a/ceph-google-gperftools.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- ceph-0.80.5/src/perfglue/heap_profiler.cc.orig 2014-08-15 16:05:00.161794290 +0200 -+++ ceph-0.80.5/src/perfglue/heap_profiler.cc 2014-08-15 16:05:04.691794305 +0200 -@@ -12,8 +12,8 @@ - * - */ - --#include --#include -+#include -+#include - #include "heap_profiler.h" - #include "common/environment.h" - #include "common/LogClient.h" diff --git a/ceph.spec b/ceph.spec index 6eef2ea..8cbcd85 100644 --- a/ceph.spec +++ b/ceph.spec @@ -5,19 +5,22 @@ %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")} %endif +%global _hardened_build 1 + ################################################################################# # common ################################################################################# Name: ceph Version: 0.87.1 -Release: 1%{?dist} +Release: 2%{?dist} Epoch: 1 Summary: User space components of the Ceph file system License: GPLv2 Group: System Environment/Base URL: http://ceph.com/ Source0: http://ceph.com/download/%{name}-%{version}.tar.bz2 -Patch0: ceph-google-gperftools.patch +Patch1: 0001-Switch-google-includes-to-gperftools-includes.patch +Patch2: 0002-common-do-not-unlock-rwlock-on-destruction.patch Requires: librbd1 = %{epoch}:%{version}-%{release} Requires: librados2 = %{epoch}:%{version}-%{release} Requires: libcephfs1 = %{epoch}:%{version}-%{release} @@ -411,7 +414,8 @@ python-cephfs instead. ################################################################################# %prep %setup -q -%patch0 -p1 +%patch1 -p1 +%patch2 -p1 %build # Find jni.h @@ -679,7 +683,6 @@ fi # Package removal cleanup if [ "$1" -eq "0" ] ; then rm -rf /var/log/ceph - rm -rf /etc/ceph fi ################################################################################# @@ -805,10 +808,6 @@ fi %post -n librbd1 /sbin/ldconfig -# First, cleanup -rm -f /usr/lib64/qemu/librbd.so.1 -rmdir /usr/lib64/qemu 2>/dev/null || true -rmdir /usr/lib64/ 2>/dev/null || true # If x86_64 and rhel6+, link the library to /usr/lib64/qemu -- rhel hack %ifarch x86_64 %if 0%{?rhel} >= 6 @@ -918,6 +917,13 @@ ln -sf %{_libdir}/librbd.so.1 /usr/lib64/qemu/librbd.so.1 %files -n python-ceph-compat %changelog +* Wed Mar 4 2015 Boris Ranto - 1:0.87.1-2 +- Perform a hardened build +- Use git-formatted patches +- Add patch for pthreads rwlock unlock problem +- Do not remove conf files on uninstall +- Remove the cleanup function, it is only necessary for f20 and f21 + * Wed Feb 25 2015 Boris Ranto - 1:0.87.1-1 - Rebase to latest upstream - Remove boost patch, it is in upstream tarball