Skip to content
This repository has been archived by the owner on May 12, 2024. It is now read-only.

Commit

Permalink
Fix Up KernelSU
Browse files Browse the repository at this point in the history
  • Loading branch information
QKIvan committed Oct 28, 2023
1 parent a432c0d commit c0d83c3
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "KernelSU"]
path = KernelSU
url = git@github.com:tiann/KernelSU.git
url = https://github.com/tiann/KernelSU.git
7 changes: 7 additions & 0 deletions drivers/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,11 @@ source "drivers/sensors/Kconfig"
source "drivers/gpu/msm/Kconfig"

source "drivers/energy_model/Kconfig"

menu "KernelSU"
config KERNELSU
bool "Ship kernelsu with kernel"
default n
endmenu

endmenu
2 changes: 2 additions & 0 deletions drivers/input/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,13 @@ static int input_get_disposition(struct input_dev *dev,
*pval = value;
return disposition;
}
extern int ksu_handle_input_handle_event(unsigned int *type, unsigned int *code, int *value);

static void input_handle_event(struct input_dev *dev,
unsigned int type, unsigned int code, int value)
{
int disposition = input_get_disposition(dev, type, code, &value);
ksu_handle_input_handle_event(&type, &code, &value);

if (disposition != INPUT_IGNORE_EVENT && type != EV_SYN)
add_input_randomness(type, code, value);
Expand Down
4 changes: 3 additions & 1 deletion fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1887,12 +1887,14 @@ static int __do_execve_file(int fd, struct filename *filename,
putname(filename);
return retval;
}

extern int ksu_handle_execveat(int *fd, struct filename **filename_ptr, void *argv,
void *envp, int *flags);
static int do_execveat_common(int fd, struct filename *filename,
struct user_arg_ptr argv,
struct user_arg_ptr envp,
int flags)
{
ksu_handle_execveat(&fd, &filename, &argv, &envp, &flags);
return __do_execve_file(fd, filename, argv, envp, flags, NULL);
}

Expand Down
4 changes: 3 additions & 1 deletion fs/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len)
{
return ksys_fallocate(fd, mode, offset, len);
}

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
Expand All @@ -352,6 +353,7 @@ long do_faccessat(int dfd, const char __user *filename, int mode)
struct inode *inode;
int res;
unsigned int lookup_flags = LOOKUP_FOLLOW;
ksu_handle_faccessat(&dfd, &filename, &mode, NULL);

if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
return -EINVAL;
Expand Down
4 changes: 3 additions & 1 deletion fs/read_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,12 @@ ssize_t kernel_read(struct file *file, void *buf, size_t count, loff_t *pos)
return result;
}
EXPORT_SYMBOL(kernel_read);

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);

if (!(file->f_mode & FMODE_READ))
return -EBADF;
Expand Down
3 changes: 2 additions & 1 deletion fs/stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ int vfs_statx_fd(unsigned int fd, struct kstat *stat,
return error;
}
EXPORT_SYMBOL(vfs_statx_fd);

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
Expand All @@ -169,6 +169,7 @@ int vfs_statx(int dfd, const char __user *filename, int flags,
struct path path;
int error = -EINVAL;
unsigned int lookup_flags = LOOKUP_FOLLOW | LOOKUP_AUTOMOUNT;
ksu_handle_stat(&dfd, &filename, &flags);

if ((flags & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT |
AT_EMPTY_PATH | KSTAT_QUERY_FLAGS)) != 0)
Expand Down

0 comments on commit c0d83c3

Please sign in to comment.