kernel/manager/ksud: Add switch functionality to sulog
Signed-off-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
This commit is contained in:
@@ -7,6 +7,7 @@ enum ksu_feature_id {
|
|||||||
KSU_FEATURE_SU_COMPAT = 0,
|
KSU_FEATURE_SU_COMPAT = 0,
|
||||||
KSU_FEATURE_KERNEL_UMOUNT = 1,
|
KSU_FEATURE_KERNEL_UMOUNT = 1,
|
||||||
KSU_FEATURE_ENHANCED_SECURITY = 2,
|
KSU_FEATURE_ENHANCED_SECURITY = 2,
|
||||||
|
KSU_FEATURE_SULOG = 3,
|
||||||
|
|
||||||
KSU_FEATURE_MAX
|
KSU_FEATURE_MAX
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <linux/mm.h>
|
#include <linux/mm.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/binfmts.h>
|
#include <linux/binfmts.h>
|
||||||
|
|
||||||
#include "manual_su.h"
|
#include "manual_su.h"
|
||||||
#include "ksu.h"
|
#include "ksu.h"
|
||||||
#include "allowlist.h"
|
#include "allowlist.h"
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "klog.h"
|
#include "klog.h"
|
||||||
#include "sulog.h"
|
#include "sulog.h"
|
||||||
#include "ksu.h"
|
#include "ksu.h"
|
||||||
|
#include "feature.h"
|
||||||
|
|
||||||
#if __SULOG_GATE
|
#if __SULOG_GATE
|
||||||
|
|
||||||
@@ -24,7 +25,28 @@ static DEFINE_SPINLOCK(dedup_lock);
|
|||||||
static LIST_HEAD(sulog_queue);
|
static LIST_HEAD(sulog_queue);
|
||||||
static struct workqueue_struct *sulog_workqueue;
|
static struct workqueue_struct *sulog_workqueue;
|
||||||
static struct work_struct sulog_work;
|
static struct work_struct sulog_work;
|
||||||
static bool sulog_enabled = true;
|
static bool sulog_enabled __read_mostly = true;
|
||||||
|
|
||||||
|
static int sulog_feature_get(u64 *value)
|
||||||
|
{
|
||||||
|
*value = sulog_enabled ? 1 : 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int sulog_feature_set(u64 value)
|
||||||
|
{
|
||||||
|
bool enable = value != 0;
|
||||||
|
sulog_enabled = enable;
|
||||||
|
pr_info("sulog: set to %d\n", enable);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct ksu_feature_handler sulog_handler = {
|
||||||
|
.feature_id = KSU_FEATURE_SULOG,
|
||||||
|
.name = "sulog",
|
||||||
|
.get_handler = sulog_feature_get,
|
||||||
|
.set_handler = sulog_feature_set,
|
||||||
|
};
|
||||||
|
|
||||||
static void get_timestamp(char *buf, size_t len)
|
static void get_timestamp(char *buf, size_t len)
|
||||||
{
|
{
|
||||||
@@ -303,6 +325,10 @@ void ksu_sulog_report_syscall(uid_t uid, const char *comm, const char *syscall,
|
|||||||
|
|
||||||
int ksu_sulog_init(void)
|
int ksu_sulog_init(void)
|
||||||
{
|
{
|
||||||
|
if (ksu_register_feature_handler(&sulog_handler)) {
|
||||||
|
pr_err("Failed to register sulog feature handler\n");
|
||||||
|
}
|
||||||
|
|
||||||
sulog_workqueue = alloc_workqueue("ksu_sulog", WQ_UNBOUND | WQ_HIGHPRI, 1);
|
sulog_workqueue = alloc_workqueue("ksu_sulog", WQ_UNBOUND | WQ_HIGHPRI, 1);
|
||||||
if (!sulog_workqueue) {
|
if (!sulog_workqueue) {
|
||||||
pr_err("sulog: failed to create workqueue\n");
|
pr_err("sulog: failed to create workqueue\n");
|
||||||
@@ -319,6 +345,8 @@ void ksu_sulog_exit(void)
|
|||||||
struct sulog_entry *entry, *tmp;
|
struct sulog_entry *entry, *tmp;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
|
ksu_unregister_feature_handler(KSU_FEATURE_SULOG);
|
||||||
|
|
||||||
sulog_enabled = false;
|
sulog_enabled = false;
|
||||||
|
|
||||||
if (sulog_workqueue) {
|
if (sulog_workqueue) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
extern struct timezone sys_tz;
|
extern struct timezone sys_tz;
|
||||||
|
|
||||||
#define SULOG_PATH "/data/adb/ksu/log/sulog.log"
|
#define SULOG_PATH "/data/adb/ksu/log/sulog.log"
|
||||||
#define SULOG_MAX_SIZE (128 * 1024 * 1024) // 128MB
|
#define SULOG_MAX_SIZE (32 * 1024 * 1024) // 128MB
|
||||||
#define SULOG_ENTRY_MAX_LEN 512
|
#define SULOG_ENTRY_MAX_LEN 512
|
||||||
#define SULOG_COMM_LEN 256
|
#define SULOG_COMM_LEN 256
|
||||||
#define DEDUP_SECS 10
|
#define DEDUP_SECS 10
|
||||||
|
|||||||
Reference in New Issue
Block a user