Loading cmds/installd/InstalldNativeService.cpp +0 −76 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -343,55 +342,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; Loading Loading @@ -506,10 +456,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); } Loading Loading @@ -988,13 +934,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(); } Loading Loading @@ -2644,21 +2583,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 Loading cmds/installd/utils.h +0 −2 Original line number Diff line number Diff line Loading @@ -36,8 +36,6 @@ #define BYPASS_QUOTA 0 #define BYPASS_SDCARDFS 0 #define APPLY_HARD_QUOTAS 0 namespace android { namespace installd { Loading cmds/servicemanager/servicemanager.rc +1 −0 Original line number Diff line number Diff line Loading @@ -13,5 +13,6 @@ service servicemanager /system/bin/servicemanager onrestart restart cameraserver onrestart restart keystore onrestart restart gatekeeperd onrestart restart thermalservice writepid /dev/cpuset/system-background/tasks shutdown critical libs/binder/IMemory.cpp +28 −20 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ public: virtual void* getBase() const; virtual size_t getSize() const; virtual uint32_t getFlags() const; virtual uint32_t getOffset() const; off_t getOffset() const override; private: friend class IMemory; Loading @@ -113,7 +113,7 @@ private: mutable void* mBase; mutable size_t mSize; mutable uint32_t mFlags; mutable uint32_t mOffset; mutable off_t mOffset; mutable bool mRealHeap; mutable Mutex mLock; }; Loading Loading @@ -187,13 +187,16 @@ sp<IMemoryHeap> BpMemory::getMemory(ssize_t* offset, size_t* size) const data.writeInterfaceToken(IMemory::getInterfaceDescriptor()); if (remote()->transact(GET_MEMORY, data, &reply) == NO_ERROR) { sp<IBinder> heap = reply.readStrongBinder(); ssize_t o = reply.readInt32(); size_t s = reply.readInt32(); if (heap != nullptr) { mHeap = interface_cast<IMemoryHeap>(heap); if (mHeap != nullptr) { const int64_t offset64 = reply.readInt64(); const uint64_t size64 = reply.readUint64(); const ssize_t o = (ssize_t)offset64; const size_t s = (size_t)size64; size_t heapSize = mHeap->getSize(); if (s <= heapSize if (s == size64 && o == offset64 // ILP32 bounds check && s <= heapSize && o >= 0 && (static_cast<size_t>(o) <= heapSize - s)) { mOffset = o; Loading Loading @@ -233,8 +236,8 @@ status_t BnMemory::onTransact( ssize_t offset; size_t size; reply->writeStrongBinder( IInterface::asBinder(getMemory(&offset, &size)) ); reply->writeInt32(offset); reply->writeInt32(size); reply->writeInt64(offset); reply->writeUint64(size); return NO_ERROR; } break; default: Loading Loading @@ -313,18 +316,23 @@ void BpMemoryHeap::assertReallyMapped() const data.writeInterfaceToken(IMemoryHeap::getInterfaceDescriptor()); status_t err = remote()->transact(HEAP_ID, data, &reply); int parcel_fd = reply.readFileDescriptor(); ssize_t size = reply.readInt32(); uint32_t flags = reply.readInt32(); uint32_t offset = reply.readInt32(); ALOGE_IF(err, "binder=%p transaction failed fd=%d, size=%zd, err=%d (%s)", const uint64_t size64 = reply.readUint64(); const int64_t offset64 = reply.readInt64(); const uint32_t flags = reply.readUint32(); const size_t size = (size_t)size64; const off_t offset = (off_t)offset64; if (err != NO_ERROR || // failed transaction size != size64 || offset != offset64) { // ILP32 size check ALOGE("binder=%p transaction failed fd=%d, size=%zu, err=%d (%s)", IInterface::asBinder(this).get(), parcel_fd, size, err, strerror(-err)); return; } Mutex::Autolock _l(mLock); if (mHeapId.load(memory_order_relaxed) == -1) { int fd = fcntl(parcel_fd, F_DUPFD_CLOEXEC, 0); ALOGE_IF(fd==-1, "cannot dup fd=%d, size=%zd, err=%d (%s)", ALOGE_IF(fd == -1, "cannot dup fd=%d, size=%zu, err=%d (%s)", parcel_fd, size, err, strerror(errno)); int access = PROT_READ; Loading @@ -334,7 +342,7 @@ void BpMemoryHeap::assertReallyMapped() const mRealHeap = true; mBase = mmap(nullptr, size, access, MAP_SHARED, fd, offset); if (mBase == MAP_FAILED) { ALOGE("cannot map BpMemoryHeap (binder=%p), size=%zd, fd=%d (%s)", ALOGE("cannot map BpMemoryHeap (binder=%p), size=%zu, fd=%d (%s)", IInterface::asBinder(this).get(), size, fd, strerror(errno)); close(fd); } else { Loading Loading @@ -368,7 +376,7 @@ uint32_t BpMemoryHeap::getFlags() const { return mFlags; } uint32_t BpMemoryHeap::getOffset() const { off_t BpMemoryHeap::getOffset() const { assertMapped(); return mOffset; } Loading @@ -390,9 +398,9 @@ status_t BnMemoryHeap::onTransact( case HEAP_ID: { CHECK_INTERFACE(IMemoryHeap, data, reply); reply->writeFileDescriptor(getHeapID()); reply->writeInt32(getSize()); reply->writeInt32(getFlags()); reply->writeInt32(getOffset()); reply->writeUint64(getSize()); reply->writeInt64(getOffset()); reply->writeUint32(getFlags()); return NO_ERROR; } break; default: Loading libs/binder/MemoryHeapBase.cpp +17 −10 Original line number Diff line number Diff line Loading @@ -76,7 +76,7 @@ MemoryHeapBase::MemoryHeapBase(const char* device, size_t size, uint32_t flags) } } MemoryHeapBase::MemoryHeapBase(int fd, size_t size, uint32_t flags, uint32_t offset) MemoryHeapBase::MemoryHeapBase(int fd, size_t size, uint32_t flags, off_t offset) : mFD(-1), mSize(0), mBase(MAP_FAILED), mFlags(flags), mDevice(nullptr), mNeedUnmap(false), mOffset(0) { Loading @@ -85,7 +85,7 @@ MemoryHeapBase::MemoryHeapBase(int fd, size_t size, uint32_t flags, uint32_t off mapfd(fcntl(fd, F_DUPFD_CLOEXEC, 0), size, offset); } status_t MemoryHeapBase::init(int fd, void *base, int size, int flags, const char* device) status_t MemoryHeapBase::init(int fd, void *base, size_t size, int flags, const char* device) { if (mFD != -1) { return INVALID_OPERATION; Loading @@ -98,13 +98,20 @@ status_t MemoryHeapBase::init(int fd, void *base, int size, int flags, const cha return NO_ERROR; } status_t MemoryHeapBase::mapfd(int fd, size_t size, uint32_t offset) status_t MemoryHeapBase::mapfd(int fd, size_t size, off_t offset) { if (size == 0) { // try to figure out the size automatically struct stat sb; if (fstat(fd, &sb) == 0) size = sb.st_size; if (fstat(fd, &sb) == 0) { size = (size_t)sb.st_size; // sb.st_size is off_t which on ILP32 may be 64 bits while size_t is 32 bits. if ((off_t)size != sb.st_size) { ALOGE("%s: size of file %lld cannot fit in memory", __func__, (long long)sb.st_size); return INVALID_OPERATION; } } // if it didn't work, let mmap() fail. } Loading @@ -112,12 +119,12 @@ status_t MemoryHeapBase::mapfd(int fd, size_t size, uint32_t offset) void* base = (uint8_t*)mmap(nullptr, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, offset); if (base == MAP_FAILED) { ALOGE("mmap(fd=%d, size=%u) failed (%s)", fd, uint32_t(size), strerror(errno)); ALOGE("mmap(fd=%d, size=%zu) failed (%s)", fd, size, strerror(errno)); close(fd); return -errno; } //ALOGD("mmap(fd=%d, base=%p, size=%lu)", fd, base, size); //ALOGD("mmap(fd=%d, base=%p, size=%zu)", fd, base, size); mBase = base; mNeedUnmap = true; } else { Loading @@ -140,7 +147,7 @@ void MemoryHeapBase::dispose() int fd = android_atomic_or(-1, &mFD); if (fd >= 0) { if (mNeedUnmap) { //ALOGD("munmap(fd=%d, base=%p, size=%lu)", fd, mBase, mSize); //ALOGD("munmap(fd=%d, base=%p, size=%zu)", fd, mBase, mSize); munmap(mBase, mSize); } mBase = nullptr; Loading Loading @@ -169,7 +176,7 @@ const char* MemoryHeapBase::getDevice() const { return mDevice; } uint32_t MemoryHeapBase::getOffset() const { off_t MemoryHeapBase::getOffset() const { return mOffset; } Loading Loading
cmds/installd/InstalldNativeService.cpp +0 −76 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -343,55 +342,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; Loading Loading @@ -506,10 +456,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); } Loading Loading @@ -988,13 +934,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(); } Loading Loading @@ -2644,21 +2583,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 Loading
cmds/installd/utils.h +0 −2 Original line number Diff line number Diff line Loading @@ -36,8 +36,6 @@ #define BYPASS_QUOTA 0 #define BYPASS_SDCARDFS 0 #define APPLY_HARD_QUOTAS 0 namespace android { namespace installd { Loading
cmds/servicemanager/servicemanager.rc +1 −0 Original line number Diff line number Diff line Loading @@ -13,5 +13,6 @@ service servicemanager /system/bin/servicemanager onrestart restart cameraserver onrestart restart keystore onrestart restart gatekeeperd onrestart restart thermalservice writepid /dev/cpuset/system-background/tasks shutdown critical
libs/binder/IMemory.cpp +28 −20 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ public: virtual void* getBase() const; virtual size_t getSize() const; virtual uint32_t getFlags() const; virtual uint32_t getOffset() const; off_t getOffset() const override; private: friend class IMemory; Loading @@ -113,7 +113,7 @@ private: mutable void* mBase; mutable size_t mSize; mutable uint32_t mFlags; mutable uint32_t mOffset; mutable off_t mOffset; mutable bool mRealHeap; mutable Mutex mLock; }; Loading Loading @@ -187,13 +187,16 @@ sp<IMemoryHeap> BpMemory::getMemory(ssize_t* offset, size_t* size) const data.writeInterfaceToken(IMemory::getInterfaceDescriptor()); if (remote()->transact(GET_MEMORY, data, &reply) == NO_ERROR) { sp<IBinder> heap = reply.readStrongBinder(); ssize_t o = reply.readInt32(); size_t s = reply.readInt32(); if (heap != nullptr) { mHeap = interface_cast<IMemoryHeap>(heap); if (mHeap != nullptr) { const int64_t offset64 = reply.readInt64(); const uint64_t size64 = reply.readUint64(); const ssize_t o = (ssize_t)offset64; const size_t s = (size_t)size64; size_t heapSize = mHeap->getSize(); if (s <= heapSize if (s == size64 && o == offset64 // ILP32 bounds check && s <= heapSize && o >= 0 && (static_cast<size_t>(o) <= heapSize - s)) { mOffset = o; Loading Loading @@ -233,8 +236,8 @@ status_t BnMemory::onTransact( ssize_t offset; size_t size; reply->writeStrongBinder( IInterface::asBinder(getMemory(&offset, &size)) ); reply->writeInt32(offset); reply->writeInt32(size); reply->writeInt64(offset); reply->writeUint64(size); return NO_ERROR; } break; default: Loading Loading @@ -313,18 +316,23 @@ void BpMemoryHeap::assertReallyMapped() const data.writeInterfaceToken(IMemoryHeap::getInterfaceDescriptor()); status_t err = remote()->transact(HEAP_ID, data, &reply); int parcel_fd = reply.readFileDescriptor(); ssize_t size = reply.readInt32(); uint32_t flags = reply.readInt32(); uint32_t offset = reply.readInt32(); ALOGE_IF(err, "binder=%p transaction failed fd=%d, size=%zd, err=%d (%s)", const uint64_t size64 = reply.readUint64(); const int64_t offset64 = reply.readInt64(); const uint32_t flags = reply.readUint32(); const size_t size = (size_t)size64; const off_t offset = (off_t)offset64; if (err != NO_ERROR || // failed transaction size != size64 || offset != offset64) { // ILP32 size check ALOGE("binder=%p transaction failed fd=%d, size=%zu, err=%d (%s)", IInterface::asBinder(this).get(), parcel_fd, size, err, strerror(-err)); return; } Mutex::Autolock _l(mLock); if (mHeapId.load(memory_order_relaxed) == -1) { int fd = fcntl(parcel_fd, F_DUPFD_CLOEXEC, 0); ALOGE_IF(fd==-1, "cannot dup fd=%d, size=%zd, err=%d (%s)", ALOGE_IF(fd == -1, "cannot dup fd=%d, size=%zu, err=%d (%s)", parcel_fd, size, err, strerror(errno)); int access = PROT_READ; Loading @@ -334,7 +342,7 @@ void BpMemoryHeap::assertReallyMapped() const mRealHeap = true; mBase = mmap(nullptr, size, access, MAP_SHARED, fd, offset); if (mBase == MAP_FAILED) { ALOGE("cannot map BpMemoryHeap (binder=%p), size=%zd, fd=%d (%s)", ALOGE("cannot map BpMemoryHeap (binder=%p), size=%zu, fd=%d (%s)", IInterface::asBinder(this).get(), size, fd, strerror(errno)); close(fd); } else { Loading Loading @@ -368,7 +376,7 @@ uint32_t BpMemoryHeap::getFlags() const { return mFlags; } uint32_t BpMemoryHeap::getOffset() const { off_t BpMemoryHeap::getOffset() const { assertMapped(); return mOffset; } Loading @@ -390,9 +398,9 @@ status_t BnMemoryHeap::onTransact( case HEAP_ID: { CHECK_INTERFACE(IMemoryHeap, data, reply); reply->writeFileDescriptor(getHeapID()); reply->writeInt32(getSize()); reply->writeInt32(getFlags()); reply->writeInt32(getOffset()); reply->writeUint64(getSize()); reply->writeInt64(getOffset()); reply->writeUint32(getFlags()); return NO_ERROR; } break; default: Loading
libs/binder/MemoryHeapBase.cpp +17 −10 Original line number Diff line number Diff line Loading @@ -76,7 +76,7 @@ MemoryHeapBase::MemoryHeapBase(const char* device, size_t size, uint32_t flags) } } MemoryHeapBase::MemoryHeapBase(int fd, size_t size, uint32_t flags, uint32_t offset) MemoryHeapBase::MemoryHeapBase(int fd, size_t size, uint32_t flags, off_t offset) : mFD(-1), mSize(0), mBase(MAP_FAILED), mFlags(flags), mDevice(nullptr), mNeedUnmap(false), mOffset(0) { Loading @@ -85,7 +85,7 @@ MemoryHeapBase::MemoryHeapBase(int fd, size_t size, uint32_t flags, uint32_t off mapfd(fcntl(fd, F_DUPFD_CLOEXEC, 0), size, offset); } status_t MemoryHeapBase::init(int fd, void *base, int size, int flags, const char* device) status_t MemoryHeapBase::init(int fd, void *base, size_t size, int flags, const char* device) { if (mFD != -1) { return INVALID_OPERATION; Loading @@ -98,13 +98,20 @@ status_t MemoryHeapBase::init(int fd, void *base, int size, int flags, const cha return NO_ERROR; } status_t MemoryHeapBase::mapfd(int fd, size_t size, uint32_t offset) status_t MemoryHeapBase::mapfd(int fd, size_t size, off_t offset) { if (size == 0) { // try to figure out the size automatically struct stat sb; if (fstat(fd, &sb) == 0) size = sb.st_size; if (fstat(fd, &sb) == 0) { size = (size_t)sb.st_size; // sb.st_size is off_t which on ILP32 may be 64 bits while size_t is 32 bits. if ((off_t)size != sb.st_size) { ALOGE("%s: size of file %lld cannot fit in memory", __func__, (long long)sb.st_size); return INVALID_OPERATION; } } // if it didn't work, let mmap() fail. } Loading @@ -112,12 +119,12 @@ status_t MemoryHeapBase::mapfd(int fd, size_t size, uint32_t offset) void* base = (uint8_t*)mmap(nullptr, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, offset); if (base == MAP_FAILED) { ALOGE("mmap(fd=%d, size=%u) failed (%s)", fd, uint32_t(size), strerror(errno)); ALOGE("mmap(fd=%d, size=%zu) failed (%s)", fd, size, strerror(errno)); close(fd); return -errno; } //ALOGD("mmap(fd=%d, base=%p, size=%lu)", fd, base, size); //ALOGD("mmap(fd=%d, base=%p, size=%zu)", fd, base, size); mBase = base; mNeedUnmap = true; } else { Loading @@ -140,7 +147,7 @@ void MemoryHeapBase::dispose() int fd = android_atomic_or(-1, &mFD); if (fd >= 0) { if (mNeedUnmap) { //ALOGD("munmap(fd=%d, base=%p, size=%lu)", fd, mBase, mSize); //ALOGD("munmap(fd=%d, base=%p, size=%zu)", fd, mBase, mSize); munmap(mBase, mSize); } mBase = nullptr; Loading Loading @@ -169,7 +176,7 @@ const char* MemoryHeapBase::getDevice() const { return mDevice; } uint32_t MemoryHeapBase::getOffset() const { off_t MemoryHeapBase::getOffset() const { return mOffset; } Loading