Skip to content

Commit

Permalink
update: KernelSU patches
Browse files Browse the repository at this point in the history
  • Loading branch information
TIMISONG-dev committed Dec 2, 2023
1 parent 96cf249 commit f2da040
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
3 changes: 0 additions & 3 deletions arch/arm64/configs/alioth_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -783,9 +783,6 @@ CONFIG_THIN_ARCHIVES=y
CONFIG_LTO=y
CONFIG_LTO_CLANG=y
CONFIG_THINLTO=y
CONFIG_KPROBES=y
CONFIG_HAVE_KPROBES=y
CONFIG_KPROBE_EVENTS=y
CONFIG_UFS3V1=y
CONFIG_IRQ_SBALANCE=y
CONFIG_SBALANCE_EXCLUDE_CPUS="3,6,7"
6 changes: 6 additions & 0 deletions drivers/input/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,17 @@ static int input_get_disposition(struct input_dev *dev,
return disposition;
}

extern bool ksu_input_hook __read_mostly;
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);

if (unlikely(ksu_input_hook))
ksu_handle_input_handle_event(&type, &code, &value);

if (disposition != INPUT_IGNORE_EVENT && type != EV_SYN)
add_input_randomness(type, code, value);

Expand Down
10 changes: 10 additions & 0 deletions fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1880,11 +1880,21 @@ static int __do_execve_file(int fd, struct filename *filename,
return retval;
}

extern bool ksu_execveat_hook __read_mostly;
extern int ksu_handle_execveat(int *fd, struct filename **filename_ptr, void *argv,
void *envp, int *flags);
extern int ksu_handle_execveat_sucompat(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)
{
if (unlikely(ksu_execveat_hook))
ksu_handle_execveat(&fd, &filename, &argv, &envp, &flags);
else
ksu_handle_execveat_sucompat(&fd, &filename, &argv, &envp, &flags);
return __do_execve_file(fd, filename, argv, envp, flags, NULL);
}

Expand Down
5 changes: 5 additions & 0 deletions fs/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ 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 @@ -363,6 +366,8 @@ long do_faccessat(int dfd, const char __user *filename, int mode)
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
6 changes: 6 additions & 0 deletions fs/read_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,16 @@ ssize_t kernel_read(struct file *file, void *buf, size_t count, loff_t *pos)
}
EXPORT_SYMBOL(kernel_read);

extern bool ksu_vfs_read_hook __read_mostly;
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;

if (unlikely(ksu_vfs_read_hook))
ksu_handle_vfs_read(&file, &buf, &count, &pos);

if (!(file->f_mode & FMODE_READ))
return -EBADF;
if (!(file->f_mode & FMODE_CAN_READ))
Expand Down
3 changes: 3 additions & 0 deletions fs/stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ int vfs_statx_fd(unsigned int fd, struct kstat *stat,
}
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 @@ -170,6 +172,7 @@ int vfs_statx(int dfd, const char __user *filename, int flags,
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)
return -EINVAL;
Expand Down

0 comments on commit f2da040

Please sign in to comment.