diff options
| -rw-r--r-- | cmds/installd/InstalldNativeService.cpp | 76 | ||||
| -rw-r--r-- | cmds/installd/utils.h | 2 | ||||
| -rw-r--r-- | libs/binder/ndk/include_ndk/android/binder_parcel_utils.h | 78 | ||||
| -rwxr-xr-x | libs/binder/ndk/scripts/gen_parcel_helper.py | 6 |
4 files changed, 20 insertions, 142 deletions
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp index e336232aed..f5f74bf04f 100644 --- a/cmds/installd/InstalldNativeService.cpp +++ b/cmds/installd/InstalldNativeService.cpp @@ -77,7 +77,6 @@ namespace installd { static constexpr const char* kCpPath = "/system/bin/cp"; static constexpr const char* kXattrDefault = "user.default"; -static constexpr const char* kPropHasReserved = "vold.has_reserved"; static constexpr const int MIN_RESTRICTED_HOME_SDK_VERSION = 24; // > M @@ -352,55 +351,6 @@ static int prepare_app_dir(const std::string& path, mode_t target_mode, uid_t ui return 0; } -/** - * Ensure that we have a hard-limit quota to protect against abusive apps; - * they should never use more than 90% of blocks or 50% of inodes. - */ -static int prepare_app_quota(const std::unique_ptr<std::string>& uuid ATTRIBUTE_UNUSED, - const std::string& device, uid_t uid) { - // Skip when reserved blocks are protecting us against abusive apps - if (android::base::GetBoolProperty(kPropHasReserved, false)) return 0; - // Skip when device no quotas present - if (device.empty()) return 0; - - struct dqblk dq; - if (quotactl(QCMD(Q_GETQUOTA, USRQUOTA), device.c_str(), uid, - reinterpret_cast<char*>(&dq)) != 0) { - PLOG(WARNING) << "Failed to find quota for " << uid; - return -1; - } - -#if APPLY_HARD_QUOTAS - if ((dq.dqb_bhardlimit == 0) || (dq.dqb_ihardlimit == 0)) { - auto path = create_data_path(uuid ? uuid->c_str() : nullptr); - struct statvfs stat; - if (statvfs(path.c_str(), &stat) != 0) { - PLOG(WARNING) << "Failed to statvfs " << path; - return -1; - } - - dq.dqb_valid = QIF_LIMITS; - dq.dqb_bhardlimit = - (((static_cast<uint64_t>(stat.f_blocks) * stat.f_frsize) / 10) * 9) / QIF_DQBLKSIZE; - dq.dqb_ihardlimit = (stat.f_files / 2); - if (quotactl(QCMD(Q_SETQUOTA, USRQUOTA), device.c_str(), uid, - reinterpret_cast<char*>(&dq)) != 0) { - PLOG(WARNING) << "Failed to set hard quota for " << uid; - return -1; - } else { - LOG(DEBUG) << "Applied hard quotas for " << uid; - return 0; - } - } else { - // Hard quota already set; assume it's reasonable - return 0; - } -#else - // Hard quotas disabled - return 0; -#endif -} - static bool prepare_app_profile_dir(const std::string& packageName, int32_t appId, int32_t userId) { if (!property_get_bool("dalvik.vm.usejitprofiles", false)) { return true; @@ -515,10 +465,6 @@ binder::Status InstalldNativeService::createAppData(const std::unique_ptr<std::s return error("Failed to restorecon " + path); } - if (prepare_app_quota(uuid, findQuotaDeviceForUuid(uuid), uid)) { - return error("Failed to set hard quota " + path); - } - if (!prepare_app_profile_dir(packageName, appId, userId)) { return error("Failed to prepare profiles for " + packageName); } @@ -958,13 +904,6 @@ binder::Status InstalldNativeService::createUserData(const std::unique_ptr<std:: } } - // Data under /data/media doesn't have an app, but we still want - // to limit it to prevent abuse. - if (prepare_app_quota(uuid, findQuotaDeviceForUuid(uuid), - multiuser_get_uid(userId, AID_MEDIA_RW))) { - return error("Failed to set hard quota for media_rw"); - } - return ok(); } @@ -2614,21 +2553,6 @@ binder::Status InstalldNativeService::invalidateMounts() { reinterpret_cast<char*>(&dq)) == 0) { LOG(DEBUG) << "Found quota mount " << source << " at " << target; mQuotaReverseMounts[target] = source; - - // ext4 only enables DQUOT_USAGE_ENABLED by default, so we - // need to kick it again to enable DQUOT_LIMITS_ENABLED. We - // only need hard limits enabled when we're not being protected - // by reserved blocks. - if (!android::base::GetBoolProperty(kPropHasReserved, false)) { - if (quotactl(QCMD(Q_QUOTAON, USRQUOTA), source.c_str(), QFMT_VFS_V1, - nullptr) != 0 && errno != EBUSY) { - PLOG(ERROR) << "Failed to enable USRQUOTA on " << source; - } - if (quotactl(QCMD(Q_QUOTAON, GRPQUOTA), source.c_str(), QFMT_VFS_V1, - nullptr) != 0 && errno != EBUSY) { - PLOG(ERROR) << "Failed to enable GRPQUOTA on " << source; - } - } } } #endif diff --git a/cmds/installd/utils.h b/cmds/installd/utils.h index 5829c4fd14..d05724a8f0 100644 --- a/cmds/installd/utils.h +++ b/cmds/installd/utils.h @@ -36,8 +36,6 @@ #define BYPASS_QUOTA 0 #define BYPASS_SDCARDFS 0 -#define APPLY_HARD_QUOTAS 0 - namespace android { namespace installd { diff --git a/libs/binder/ndk/include_ndk/android/binder_parcel_utils.h b/libs/binder/ndk/include_ndk/android/binder_parcel_utils.h index faeb78fdfa..bf0c956b0d 100644 --- a/libs/binder/ndk/include_ndk/android/binder_parcel_utils.h +++ b/libs/binder/ndk/include_ndk/android/binder_parcel_utils.h @@ -76,34 +76,18 @@ static inline void AParcel_stdVectorSetter(void* vectorData, size_t index, T val (*vec)[index] = value; } -/** - * Writes a vector to the next location in a non-null parcel. - */ -template <typename T> -static inline binder_status_t AParcel_writeVector(AParcel* parcel, const std::vector<T>& vec); - -/** - * Reads a vector to the next location in a non-null parcel. - */ -template <typename T> -static inline binder_status_t AParcel_readVector(const AParcel* parcel, std::vector<T>* vec); - // @START /** * Writes a vector of int32_t to the next location in a non-null parcel. */ -template <> -inline binder_status_t AParcel_writeVector<int32_t>(AParcel* parcel, - const std::vector<int32_t>& vec) { +inline binder_status_t AParcel_writeVector(AParcel* parcel, const std::vector<int32_t>& vec) { return AParcel_writeInt32Array(parcel, vec.data(), vec.size()); } /** * Reads a vector of int32_t from the next location in a non-null parcel. */ -template <> -inline binder_status_t AParcel_readVector<int32_t>(const AParcel* parcel, - std::vector<int32_t>* vec) { +inline binder_status_t AParcel_readVector(const AParcel* parcel, std::vector<int32_t>* vec) { void* vectorData = static_cast<void*>(vec); return AParcel_readInt32Array(parcel, &vectorData, &AParcel_stdVectorReallocator<int32_t>, AParcel_stdVectorGetter<int32_t>); @@ -112,18 +96,14 @@ inline binder_status_t AParcel_readVector<int32_t>(const AParcel* parcel, /** * Writes a vector of uint32_t to the next location in a non-null parcel. */ -template <> -inline binder_status_t AParcel_writeVector<uint32_t>(AParcel* parcel, - const std::vector<uint32_t>& vec) { +inline binder_status_t AParcel_writeVector(AParcel* parcel, const std::vector<uint32_t>& vec) { return AParcel_writeUint32Array(parcel, vec.data(), vec.size()); } /** * Reads a vector of uint32_t from the next location in a non-null parcel. */ -template <> -inline binder_status_t AParcel_readVector<uint32_t>(const AParcel* parcel, - std::vector<uint32_t>* vec) { +inline binder_status_t AParcel_readVector(const AParcel* parcel, std::vector<uint32_t>* vec) { void* vectorData = static_cast<void*>(vec); return AParcel_readUint32Array(parcel, &vectorData, &AParcel_stdVectorReallocator<uint32_t>, AParcel_stdVectorGetter<uint32_t>); @@ -132,18 +112,14 @@ inline binder_status_t AParcel_readVector<uint32_t>(const AParcel* parcel, /** * Writes a vector of int64_t to the next location in a non-null parcel. */ -template <> -inline binder_status_t AParcel_writeVector<int64_t>(AParcel* parcel, - const std::vector<int64_t>& vec) { +inline binder_status_t AParcel_writeVector(AParcel* parcel, const std::vector<int64_t>& vec) { return AParcel_writeInt64Array(parcel, vec.data(), vec.size()); } /** * Reads a vector of int64_t from the next location in a non-null parcel. */ -template <> -inline binder_status_t AParcel_readVector<int64_t>(const AParcel* parcel, - std::vector<int64_t>* vec) { +inline binder_status_t AParcel_readVector(const AParcel* parcel, std::vector<int64_t>* vec) { void* vectorData = static_cast<void*>(vec); return AParcel_readInt64Array(parcel, &vectorData, &AParcel_stdVectorReallocator<int64_t>, AParcel_stdVectorGetter<int64_t>); @@ -152,18 +128,14 @@ inline binder_status_t AParcel_readVector<int64_t>(const AParcel* parcel, /** * Writes a vector of uint64_t to the next location in a non-null parcel. */ -template <> -inline binder_status_t AParcel_writeVector<uint64_t>(AParcel* parcel, - const std::vector<uint64_t>& vec) { +inline binder_status_t AParcel_writeVector(AParcel* parcel, const std::vector<uint64_t>& vec) { return AParcel_writeUint64Array(parcel, vec.data(), vec.size()); } /** * Reads a vector of uint64_t from the next location in a non-null parcel. */ -template <> -inline binder_status_t AParcel_readVector<uint64_t>(const AParcel* parcel, - std::vector<uint64_t>* vec) { +inline binder_status_t AParcel_readVector(const AParcel* parcel, std::vector<uint64_t>* vec) { void* vectorData = static_cast<void*>(vec); return AParcel_readUint64Array(parcel, &vectorData, &AParcel_stdVectorReallocator<uint64_t>, AParcel_stdVectorGetter<uint64_t>); @@ -172,16 +144,14 @@ inline binder_status_t AParcel_readVector<uint64_t>(const AParcel* parcel, /** * Writes a vector of float to the next location in a non-null parcel. */ -template <> -inline binder_status_t AParcel_writeVector<float>(AParcel* parcel, const std::vector<float>& vec) { +inline binder_status_t AParcel_writeVector(AParcel* parcel, const std::vector<float>& vec) { return AParcel_writeFloatArray(parcel, vec.data(), vec.size()); } /** * Reads a vector of float from the next location in a non-null parcel. */ -template <> -inline binder_status_t AParcel_readVector<float>(const AParcel* parcel, std::vector<float>* vec) { +inline binder_status_t AParcel_readVector(const AParcel* parcel, std::vector<float>* vec) { void* vectorData = static_cast<void*>(vec); return AParcel_readFloatArray(parcel, &vectorData, &AParcel_stdVectorReallocator<float>, AParcel_stdVectorGetter<float>); @@ -190,17 +160,14 @@ inline binder_status_t AParcel_readVector<float>(const AParcel* parcel, std::vec /** * Writes a vector of double to the next location in a non-null parcel. */ -template <> -inline binder_status_t AParcel_writeVector<double>(AParcel* parcel, - const std::vector<double>& vec) { +inline binder_status_t AParcel_writeVector(AParcel* parcel, const std::vector<double>& vec) { return AParcel_writeDoubleArray(parcel, vec.data(), vec.size()); } /** * Reads a vector of double from the next location in a non-null parcel. */ -template <> -inline binder_status_t AParcel_readVector<double>(const AParcel* parcel, std::vector<double>* vec) { +inline binder_status_t AParcel_readVector(const AParcel* parcel, std::vector<double>* vec) { void* vectorData = static_cast<void*>(vec); return AParcel_readDoubleArray(parcel, &vectorData, &AParcel_stdVectorReallocator<double>, AParcel_stdVectorGetter<double>); @@ -209,8 +176,7 @@ inline binder_status_t AParcel_readVector<double>(const AParcel* parcel, std::ve /** * Writes a vector of bool to the next location in a non-null parcel. */ -template <> -inline binder_status_t AParcel_writeVector<bool>(AParcel* parcel, const std::vector<bool>& vec) { +inline binder_status_t AParcel_writeVector(AParcel* parcel, const std::vector<bool>& vec) { return AParcel_writeBoolArray(parcel, static_cast<const void*>(&vec), AParcel_stdVectorGetter<bool>, vec.size()); } @@ -218,8 +184,7 @@ inline binder_status_t AParcel_writeVector<bool>(AParcel* parcel, const std::vec /** * Reads a vector of bool from the next location in a non-null parcel. */ -template <> -inline binder_status_t AParcel_readVector<bool>(const AParcel* parcel, std::vector<bool>* vec) { +inline binder_status_t AParcel_readVector(const AParcel* parcel, std::vector<bool>* vec) { void* vectorData = static_cast<void*>(vec); return AParcel_readBoolArray(parcel, &vectorData, &AParcel_stdVectorReallocator<bool>, AParcel_stdVectorSetter<bool>); @@ -228,18 +193,14 @@ inline binder_status_t AParcel_readVector<bool>(const AParcel* parcel, std::vect /** * Writes a vector of char16_t to the next location in a non-null parcel. */ -template <> -inline binder_status_t AParcel_writeVector<char16_t>(AParcel* parcel, - const std::vector<char16_t>& vec) { +inline binder_status_t AParcel_writeVector(AParcel* parcel, const std::vector<char16_t>& vec) { return AParcel_writeCharArray(parcel, vec.data(), vec.size()); } /** * Reads a vector of char16_t from the next location in a non-null parcel. */ -template <> -inline binder_status_t AParcel_readVector<char16_t>(const AParcel* parcel, - std::vector<char16_t>* vec) { +inline binder_status_t AParcel_readVector(const AParcel* parcel, std::vector<char16_t>* vec) { void* vectorData = static_cast<void*>(vec); return AParcel_readCharArray(parcel, &vectorData, &AParcel_stdVectorReallocator<char16_t>, AParcel_stdVectorGetter<char16_t>); @@ -248,17 +209,14 @@ inline binder_status_t AParcel_readVector<char16_t>(const AParcel* parcel, /** * Writes a vector of int8_t to the next location in a non-null parcel. */ -template <> -inline binder_status_t AParcel_writeVector<int8_t>(AParcel* parcel, - const std::vector<int8_t>& vec) { +inline binder_status_t AParcel_writeVector(AParcel* parcel, const std::vector<int8_t>& vec) { return AParcel_writeByteArray(parcel, vec.data(), vec.size()); } /** * Reads a vector of int8_t from the next location in a non-null parcel. */ -template <> -inline binder_status_t AParcel_readVector<int8_t>(const AParcel* parcel, std::vector<int8_t>* vec) { +inline binder_status_t AParcel_readVector(const AParcel* parcel, std::vector<int8_t>* vec) { void* vectorData = static_cast<void*>(vec); return AParcel_readByteArray(parcel, &vectorData, &AParcel_stdVectorReallocator<int8_t>, AParcel_stdVectorGetter<int8_t>); diff --git a/libs/binder/ndk/scripts/gen_parcel_helper.py b/libs/binder/ndk/scripts/gen_parcel_helper.py index 45f8d06883..2cf10d3b7a 100755 --- a/libs/binder/ndk/scripts/gen_parcel_helper.py +++ b/libs/binder/ndk/scripts/gen_parcel_helper.py @@ -152,8 +152,7 @@ def main(): cpp_helper += "/**\n" cpp_helper += " * Writes a vector of " + cpp + " to the next location in a non-null parcel.\n" cpp_helper += " */\n" - cpp_helper += "template<>\n" - cpp_helper += "inline binder_status_t AParcel_writeVector<" + cpp + ">(AParcel* parcel, const std::vector<" + cpp + ">& vec) {\n" + cpp_helper += "inline binder_status_t AParcel_writeVector(AParcel* parcel, const std::vector<" + cpp + ">& vec) {\n" write_args = "vec.data()" if nca: write_args = "static_cast<const void*>(&vec), AParcel_stdVectorGetter<" + cpp + ">" cpp_helper += " return AParcel_write" + pretty + "Array(parcel, " + write_args + ", vec.size());\n" @@ -162,8 +161,7 @@ def main(): cpp_helper += "/**\n" cpp_helper += " * Reads a vector of " + cpp + " from the next location in a non-null parcel.\n" cpp_helper += " */\n" - cpp_helper += "template<>\n" - cpp_helper += "inline binder_status_t AParcel_readVector<" + cpp + ">(const AParcel* parcel, std::vector<" + cpp + ">* vec) {\n" + cpp_helper += "inline binder_status_t AParcel_readVector(const AParcel* parcel, std::vector<" + cpp + ">* vec) {\n" cpp_helper += " void* vectorData = static_cast<void*>(vec);\n" read_args = [] read_args += ["parcel"] |