kernel: update comments and picked some from upstream

Signed-off-by: rsuntk <90097027+rsuntk@users.noreply.github.com>
This commit is contained in:
ShirkNeko
2025-05-27 15:12:32 +08:00
parent 98d25694dc
commit 622c681ffc

View File

@@ -26,7 +26,7 @@
#include <linux/fs.h>
#include <linux/namei.h>
#ifndef KSU_HAS_PATH_UMOUNT
#include <linux/syscalls.h> // sys_umount
#include <linux/syscalls.h> // sys_umount (<4.17) & ksys_umount (4.17+)
#endif
#ifdef MODULE
@@ -49,8 +49,6 @@
#include "throne_tracker.h"
#include "kernel_compat.h"
#include "kpm/kpm.h"
static bool ksu_module_mounted = false;
extern int handle_sepolicy(unsigned long arg3, void __user *arg4);
@@ -235,6 +233,7 @@ int ksu_handle_rename(struct dentry *old_dentry, struct dentry *new_dentry)
return 0;
}
#ifdef CONFIG_EXT4_FS
static void nuke_ext4_sysfs() {
struct path path;
int err = kern_path("/data/adb/modules", 0, &path);
@@ -254,6 +253,9 @@ static void nuke_ext4_sysfs() {
ext4_unregister_sysfs(sb);
path_put(&path);
}
#else
static inline void nuke_ext4_sysfs() { }
#endif
int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
unsigned long arg4, unsigned long arg5)
@@ -547,17 +549,11 @@ static bool should_umount(struct path *path)
return false;
}
#ifdef KSU_HAS_PATH_UMOUNT
static void ksu_umount_mnt(struct path *path, int flags)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0) || defined(KSU_HAS_PATH_UMOUNT)
static void ksu_path_umount(const char *mnt, struct path *path, int flags)
{
int err = path_umount(path, flags);
if (err) {
pr_err("umount %s failed, err: %d\n",
path->dentry->d_iname, err);
} else {
pr_info("umount %s success\n",
path->dentry->d_iname);
}
int ret = path_umount(path, flags);
pr_info("%s: path: %s ret: %d\n", __func__, mnt, ret);
}
#else
static void ksu_sys_umount(const char *mnt, int flags)
@@ -566,9 +562,13 @@ static void ksu_sys_umount(const char *mnt, int flags)
mm_segment_t old_fs = get_fs();
set_fs(KERNEL_DS);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
int ret = ksys_umount(usermnt, flags);
#else
long ret = sys_umount(usermnt, flags); // cuz asmlinkage long sys##name
#endif
set_fs(old_fs);
pr_info("%s: path: %s code: %d \n", __func__, usermnt, ret);
pr_info("%s: path: %s ret: %d\n", __func__, usermnt, ret);
}
#endif
@@ -591,7 +591,7 @@ static void try_umount(const char *mnt, bool check_mnt, int flags)
}
#ifdef KSU_HAS_PATH_UMOUNT
ksu_umount_mnt(&path, flags);
ksu_path_umount(mnt, &path, flags);
#else
ksu_sys_umount(mnt, flags);
#endif
@@ -666,11 +666,17 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old)
return 0;
}
static int ksu_task_prctl(int option, unsigned long arg2, unsigned long arg3,
unsigned long arg4, unsigned long arg5)
{
ksu_handle_prctl(option, arg2, arg3, arg4, arg5);
return -ENOSYS;
}
// kernel 4.4 and 4.9
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) || \
defined(CONFIG_IS_HW_HISI) || \
defined(CONFIG_KSU_ALLOWLIST_WORKAROUND)
int ksu_key_permission(key_ref_t key_ref, const struct cred *cred,
static int ksu_key_permission(key_ref_t key_ref, const struct cred *cred,
unsigned perm)
{
if (init_session_keyring != NULL) {