kernel: add CONFIG_KSU_DEBUG (#19)

* Kconfig: add KSU_DEBUG

* print alert on debug mode

* allow shell by default

* store signature to var on debug mode

* format

* export as module_param

* rename apk_sign to kernelsu
This commit is contained in:
Ylarod
2023-01-14 21:45:34 +08:00
committed by GitHub
parent 50f44fff9e
commit 5e77d1cd5b
5 changed files with 43 additions and 3 deletions

View File

@@ -1,9 +1,10 @@
#include <linux/moduleparam.h>
#include <linux/fs.h>
#include "apk_sign.h"
#include "klog.h"
static int check_v2_signature(char *path, unsigned expected_size,
static __always_inline int check_v2_signature(char *path, unsigned expected_size,
unsigned expected_hash)
{
unsigned char buffer[0x11] = { 0 };
@@ -121,7 +122,25 @@ clean:
return sign;
}
#ifdef CONFIG_KSU_DEBUG
unsigned ksu_expected_size = EXPECTED_SIZE;
unsigned ksu_expected_hash = EXPECTED_HASH;
module_param(ksu_expected_size, uint, S_IRUSR | S_IWUSR);
module_param(ksu_expected_hash, uint, S_IRUSR | S_IWUSR);
int is_manager_apk(char *path)
{
return check_v2_signature(path, ksu_expected_size, ksu_expected_hash);
}
#else
int is_manager_apk(char *path)
{
return check_v2_signature(path, EXPECTED_SIZE, EXPECTED_HASH);
}
}
#endif