Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 70d19d8c authored by Dan Pasanen's avatar Dan Pasanen Committed by Ethan Chen
Browse files

fs_mgr: Skip filesystem check unless fs_type matches

* Prevent accidentally destroying a partition of the wrong type.
* Don't skip iterations of the internal mount_all loop, otherwise
  encryptability may not be properly handled.

Change-Id: I8f3ddc396a5fb85f4ae0a0a11dd61fb4d6462d6d
parent ee4a7e8b
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -8,8 +8,8 @@ LOCAL_SRC_FILES:= fs_mgr.c fs_mgr_verity.c fs_mgr_fstab.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include

LOCAL_MODULE:= libfs_mgr
LOCAL_STATIC_LIBRARIES := liblogwrap libmincrypt libext4_utils_static
LOCAL_C_INCLUDES += system/extras/ext4_utils
LOCAL_STATIC_LIBRARIES := liblogwrap libmincrypt libext4_utils_static libext2_blkid libext2_uuid
LOCAL_C_INCLUDES += system/extras/ext4_utils external/e2fsprogs/lib
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
LOCAL_CFLAGS := -Werror

@@ -30,7 +30,7 @@ LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)/sbin
LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED)

LOCAL_STATIC_LIBRARIES := libfs_mgr liblogwrap libcutils liblog libc libmincrypt libext4_utils_static
LOCAL_STATIC_LIBRARIES := libfs_mgr liblogwrap libcutils liblog libc libmincrypt libext4_utils_static libext2_blkid libext2_uuid

LOCAL_CFLAGS := -Werror

+13 −2
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include <cutils/partition_utils.h>
#include <cutils/properties.h>
#include <logwrap/logwrap.h>
#include <blkid/blkid.h>

#include "mincrypt/rsa.h"
#include "mincrypt/sha.h"
@@ -261,6 +262,8 @@ static int mount_with_alternatives(struct fstab *fstab, int start_idx, int *end_
    int i;
    int mount_errno = 0;
    int mounted = 0;
    int cmp_len;
    char *detected_fs_type;

    if (!end_idx || !attempted_idx || start_idx >= fstab->num_entries) {
      errno = EINVAL;
@@ -286,9 +289,17 @@ static int mount_with_alternatives(struct fstab *fstab, int start_idx, int *end_
            }

            if (fstab->recs[i].fs_mgr_flags & MF_CHECK) {
                /* Skip file system check unless we are sure we are the right type */
                detected_fs_type = blkid_get_tag_value(NULL, "TYPE", fstab->recs[i].blk_device);
                if (detected_fs_type) {
                    cmp_len = (!strncmp(detected_fs_type, "ext", 3) &&
                            strlen(detected_fs_type) == 4) ? 3 : strlen(detected_fs_type);
                    if (!strncmp(fstab->recs[i].fs_type, detected_fs_type, cmp_len)) {
                        check_fs(fstab->recs[i].blk_device, fstab->recs[i].fs_type,
                                 fstab->recs[i].mount_point);
                    }
                }
            }
            if (!__mount(fstab->recs[i].blk_device, fstab->recs[i].mount_point, &fstab->recs[i])) {
                *attempted_idx = i;
                mounted = 1;
+3 −1
Original line number Diff line number Diff line
@@ -60,7 +60,9 @@ LOCAL_STATIC_LIBRARIES := \
	libc \
	libselinux \
	libmincrypt \
	libext4_utils_static
	libext4_utils_static \
	libext2_blkid \
	libext2_uuid

LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
ifneq ($(strip $(TARGET_PLATFORM_DEVICE_BASE)),)