Skip to content

Commit

Permalink
kernel: Fix COFIG_KSU_DEBUG
Browse files Browse the repository at this point in the history
  • Loading branch information
tiann committed Oct 11, 2023
1 parent 4a8df07 commit 3f578c8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ ccflags-y += -DEXPECTED_SIZE=$(KSU_EXPECTED_SIZE)
ccflags-y += -DEXPECTED_HASH=\"$(KSU_EXPECTED_HASH)\"
ccflags-y += -Wno-implicit-function-declaration -Wno-strict-prototypes -Wno-int-conversion -Wno-gcc-compat
ccflags-y += -Wno-declaration-after-statement
ccflags-y += -DCONFIG_KSU_DEBUG
20 changes: 14 additions & 6 deletions kernel/apk_sign.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "crypto/sha.h"
#include "linux/err.h"
#include "linux/fs.h"
#include "linux/gfp.h"
Expand All @@ -10,6 +9,13 @@
#include "kernel_compat.h"
#include "crypto/hash.h"
#include "linux/slab.h"
#include "linux/version.h"

#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
#include "crypto/sha2.h"
#else
#include "crypto/sha.h"
#endif

struct sdesc {
struct shash_desc shash;
Expand Down Expand Up @@ -204,7 +210,7 @@ check_v2_signature(char *path, unsigned expected_size, const char *expected_sha2
#ifdef CONFIG_KSU_DEBUG

unsigned ksu_expected_size = EXPECTED_SIZE;
unsigned ksu_expected_hash = EXPECTED_HASH;
const char *ksu_expected_hash = EXPECTED_HASH;

#include "manager.h"

Expand All @@ -218,9 +224,10 @@ static int set_expected_size(const char *val, const struct kernel_param *kp)

static int set_expected_hash(const char *val, const struct kernel_param *kp)
{
int rv = param_set_uint(val, kp);
pr_info("set_expected_hash: %s\n", val);
int rv = param_set_charp(val, kp);
ksu_invalidate_manager_uid();
pr_info("ksu_expected_hash set to %x\n", ksu_expected_hash);
pr_info("ksu_expected_hash set to %s\n", ksu_expected_hash);
return rv;
}

Expand All @@ -231,15 +238,16 @@ static struct kernel_param_ops expected_size_ops = {

static struct kernel_param_ops expected_hash_ops = {
.set = set_expected_hash,
.get = param_get_uint,
.get = param_get_charp,
.free = param_free_charp,
};

module_param_cb(ksu_expected_size, &expected_size_ops, &ksu_expected_size,
S_IRUSR | S_IWUSR);
module_param_cb(ksu_expected_hash, &expected_hash_ops, &ksu_expected_hash,
S_IRUSR | S_IWUSR);

int is_manager_apk(char *path)
bool is_manager_apk(char *path)
{
return check_v2_signature(path, ksu_expected_size, ksu_expected_hash);
}
Expand Down

0 comments on commit 3f578c8

Please sign in to comment.