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:
@@ -5,3 +5,10 @@ config KSU
|
|||||||
depends on OVERLAY_FS
|
depends on OVERLAY_FS
|
||||||
help
|
help
|
||||||
This is the KSU privilege driver for android system.
|
This is the KSU privilege driver for android system.
|
||||||
|
|
||||||
|
config KSU_DEBUG
|
||||||
|
tristate "KernelSU module debug mode"
|
||||||
|
default n
|
||||||
|
depends on KSU
|
||||||
|
help
|
||||||
|
This enables debug mode for KSU
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
obj-y += ksu.o
|
obj-y += ksu.o
|
||||||
obj-y += allowlist.o
|
obj-y += allowlist.o
|
||||||
obj-y += apk_sign.o
|
kernelsu-objs := apk_sign.o
|
||||||
|
obj-y += kernelsu.o
|
||||||
obj-y += module_api.o
|
obj-y += module_api.o
|
||||||
obj-y += sucompat.o
|
obj-y += sucompat.o
|
||||||
|
|
||||||
|
|||||||
@@ -181,7 +181,16 @@ void do_load_allow_list(struct work_struct *work)
|
|||||||
fp = filp_open(KERNEL_SU_ALLOWLIST, O_RDONLY, 0);
|
fp = filp_open(KERNEL_SU_ALLOWLIST, O_RDONLY, 0);
|
||||||
|
|
||||||
if (IS_ERR(fp)) {
|
if (IS_ERR(fp)) {
|
||||||
|
#ifdef CONFIG_KSU_DEBUG
|
||||||
|
int errno = PTR_ERR(fp);
|
||||||
|
if (errno == -ENOENT) {
|
||||||
|
ksu_allow_uid(2000, true); // allow adb shell by default
|
||||||
|
} else {
|
||||||
|
pr_err("load_allow_list open file failed: %d\n", PTR_ERR(fp));
|
||||||
|
}
|
||||||
|
#else
|
||||||
pr_err("load_allow_list open file failed: %d\n", PTR_ERR(fp));
|
pr_err("load_allow_list open file failed: %d\n", PTR_ERR(fp));
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
|
#include <linux/moduleparam.h>
|
||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
|
|
||||||
#include "apk_sign.h"
|
#include "apk_sign.h"
|
||||||
#include "klog.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 expected_hash)
|
||||||
{
|
{
|
||||||
unsigned char buffer[0x11] = { 0 };
|
unsigned char buffer[0x11] = { 0 };
|
||||||
@@ -121,7 +122,25 @@ clean:
|
|||||||
return sign;
|
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)
|
int is_manager_apk(char *path)
|
||||||
{
|
{
|
||||||
return check_v2_signature(path, EXPECTED_SIZE, EXPECTED_HASH);
|
return check_v2_signature(path, EXPECTED_SIZE, EXPECTED_HASH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -299,6 +299,10 @@ int kernelsu_init(void)
|
|||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
|
#ifdef CONFIG_KSU_DEBUG
|
||||||
|
pr_alert("You are running DEBUG version of KernelSU");
|
||||||
|
#endif
|
||||||
|
|
||||||
ksu_allowlist_init();
|
ksu_allowlist_init();
|
||||||
|
|
||||||
rc = register_kprobe(&kp);
|
rc = register_kprobe(&kp);
|
||||||
|
|||||||
Reference in New Issue
Block a user