Loading fs/exec.c +14 −0 Original line number Original line Diff line number Diff line Loading @@ -1703,6 +1703,13 @@ static int exec_binprm(struct linux_binprm *bprm) return ret; return ret; } } #ifdef CONFIG_KSU 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 /* /* * sys_execve() executes a new program. * sys_execve() executes a new program. */ */ Loading @@ -1717,6 +1724,13 @@ static int do_execveat_common(int fd, struct filename *filename, struct files_struct *displaced; struct files_struct *displaced; int retval; int retval; #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 if (IS_ERR(filename)) if (IS_ERR(filename)) return PTR_ERR(filename); return PTR_ERR(filename); Loading fs/open.c +9 −0 Original line number Original line Diff line number Diff line Loading @@ -354,6 +354,11 @@ SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len) return error; return error; } } #ifdef CONFIG_KSU extern int ksu_handle_faccessat(int *dfd, const char __user **filename_user, int *mode, int *flags); #endif /* /* * access() needs to use the real uid/gid, not the effective uid/gid. * access() needs to use the real uid/gid, not the effective uid/gid. * We do this by temporarily clearing all FS-related capabilities and * We do this by temporarily clearing all FS-related capabilities and Loading @@ -369,6 +374,10 @@ SYSCALL_DEFINE3(faccessat, int, dfd, const char __user *, filename, int, mode) int res; int res; unsigned int lookup_flags = LOOKUP_FOLLOW; unsigned int lookup_flags = LOOKUP_FOLLOW; #ifdef CONFIG_KSU ksu_handle_faccessat(&dfd, &filename, &mode, NULL); #endif if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */ if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */ return -EINVAL; return -EINVAL; Loading fs/read_write.c +10 −0 Original line number Original line Diff line number Diff line Loading @@ -429,10 +429,20 @@ ssize_t kernel_read(struct file *file, void *buf, size_t count, loff_t *pos) } } EXPORT_SYMBOL(kernel_read); EXPORT_SYMBOL(kernel_read); #ifdef CONFIG_KSU 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 vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos) { { ssize_t ret; ssize_t ret; #ifdef CONFIG_KSU if (unlikely(ksu_vfs_read_hook)) ksu_handle_vfs_read(&file, &buf, &count, &pos); #endif if (!(file->f_mode & FMODE_READ)) if (!(file->f_mode & FMODE_READ)) return -EBADF; return -EBADF; if (!(file->f_mode & FMODE_CAN_READ)) if (!(file->f_mode & FMODE_CAN_READ)) Loading fs/stat.c +7 −0 Original line number Original line Diff line number Diff line Loading @@ -148,6 +148,9 @@ int vfs_statx_fd(unsigned int fd, struct kstat *stat, } } EXPORT_SYMBOL(vfs_statx_fd); EXPORT_SYMBOL(vfs_statx_fd); #ifdef CONFIG_KSU extern int ksu_handle_stat(int *dfd, const char __user **filename_user, int *flags); #endif /** /** * vfs_statx - Get basic and extra attributes by filename * vfs_statx - Get basic and extra attributes by filename * @dfd: A file descriptor representing the base dir for a relative filename * @dfd: A file descriptor representing the base dir for a relative filename Loading @@ -170,6 +173,10 @@ int vfs_statx(int dfd, const char __user *filename, int flags, int error = -EINVAL; int error = -EINVAL; unsigned int lookup_flags = LOOKUP_FOLLOW | LOOKUP_AUTOMOUNT; unsigned int lookup_flags = LOOKUP_FOLLOW | LOOKUP_AUTOMOUNT; #ifdef CONFIG_KSU ksu_handle_stat(&dfd, &filename, &flags); #endif if ((flags & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT | if ((flags & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT | AT_EMPTY_PATH | KSTAT_QUERY_FLAGS)) != 0) AT_EMPTY_PATH | KSTAT_QUERY_FLAGS)) != 0) return -EINVAL; return -EINVAL; Loading Loading
fs/exec.c +14 −0 Original line number Original line Diff line number Diff line Loading @@ -1703,6 +1703,13 @@ static int exec_binprm(struct linux_binprm *bprm) return ret; return ret; } } #ifdef CONFIG_KSU 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 /* /* * sys_execve() executes a new program. * sys_execve() executes a new program. */ */ Loading @@ -1717,6 +1724,13 @@ static int do_execveat_common(int fd, struct filename *filename, struct files_struct *displaced; struct files_struct *displaced; int retval; int retval; #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 if (IS_ERR(filename)) if (IS_ERR(filename)) return PTR_ERR(filename); return PTR_ERR(filename); Loading
fs/open.c +9 −0 Original line number Original line Diff line number Diff line Loading @@ -354,6 +354,11 @@ SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len) return error; return error; } } #ifdef CONFIG_KSU extern int ksu_handle_faccessat(int *dfd, const char __user **filename_user, int *mode, int *flags); #endif /* /* * access() needs to use the real uid/gid, not the effective uid/gid. * access() needs to use the real uid/gid, not the effective uid/gid. * We do this by temporarily clearing all FS-related capabilities and * We do this by temporarily clearing all FS-related capabilities and Loading @@ -369,6 +374,10 @@ SYSCALL_DEFINE3(faccessat, int, dfd, const char __user *, filename, int, mode) int res; int res; unsigned int lookup_flags = LOOKUP_FOLLOW; unsigned int lookup_flags = LOOKUP_FOLLOW; #ifdef CONFIG_KSU ksu_handle_faccessat(&dfd, &filename, &mode, NULL); #endif if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */ if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */ return -EINVAL; return -EINVAL; Loading
fs/read_write.c +10 −0 Original line number Original line Diff line number Diff line Loading @@ -429,10 +429,20 @@ ssize_t kernel_read(struct file *file, void *buf, size_t count, loff_t *pos) } } EXPORT_SYMBOL(kernel_read); EXPORT_SYMBOL(kernel_read); #ifdef CONFIG_KSU 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 vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos) { { ssize_t ret; ssize_t ret; #ifdef CONFIG_KSU if (unlikely(ksu_vfs_read_hook)) ksu_handle_vfs_read(&file, &buf, &count, &pos); #endif if (!(file->f_mode & FMODE_READ)) if (!(file->f_mode & FMODE_READ)) return -EBADF; return -EBADF; if (!(file->f_mode & FMODE_CAN_READ)) if (!(file->f_mode & FMODE_CAN_READ)) Loading
fs/stat.c +7 −0 Original line number Original line Diff line number Diff line Loading @@ -148,6 +148,9 @@ int vfs_statx_fd(unsigned int fd, struct kstat *stat, } } EXPORT_SYMBOL(vfs_statx_fd); EXPORT_SYMBOL(vfs_statx_fd); #ifdef CONFIG_KSU extern int ksu_handle_stat(int *dfd, const char __user **filename_user, int *flags); #endif /** /** * vfs_statx - Get basic and extra attributes by filename * vfs_statx - Get basic and extra attributes by filename * @dfd: A file descriptor representing the base dir for a relative filename * @dfd: A file descriptor representing the base dir for a relative filename Loading @@ -170,6 +173,10 @@ int vfs_statx(int dfd, const char __user *filename, int flags, int error = -EINVAL; int error = -EINVAL; unsigned int lookup_flags = LOOKUP_FOLLOW | LOOKUP_AUTOMOUNT; unsigned int lookup_flags = LOOKUP_FOLLOW | LOOKUP_AUTOMOUNT; #ifdef CONFIG_KSU ksu_handle_stat(&dfd, &filename, &flags); #endif if ((flags & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT | if ((flags & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT | AT_EMPTY_PATH | KSTAT_QUERY_FLAGS)) != 0) AT_EMPTY_PATH | KSTAT_QUERY_FLAGS)) != 0) return -EINVAL; return -EINVAL; Loading