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

Commit fefe5915 authored by Ethan Yonker's avatar Ethan Yonker
Browse files

FBE for Pixel 2

Includes various minor fixes for building in Android 8 trees with r23+ tag

Update FBE extended header in libtar to version 2 and include the entire
ext4_encryption_policy structure now after translating the policy.

See this post for more details:
https://plus.google.com/u/1/+DeesTroy/posts/i33ygUi7tiu

Change-Id: I2af981e51f459b17fcd895fb8c2d3f6c8200e24b
parent dc864ec8
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -64,9 +64,48 @@ static void set_usb_driver(bool enabled) {
    }
}

// On Android 8.0 for some reason init can't seem to completely stop adbd
// so we have to kill it too if it doesn't die on its own.
static void kill_adbd() {
    DIR* dir = opendir("/proc");
    if (dir) {
        struct dirent* de = 0;

        while ((de = readdir(dir)) != 0) {
            if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0)
                continue;

            int pid = -1;
            int ret = sscanf(de->d_name, "%d", &pid);

            if (ret == 1) {
                char cmdpath[PATH_MAX];
                sprintf(cmdpath, "/proc/%d/cmdline", pid);

                FILE* file = fopen(cmdpath, "r");
                size_t task_size = PATH_MAX;
                char task[PATH_MAX];
                char* p = task;
                if (getline(&p, &task_size, file) > 0) {
                    if (strstr(task, "adbd") != 0) {
                        printf("adbd pid %d found, sending kill.\n", pid);
                        kill(pid, SIGINT);
                        usleep(5000);
                        kill(pid, SIGKILL);
                    }
                }
                fclose(file);
            }
        }
        closedir(dir);
    }
}

static void stop_adbd() {
    printf("Stopping adbd...\n");
    property_set("ctl.stop", "adbd");
    usleep(5000);
    kill_adbd();
    set_usb_driver(false);
}

+4 −3
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
#include <vector>
#include <fstream>
#include <sstream>
#include <assert.h>

#include "twadbstream.h"
#include "libtwadbbu.hpp"
@@ -50,8 +51,8 @@ bool twadbbu::Check_ADB_Backup_File(std::string fname) {
	bytes = read(fd, &buf, sizeof(buf));
	close(fd);

	if (memcpy(&adbbuhdr, buf, sizeof(adbbuhdr)) < 0) {
		printf("Unable to memcpy: %s.\n", fname.c_str(), strerror(errno));
	if (memcpy(&adbbuhdr, buf, sizeof(adbbuhdr)) == NULL) {
		printf("Unable to memcpy: %s (%s).\n", fname.c_str(), strerror(errno));
		return false;
	}
	adbbuhdrcrc = adbbuhdr.crc;
@@ -77,7 +78,7 @@ std::vector<std::string> twadbbu::Get_ADB_Backup_Files(std::string fname) {
	while (1) {
		std::string cmdstr;
		int readbytes;
		if (readbytes = read(fd, &buf, sizeof(buf)) > 0) {
		if ((readbytes = read(fd, &buf, sizeof(buf))) > 0) {
			memcpy(&structcmd, buf, sizeof(structcmd));
			assert(structcmd.type == TWENDADB || structcmd.type == TWIMG || structcmd.type == TWFN);
			cmdstr = structcmd.type;
+11 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ include $(CLEAR_VARS)
LOCAL_MODULE := libe4crypt
LOCAL_MODULE_TAGS := eng optional
LOCAL_CFLAGS :=
LOCAL_SRC_FILES := Decrypt.cpp Ext4Crypt.cpp Keymaster.cpp KeyStorage.cpp ScryptParameters.cpp Utils.cpp HashPassword.cpp ext4_crypt.cpp
LOCAL_SRC_FILES := Decrypt.cpp Ext4Crypt.cpp ScryptParameters.cpp Utils.cpp HashPassword.cpp ext4_crypt.cpp
LOCAL_SHARED_LIBRARIES := libselinux libc libc++ libext4_utils libsoftkeymaster libbase libcrypto libcutils libkeymaster_messages libhardware libprotobuf-cpp-lite
LOCAL_STATIC_LIBRARIES := libscrypt_static
LOCAL_C_INCLUDES := system/extras/ext4_utils system/extras/ext4_utils/include/ext4_utils external/scrypt/lib/crypto system/security/keystore hardware/libhardware/include/hardware system/security/softkeymaster/include/keymaster system/keymaster/include
@@ -14,6 +14,16 @@ ifneq ($(wildcard hardware/libhardware/include/hardware/keymaster0.h),)
    LOCAL_CFLAGS += -DTW_CRYPTO_HAVE_KEYMASTERX
    LOCAL_C_INCLUDES +=  external/boringssl/src/include
endif
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0)
    LOCAL_CFLAGS += -DUSE_KEYSTORAGE_3 -DHAVE_LIBKEYUTILS -DHAVE_SYNTH_PWD_SUPPORT -DHAVE_GATEKEEPER1
    LOCAL_SRC_FILES += Keymaster3.cpp KeyStorage3.cpp
    LOCAL_SHARED_LIBRARIES += android.hardware.keymaster@3.0 libkeystore_binder libhidlbase libutils libkeyutils libbinder
    LOCAL_SHARED_LIBRARIES += android.hardware.gatekeeper@1.0
    LOCAL_SRC_FILES += Weaver1.cpp
    LOCAL_SHARED_LIBRARIES += android.hardware.weaver@1.0
else
    LOCAL_SRC_FILES += Keymaster.cpp KeyStorage.cpp
endif

include $(BUILD_SHARED_LIBRARY)

+767 −19

File changed.

Preview size limit exceeded, changes collapsed.

+8 −0
Original line number Diff line number Diff line
@@ -41,8 +41,16 @@

#include <private/android_filesystem_config.h>

#ifdef HAVE_SYNTH_PWD_SUPPORT
#include <ext4_utils/ext4_crypt.h>
#else
#include "ext4_crypt.h"
#endif
#ifndef HAVE_LIBKEYUTILS
#include "key_control.h"
#else
#include <keyutils.h>
#endif

#include <hardware/gatekeeper.h>
#include "HashPassword.h"
Loading