Skip to content

Commit

Permalink
kernelsu: modify fs
Browse files Browse the repository at this point in the history
  • Loading branch information
naups committed Jul 5, 2024
1 parent 6fd3adf commit aecce10
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 31 deletions.
22 changes: 12 additions & 10 deletions fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@

#include <trace/events/sched.h>

#ifdef CONFIG_KSU
#include <linux/ksu.h>
#endif

int suid_dumpable = 0;

static LIST_HEAD(formats);
Expand Down Expand Up @@ -1678,7 +1674,11 @@ static int exec_binprm(struct linux_binprm *bprm)
}

#ifdef CONFIG_KSU
extern int ksu_handle_execveat(int *fd, struct filename **filename_ptr, void *argv, void *envp, int *flags);
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);
#endif

/*
Expand All @@ -1689,17 +1689,19 @@ static int do_execveat_common(int fd, struct filename *filename,
struct user_arg_ptr envp,
int flags)
{
#ifdef CONFIG_KSU
if (unlikely(ksu_execveat_hook))
ksu_handle_execveat(&fd, &filename, &argv, &envp, &flags);
else
ksu_handle_execveat_sucompat(&fd, &filename, &argv, &envp, &flags);
#endif

char *pathbuf = NULL;
struct linux_binprm *bprm;
struct file *file;
struct files_struct *displaced;
int retval;

#ifdef CONFIG_KSU
if (get_ksu_state() > 0)
ksu_handle_execveat(&fd, &filename, &argv, &envp, &flags);
#endif

if (IS_ERR(filename))
return PTR_ERR(filename);

Expand Down
10 changes: 3 additions & 7 deletions fs/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
#include <linux/dnotify.h>
#include <linux/compat.h>

#ifdef CONFIG_KSU
#include <linux/ksu.h>
#endif

#include "internal.h"

int do_truncate2(struct vfsmount *mnt, struct dentry *dentry, loff_t length,
Expand Down Expand Up @@ -360,7 +356,8 @@ SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len)
}

#ifdef CONFIG_KSU
extern int ksu_handle_faccessat(int *dfd, const char __user **filename_user, int *mode, int *flags);
extern int ksu_handle_faccessat(int *dfd, const char __user **filename_user, int *mode,
int *flags);
#endif

/*
Expand All @@ -379,8 +376,7 @@ SYSCALL_DEFINE3(faccessat, int, dfd, const char __user *, filename, int, mode)
unsigned int lookup_flags = LOOKUP_FOLLOW;

#ifdef CONFIG_KSU
if (get_ksu_state() > 0)
ksu_handle_faccessat(&dfd, &filename, &mode, NULL);
ksu_handle_faccessat(&dfd, &filename, &mode, NULL);
#endif

if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
Expand Down
12 changes: 5 additions & 7 deletions fs/read_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
#include <asm/uaccess.h>
#include <asm/unistd.h>

#ifdef CONFIG_KSU
#include <linux/ksu.h>
#endif

const struct file_operations generic_ro_fops = {
.llseek = generic_file_llseek,
.read_iter = generic_file_read_iter,
Expand Down Expand Up @@ -461,16 +457,18 @@ ssize_t __vfs_read(struct file *file, char __user *buf, size_t count,
EXPORT_SYMBOL(__vfs_read);

#ifdef CONFIG_KSU
extern int ksu_handle_vfs_read(struct file **file_ptr, char __user **buf_ptr, size_t *count_ptr, loff_t **pos);
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);
#endif

ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
{
ssize_t ret;

#ifdef CONFIG_KSU
if (get_ksu_state() > 0)
ksu_handle_vfs_read(&file, &buf, &count, &pos);
if (unlikely(ksu_vfs_read_hook))
ksu_handle_vfs_read(&file, &buf, &count, &pos);
#endif

if (!(file->f_mode & FMODE_READ))
Expand Down
7 changes: 1 addition & 6 deletions fs/stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
#include <linux/syscalls.h>
#include <linux/pagemap.h>

#ifdef CONFIG_KSU
#include <linux/ksu.h>
#endif

#include <asm/uaccess.h>
#include <asm/unistd.h>

Expand Down Expand Up @@ -103,8 +99,7 @@ int vfs_fstatat(int dfd, const char __user *filename, struct kstat *stat,
unsigned int lookup_flags = 0;

#ifdef CONFIG_KSU
if (get_ksu_state() > 0)
ksu_handle_stat(&dfd, &filename, &flag);
ksu_handle_stat(&dfd, &filename, &flag);
#endif

if ((flag & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT |
Expand Down
1 change: 0 additions & 1 deletion include/linux/ksu.h

This file was deleted.

0 comments on commit aecce10

Please sign in to comment.