update new sdk
This commit is contained in:
parent
f33907443a
commit
744c72c133
1643 changed files with 83006 additions and 28021 deletions
10
android/system/libhidl/libhidlmemory/mapping.cpp
Normal file → Executable file
10
android/system/libhidl/libhidlmemory/mapping.cpp
Normal file → Executable file
|
@ -24,6 +24,7 @@
|
|||
#include <android-base/logging.h>
|
||||
#include <android/hidl/memory/1.0/IMapper.h>
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include <log/log.h>
|
||||
|
||||
using android::sp;
|
||||
using android::hidl::memory::V1_0::IMemory;
|
||||
|
@ -63,6 +64,15 @@ sp<IMemory> mapMemory(const hidl_memory& memory) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
// hidl_memory's size is stored in uint64_t, but mapMemory's mmap will map
|
||||
// size in size_t. If size is over SIZE_MAX, mapMemory could succeed
|
||||
// but the mapped memory's actual size will be smaller than the reported size.
|
||||
if (memory.size() > SIZE_MAX) {
|
||||
LOG(ERROR) << "Cannot map " << memory.size() << " bytes of memory because it is too large.";
|
||||
android_errorWriteLog(0x534e4554, "79376389");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Return<sp<IMemory>> ret = mapper->mapMemory(memory);
|
||||
|
||||
if (!ret.isOk()) {
|
||||
|
|
10
android/system/libhidl/transport/HidlBinderSupport.cpp
Normal file → Executable file
10
android/system/libhidl/transport/HidlBinderSupport.cpp
Normal file → Executable file
|
@ -19,6 +19,7 @@
|
|||
#include <hidl/HidlBinderSupport.h>
|
||||
|
||||
// C includes
|
||||
#include <inttypes.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// C++ includes
|
||||
|
@ -66,6 +67,15 @@ status_t readEmbeddedFromParcel(const hidl_memory& memory,
|
|||
parentOffset + hidl_memory::kOffsetOfName);
|
||||
}
|
||||
|
||||
// hidl_memory's size is stored in uint64_t, but mapMemory's mmap will map
|
||||
// size in size_t. If size is over SIZE_MAX, mapMemory could succeed
|
||||
// but the mapped memory's actual size will be smaller than the reported size.
|
||||
if (memory.size() > SIZE_MAX) {
|
||||
ALOGE("Cannot use memory with %" PRId64 " bytes because it is too large.", memory.size());
|
||||
android_errorWriteLog(0x534e4554, "79376389");
|
||||
return BAD_VALUE;
|
||||
}
|
||||
|
||||
return _hidl_err;
|
||||
}
|
||||
|
||||
|
|
1
android/system/libhidl/transport/memory/1.0/default/Android.bp
Normal file → Executable file
1
android/system/libhidl/transport/memory/1.0/default/Android.bp
Normal file → Executable file
|
@ -32,6 +32,7 @@ cc_library_shared {
|
|||
"libhardware",
|
||||
"libhwbinder",
|
||||
"libbase",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
|
|
13
android/system/libhidl/transport/memory/1.0/default/AshmemMapper.cpp
Normal file → Executable file
13
android/system/libhidl/transport/memory/1.0/default/AshmemMapper.cpp
Normal file → Executable file
|
@ -16,6 +16,9 @@
|
|||
|
||||
#include "AshmemMapper.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <log/log.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "AshmemMemory.h"
|
||||
|
@ -32,6 +35,16 @@ Return<sp<IMemory>> AshmemMapper::mapMemory(const hidl_memory& mem) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
// If ashmem service runs in 32-bit (size_t is uint32_t) and a 64-bit
|
||||
// client process requests a memory > 2^32 bytes, the size would be
|
||||
// converted to a 32-bit number in mmap. mmap could succeed but the
|
||||
// mapped memory's actual size would be smaller than the reported size.
|
||||
if (mem.size() > SIZE_MAX) {
|
||||
ALOGE("Cannot map %" PRIu64 " bytes of memory because it is too large.", mem.size());
|
||||
android_errorWriteLog(0x534e4554, "79376389");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int fd = mem.handle()->data[0];
|
||||
void* data = mmap(0, mem.size(), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
if (data == MAP_FAILED) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue