Merge changes from topic 'update-verified-priority-bump' into oc-dev
* changes:
init.rc: launch update_verifier with exec_start
init: replace property_get with its android::base equivalent
init: remove unused cutils includes
init: add exec_start command
diff --git a/init/init.cpp b/init/init.cpp
index 4249115..a1d9f1b 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -875,6 +875,34 @@
}
}
+// The files and directories that were created before initial sepolicy load
+// need to have their security context restored to the proper value.
+// This must happen before /dev is populated by ueventd.
+static void selinux_restore_context() {
+ LOG(INFO) << "Running restorecon...";
+ restorecon("/dev");
+ restorecon("/dev/kmsg");
+ restorecon("/dev/socket");
+ restorecon("/dev/random");
+ restorecon("/dev/urandom");
+ restorecon("/dev/__properties__");
+
+ restorecon("/file_contexts.bin");
+ restorecon("/plat_file_contexts");
+ restorecon("/nonplat_file_contexts");
+ restorecon("/plat_property_contexts");
+ restorecon("/nonplat_property_contexts");
+ restorecon("/plat_seapp_contexts");
+ restorecon("/nonplat_seapp_contexts");
+ restorecon("/plat_service_contexts");
+ restorecon("/nonplat_service_contexts");
+ restorecon("/sepolicy");
+
+ restorecon("/sys", SELINUX_ANDROID_RESTORECON_RECURSE);
+ restorecon("/dev/block", SELINUX_ANDROID_RESTORECON_RECURSE);
+ restorecon("/dev/device-mapper");
+}
+
// Set the UDC controller for the ConfigFS USB Gadgets.
// Read the UDC controller in use from "/sys/class/udc".
// In case of multiple UDC controllers select the first one.
@@ -1213,22 +1241,7 @@
// Now set up SELinux for second stage.
selinux_initialize(false);
-
- // These directories were necessarily created before initial policy load
- // and therefore need their security context restored to the proper value.
- // This must happen before /dev is populated by ueventd.
- LOG(INFO) << "Running restorecon...";
- restorecon("/dev");
- restorecon("/dev/kmsg");
- restorecon("/dev/socket");
- restorecon("/dev/random");
- restorecon("/dev/urandom");
- restorecon("/dev/__properties__");
- restorecon("/plat_property_contexts");
- restorecon("/nonplat_property_contexts");
- restorecon("/sys", SELINUX_ANDROID_RESTORECON_RECURSE);
- restorecon("/dev/block", SELINUX_ANDROID_RESTORECON_RECURSE);
- restorecon("/dev/device-mapper");
+ selinux_restore_context();
epoll_fd = epoll_create1(EPOLL_CLOEXEC);
if (epoll_fd == -1) {
diff --git a/libutils/RefBase.cpp b/libutils/RefBase.cpp
index 0d98db9..24737b9 100644
--- a/libutils/RefBase.cpp
+++ b/libutils/RefBase.cpp
@@ -760,6 +760,4 @@
ref->mRefs->renameWeakRefId(old_id, new_id);
}
-VirtualLightRefBase::~VirtualLightRefBase() {}
-
}; // namespace android
diff --git a/libutils/include/utils/LightRefBase.h b/libutils/include/utils/LightRefBase.h
new file mode 100644
index 0000000..65257ed
--- /dev/null
+++ b/libutils/include/utils/LightRefBase.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+/*
+ * See documentation in RefBase.h
+ */
+
+#include <atomic>
+
+#include <sys/types.h>
+
+namespace android {
+
+class ReferenceRenamer;
+
+template <class T>
+class LightRefBase
+{
+public:
+ inline LightRefBase() : mCount(0) { }
+ inline void incStrong(__attribute__((unused)) const void* id) const {
+ mCount.fetch_add(1, std::memory_order_relaxed);
+ }
+ inline void decStrong(__attribute__((unused)) const void* id) const {
+ if (mCount.fetch_sub(1, std::memory_order_release) == 1) {
+ std::atomic_thread_fence(std::memory_order_acquire);
+ delete static_cast<const T*>(this);
+ }
+ }
+ //! DEBUGGING ONLY: Get current strong ref count.
+ inline int32_t getStrongCount() const {
+ return mCount.load(std::memory_order_relaxed);
+ }
+
+ typedef LightRefBase<T> basetype;
+
+protected:
+ inline ~LightRefBase() { }
+
+private:
+ friend class ReferenceMover;
+ inline static void renameRefs(size_t /*n*/, const ReferenceRenamer& /*renamer*/) { }
+ inline static void renameRefId(T* /*ref*/, const void* /*old_id*/ , const void* /*new_id*/) { }
+
+private:
+ mutable std::atomic<int32_t> mCount;
+};
+
+
+// This is a wrapper around LightRefBase that simply enforces a virtual
+// destructor to eliminate the template requirement of LightRefBase
+class VirtualLightRefBase : public LightRefBase<VirtualLightRefBase> {
+public:
+ virtual ~VirtualLightRefBase() = default;
+};
+
+}; // namespace android
diff --git a/libutils/include/utils/RefBase.h b/libutils/include/utils/RefBase.h
index a61ea58..223b666 100644
--- a/libutils/include/utils/RefBase.h
+++ b/libutils/include/utils/RefBase.h
@@ -177,6 +177,9 @@
#include <stdlib.h>
#include <string.h>
+// LightRefBase used to be declared in this header, so we have to include it
+#include <utils/LightRefBase.h>
+
#include <utils/StrongPointer.h>
#include <utils/TypeHelpers.h>
@@ -216,7 +219,7 @@
class ReferenceRenamer {
protected:
- // destructor is purposedly not virtual so we avoid code overhead from
+ // destructor is purposely not virtual so we avoid code overhead from
// subclasses; we have to make it protected to guarantee that it
// cannot be called from this base class (and to make strict compilers
// happy).
@@ -246,13 +249,13 @@
{
public:
RefBase* refBase() const;
-
+
void incWeak(const void* id);
void decWeak(const void* id);
-
+
// acquires a strong reference if there is already one.
bool attemptIncStrong(const void* id);
-
+
// acquires a weak reference if there is already one.
// This is not always safe. see ProcessState.cpp and BpBinder.cpp
// for proper use.
@@ -268,12 +271,12 @@
// enable -- enable/disable tracking
// retain -- when tracking is enable, if true, then we save a stack trace
// for each reference and dereference; when retain == false, we
- // match up references and dereferences and keep only the
+ // match up references and dereferences and keep only the
// outstanding ones.
-
+
void trackMe(bool enable, bool retain);
};
-
+
weakref_type* createWeak(const void* id) const;
weakref_type* getWeakRefs() const;
@@ -345,54 +348,12 @@
// ---------------------------------------------------------------------------
-template <class T>
-class LightRefBase
-{
-public:
- inline LightRefBase() : mCount(0) { }
- inline void incStrong(__attribute__((unused)) const void* id) const {
- mCount.fetch_add(1, std::memory_order_relaxed);
- }
- inline void decStrong(__attribute__((unused)) const void* id) const {
- if (mCount.fetch_sub(1, std::memory_order_release) == 1) {
- std::atomic_thread_fence(std::memory_order_acquire);
- delete static_cast<const T*>(this);
- }
- }
- //! DEBUGGING ONLY: Get current strong ref count.
- inline int32_t getStrongCount() const {
- return mCount.load(std::memory_order_relaxed);
- }
-
- typedef LightRefBase<T> basetype;
-
-protected:
- inline ~LightRefBase() { }
-
-private:
- friend class ReferenceMover;
- inline static void renameRefs(size_t /*n*/, const ReferenceRenamer& /*renamer*/) { }
- inline static void renameRefId(T* /*ref*/, const void* /*old_id*/ , const void* /*new_id*/) { }
-
-private:
- mutable std::atomic<int32_t> mCount;
-};
-
-// This is a wrapper around LightRefBase that simply enforces a virtual
-// destructor to eliminate the template requirement of LightRefBase
-class VirtualLightRefBase : public LightRefBase<VirtualLightRefBase> {
-public:
- virtual ~VirtualLightRefBase();
-};
-
-// ---------------------------------------------------------------------------
-
template <typename T>
class wp
{
public:
typedef typename RefBase::weakref_type weakref_type;
-
+
inline wp() : m_ptr(0) { }
wp(T* other); // NOLINT(implicit)
@@ -403,31 +364,31 @@
template<typename U> wp(const wp<U>& other); // NOLINT(implicit)
~wp();
-
+
// Assignment
wp& operator = (T* other);
wp& operator = (const wp<T>& other);
wp& operator = (const sp<T>& other);
-
+
template<typename U> wp& operator = (U* other);
template<typename U> wp& operator = (const wp<U>& other);
template<typename U> wp& operator = (const sp<U>& other);
-
+
void set_object_and_refs(T* other, weakref_type* refs);
// promotion to sp
-
+
sp<T> promote() const;
// Reset
-
+
void clear();
// Accessors
-
+
inline weakref_type* get_refs() const { return m_refs; }
-
+
inline T* unsafe_get() const { return m_ptr; }
// Operators