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

Commit 3439f41a authored by Andres Morales's avatar Andres Morales
Browse files

[gatekeeperd] copy uid to local before passing to u_map

The compiler will issue the unaligned access instuctions
when reading from a packed struct. Since 'find' takes a
reference, if we pass the field directly it is removed
from its packed context and may be unreadable.

Read the field out directly from the packed struct and pass
in aligned to u_map to fix.

Bug: 22367550
Change-Id: Ia3b639c7518154ff5a2b7c233b752e154eab9aad
parent bf94f03d
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -25,8 +25,10 @@ extern "C" {
#include <crypto_scrypt.h>
#include <crypto_scrypt.h>
}
}


#include <base/memory.h>
#include <UniquePtr.h>
#include <UniquePtr.h>
#include <gatekeeper/gatekeeper.h>
#include <gatekeeper/gatekeeper.h>

#include <iostream>
#include <iostream>
#include <unordered_map>
#include <unordered_map>


@@ -150,7 +152,8 @@ public:
    }
    }


    bool DoVerify(const password_handle_t *expected_handle, const SizedBuffer &password) {
    bool DoVerify(const password_handle_t *expected_handle, const SizedBuffer &password) {
        FastHashMap::const_iterator it = fast_hash_map_.find(expected_handle->user_id);
        FastHashMap::const_iterator it = fast_hash_map_.find(
                android::base::get_unaligned(&expected_handle->user_id));
        if (it != fast_hash_map_.end() && VerifyFast(it->second, password)) {
        if (it != fast_hash_map_.end() && VerifyFast(it->second, password)) {
            return true;
            return true;
        } else {
        } else {
+1 −1
Original line number Original line Diff line number Diff line
@@ -20,7 +20,7 @@ include $(CLEAR_VARS)
LOCAL_MODULE := gatekeeperd-unit-tests
LOCAL_MODULE := gatekeeperd-unit-tests
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_CFLAGS += -g -Wall -Werror -std=gnu++11 -Wno-missing-field-initializers
LOCAL_CFLAGS += -g -Wall -Werror -std=gnu++11 -Wno-missing-field-initializers
LOCAL_SHARED_LIBRARIES := libgatekeeper libcrypto
LOCAL_SHARED_LIBRARIES := libgatekeeper libcrypto libbase
LOCAL_STATIC_LIBRARIES := libscrypt_static
LOCAL_STATIC_LIBRARIES := libscrypt_static
LOCAL_C_INCLUDES := external/scrypt/lib/crypto
LOCAL_C_INCLUDES := external/scrypt/lib/crypto
LOCAL_SRC_FILES := \
LOCAL_SRC_FILES := \