Loading fs_mgr/libdm/dm.cpp +15 −0 Original line number Original line Diff line number Diff line Loading @@ -29,6 +29,7 @@ #include <android-base/file.h> #include <android-base/file.h> #include <android-base/logging.h> #include <android-base/logging.h> #include <android-base/macros.h> #include <android-base/macros.h> #include <android-base/properties.h> #include <android-base/strings.h> #include <android-base/strings.h> #include <uuid/uuid.h> #include <uuid/uuid.h> Loading Loading @@ -140,6 +141,10 @@ static std::string GenerateUuid() { return std::string{uuid_chars}; return std::string{uuid_chars}; } } static bool IsRecovery() { return access("/system/bin/recovery", F_OK) == 0; } bool DeviceMapper::CreateDevice(const std::string& name, const DmTable& table, std::string* path, bool DeviceMapper::CreateDevice(const std::string& name, const DmTable& table, std::string* path, const std::chrono::milliseconds& timeout_ms) { const std::chrono::milliseconds& timeout_ms) { std::string uuid = GenerateUuid(); std::string uuid = GenerateUuid(); Loading @@ -160,6 +165,16 @@ bool DeviceMapper::CreateDevice(const std::string& name, const DmTable& table, s if (timeout_ms <= std::chrono::milliseconds::zero()) { if (timeout_ms <= std::chrono::milliseconds::zero()) { return true; return true; } } if (IsRecovery()) { bool non_ab_device = android::base::GetProperty("ro.build.ab_update", "").empty(); int sdk = android::base::GetIntProperty("ro.build.version.sdk", 0); if (non_ab_device && sdk && sdk <= 29) { LOG(INFO) << "Detected ueventd incompatibility, reverting to legacy libdm behavior."; unique_path = *path; } } if (!WaitForFile(unique_path, timeout_ms)) { if (!WaitForFile(unique_path, timeout_ms)) { LOG(ERROR) << "Failed waiting for device path: " << unique_path; LOG(ERROR) << "Failed waiting for device path: " << unique_path; DeleteDevice(name); DeleteDevice(name); Loading init/reboot.cpp +4 −1 Original line number Original line Diff line number Diff line Loading @@ -678,9 +678,12 @@ static void DoReboot(unsigned int cmd, const std::string& reason, const std::str // Reap subcontext pids. // Reap subcontext pids. ReapAnyOutstandingChildren(); ReapAnyOutstandingChildren(); // 3. send volume shutdown to vold // 3. send volume abort_fuse and volume shutdown to vold Service* vold_service = ServiceList::GetInstance().FindService("vold"); Service* vold_service = ServiceList::GetInstance().FindService("vold"); if (vold_service != nullptr && vold_service->IsRunning()) { if (vold_service != nullptr && vold_service->IsRunning()) { // Manually abort FUSE connections, since the FUSE daemon is already dead // at this point, and unmounting it might hang. CallVdc("volume", "abort_fuse"); CallVdc("volume", "shutdown"); CallVdc("volume", "shutdown"); vold_service->Stop(); vold_service->Stop(); } else { } else { Loading libutils/FileMap.cpp +5 −1 Original line number Original line Diff line number Diff line Loading @@ -189,7 +189,11 @@ bool FileMap::create(const char* origFileName, int fd, off64_t offset, size_t le int adjust = offset % mPageSize; int adjust = offset % mPageSize; off64_t adjOffset = offset - adjust; off64_t adjOffset = offset - adjust; size_t adjLength = length + adjust; size_t adjLength; if (__builtin_add_overflow(length, adjust, &adjLength)) { ALOGE("adjusted length overflow: length %zu adjust %d", length, adjust); return false; } int flags = MAP_SHARED; int flags = MAP_SHARED; int prot = PROT_READ; int prot = PROT_READ; Loading libutils/FileMap_test.cpp +13 −0 Original line number Original line Diff line number Diff line Loading @@ -52,3 +52,16 @@ TEST(FileMap, large_offset) { ASSERT_EQ(0u, m.getDataLength()); ASSERT_EQ(0u, m.getDataLength()); ASSERT_EQ(offset, m.getDataOffset()); ASSERT_EQ(offset, m.getDataOffset()); } } TEST(FileMap, offset_overflow) { // Make sure that an end that overflows SIZE_MAX will not abort. // See http://b/156997193. TemporaryFile tf; ASSERT_TRUE(tf.fd != -1); off64_t offset = 200; size_t length = SIZE_MAX; android::FileMap m; ASSERT_FALSE(m.create("test", tf.fd, offset, length, true)); } rootdir/init.rc +3 −0 Original line number Original line Diff line number Diff line Loading @@ -177,6 +177,9 @@ on init mount binder binder /dev/binderfs stats=global mount binder binder /dev/binderfs stats=global chmod 0755 /dev/binderfs chmod 0755 /dev/binderfs # Mount fusectl mount fusectl none /sys/fs/fuse/connections symlink /dev/binderfs/binder /dev/binder symlink /dev/binderfs/binder /dev/binder symlink /dev/binderfs/hwbinder /dev/hwbinder symlink /dev/binderfs/hwbinder /dev/hwbinder symlink /dev/binderfs/vndbinder /dev/vndbinder symlink /dev/binderfs/vndbinder /dev/vndbinder Loading Loading
fs_mgr/libdm/dm.cpp +15 −0 Original line number Original line Diff line number Diff line Loading @@ -29,6 +29,7 @@ #include <android-base/file.h> #include <android-base/file.h> #include <android-base/logging.h> #include <android-base/logging.h> #include <android-base/macros.h> #include <android-base/macros.h> #include <android-base/properties.h> #include <android-base/strings.h> #include <android-base/strings.h> #include <uuid/uuid.h> #include <uuid/uuid.h> Loading Loading @@ -140,6 +141,10 @@ static std::string GenerateUuid() { return std::string{uuid_chars}; return std::string{uuid_chars}; } } static bool IsRecovery() { return access("/system/bin/recovery", F_OK) == 0; } bool DeviceMapper::CreateDevice(const std::string& name, const DmTable& table, std::string* path, bool DeviceMapper::CreateDevice(const std::string& name, const DmTable& table, std::string* path, const std::chrono::milliseconds& timeout_ms) { const std::chrono::milliseconds& timeout_ms) { std::string uuid = GenerateUuid(); std::string uuid = GenerateUuid(); Loading @@ -160,6 +165,16 @@ bool DeviceMapper::CreateDevice(const std::string& name, const DmTable& table, s if (timeout_ms <= std::chrono::milliseconds::zero()) { if (timeout_ms <= std::chrono::milliseconds::zero()) { return true; return true; } } if (IsRecovery()) { bool non_ab_device = android::base::GetProperty("ro.build.ab_update", "").empty(); int sdk = android::base::GetIntProperty("ro.build.version.sdk", 0); if (non_ab_device && sdk && sdk <= 29) { LOG(INFO) << "Detected ueventd incompatibility, reverting to legacy libdm behavior."; unique_path = *path; } } if (!WaitForFile(unique_path, timeout_ms)) { if (!WaitForFile(unique_path, timeout_ms)) { LOG(ERROR) << "Failed waiting for device path: " << unique_path; LOG(ERROR) << "Failed waiting for device path: " << unique_path; DeleteDevice(name); DeleteDevice(name); Loading
init/reboot.cpp +4 −1 Original line number Original line Diff line number Diff line Loading @@ -678,9 +678,12 @@ static void DoReboot(unsigned int cmd, const std::string& reason, const std::str // Reap subcontext pids. // Reap subcontext pids. ReapAnyOutstandingChildren(); ReapAnyOutstandingChildren(); // 3. send volume shutdown to vold // 3. send volume abort_fuse and volume shutdown to vold Service* vold_service = ServiceList::GetInstance().FindService("vold"); Service* vold_service = ServiceList::GetInstance().FindService("vold"); if (vold_service != nullptr && vold_service->IsRunning()) { if (vold_service != nullptr && vold_service->IsRunning()) { // Manually abort FUSE connections, since the FUSE daemon is already dead // at this point, and unmounting it might hang. CallVdc("volume", "abort_fuse"); CallVdc("volume", "shutdown"); CallVdc("volume", "shutdown"); vold_service->Stop(); vold_service->Stop(); } else { } else { Loading
libutils/FileMap.cpp +5 −1 Original line number Original line Diff line number Diff line Loading @@ -189,7 +189,11 @@ bool FileMap::create(const char* origFileName, int fd, off64_t offset, size_t le int adjust = offset % mPageSize; int adjust = offset % mPageSize; off64_t adjOffset = offset - adjust; off64_t adjOffset = offset - adjust; size_t adjLength = length + adjust; size_t adjLength; if (__builtin_add_overflow(length, adjust, &adjLength)) { ALOGE("adjusted length overflow: length %zu adjust %d", length, adjust); return false; } int flags = MAP_SHARED; int flags = MAP_SHARED; int prot = PROT_READ; int prot = PROT_READ; Loading
libutils/FileMap_test.cpp +13 −0 Original line number Original line Diff line number Diff line Loading @@ -52,3 +52,16 @@ TEST(FileMap, large_offset) { ASSERT_EQ(0u, m.getDataLength()); ASSERT_EQ(0u, m.getDataLength()); ASSERT_EQ(offset, m.getDataOffset()); ASSERT_EQ(offset, m.getDataOffset()); } } TEST(FileMap, offset_overflow) { // Make sure that an end that overflows SIZE_MAX will not abort. // See http://b/156997193. TemporaryFile tf; ASSERT_TRUE(tf.fd != -1); off64_t offset = 200; size_t length = SIZE_MAX; android::FileMap m; ASSERT_FALSE(m.create("test", tf.fd, offset, length, true)); }
rootdir/init.rc +3 −0 Original line number Original line Diff line number Diff line Loading @@ -177,6 +177,9 @@ on init mount binder binder /dev/binderfs stats=global mount binder binder /dev/binderfs stats=global chmod 0755 /dev/binderfs chmod 0755 /dev/binderfs # Mount fusectl mount fusectl none /sys/fs/fuse/connections symlink /dev/binderfs/binder /dev/binder symlink /dev/binderfs/binder /dev/binder symlink /dev/binderfs/hwbinder /dev/hwbinder symlink /dev/binderfs/hwbinder /dev/hwbinder symlink /dev/binderfs/vndbinder /dev/vndbinder symlink /dev/binderfs/vndbinder /dev/vndbinder Loading