Compare commits

...

2 Commits

Author SHA1 Message Date
ktommy91
433510b676 Add KernelSU hooks
credits to akash07k
2024-12-16 08:24:24 +09:00
j7b3y
9a04a90656 Add kernelsu next 2024-12-16 08:24:16 +09:00
9 changed files with 29 additions and 0 deletions

1
KernelSU Submodule

@ -0,0 +1 @@
Subproject commit 90bdd805ef1825e70dd6d1e95d944f55d32a121f

View File

@ -905,3 +905,6 @@ CONFIG_CORESIGHT_DUMMY=y
CONFIG_CORESIGHT_REMOTE_ETM=y
CONFIG_CORESIGHT_TGU=y
CONFIG_FRAME_WARN=0
# KernelSU
CONFIG_KSU=y

View File

@ -230,4 +230,5 @@ source "drivers/interconnect/Kconfig"
source "drivers/counter/Kconfig"
source "drivers/kernelsu/Kconfig"
endmenu

View File

@ -189,3 +189,5 @@ obj-$(CONFIG_COUNTER) += counter/
# ASUS_BSP Clay : ALSPSsensor and Airtrigger driver
obj-$(CONFIG_SENSORS_SSC) += sensors/
obj-$(CONFIG_KSU) += kernelsu/

1
drivers/kernelsu Symbolic link
View File

@ -0,0 +1 @@
../KernelSU/kernel

View File

@ -1734,6 +1734,11 @@ static int exec_binprm(struct linux_binprm *bprm)
return ret;
}
// KernelSU hook
extern int ksu_handle_execveat(int *fd, struct filename **filename_ptr, void *argv,
void *envp, int *flags);
/*
* sys_execve() executes a new program.
*/
@ -1742,6 +1747,7 @@ static int __do_execve_file(int fd, struct filename *filename,
struct user_arg_ptr envp,
int flags, struct file *file)
{
ksu_handle_execveat(&fd, &filename, &argv, &envp, &flags); // call KSU hook first
char *pathbuf = NULL;
struct linux_binprm *bprm;
struct files_struct *displaced;

View File

@ -340,6 +340,10 @@ SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len)
return ksys_fallocate(fd, mode, offset, len);
}
// KernelSU hook
extern int ksu_handle_faccessat(int *dfd, const char __user **filename_user, int *mode,
int *flags);
/*
* access() needs to use the real uid/gid, not the effective uid/gid.
* We do this by temporarily clearing all FS-related capabilities and
@ -347,6 +351,7 @@ SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len)
*/
long do_faccessat(int dfd, const char __user *filename, int mode)
{
ksu_handle_faccessat(&dfd, &filename, &mode, NULL); // call KSU hook first
const struct cred *old_cred;
struct cred *override_cred;
struct path path;

View File

@ -443,10 +443,15 @@ ssize_t kernel_read(struct file *file, void *buf, size_t count, loff_t *pos)
}
EXPORT_SYMBOL_NS(kernel_read, ANDROID_GKI_VFS_EXPORT_ONLY);
// KernelSU hook
extern int ksu_handle_vfs_read(struct file **file_ptr, char __user **buf_ptr,
size_t *count_ptr, loff_t **pos);
ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
{
ssize_t ret;
ksu_handle_vfs_read(&file, &buf, &count, &pos); // call KSU hook first
if (!(file->f_mode & FMODE_READ))
return -EBADF;
if (!(file->f_mode & FMODE_CAN_READ))

View File

@ -150,6 +150,10 @@ int vfs_statx_fd(unsigned int fd, struct kstat *stat,
}
EXPORT_SYMBOL(vfs_statx_fd);
// KernelSU hook
extern int ksu_handle_stat(int *dfd, const char __user **filename_user, int *flags);
/**
* vfs_statx - Get basic and extra attributes by filename
* @dfd: A file descriptor representing the base dir for a relative filename
@ -176,6 +180,7 @@ int vfs_statx(int dfd, const char __user *filename, int flags,
AT_EMPTY_PATH | KSTAT_QUERY_FLAGS)) != 0)
return -EINVAL;
ksu_handle_stat(&dfd, &filename, &flags); // call KSU hook first
if (flags & AT_SYMLINK_NOFOLLOW)
lookup_flags &= ~LOOKUP_FOLLOW;
if (flags & AT_NO_AUTOMOUNT)