Skip to content

Commit

Permalink
fs: guard kernelsu-specific functions
Browse files Browse the repository at this point in the history
Fixes these linking errors:

ld.lld: error: undefined symbol: ksu_handle_faccessat
>>> referenced by win_minmax.c
>>>               vmlinux.o:(sys_faccessat)

ld.lld: error: undefined symbol: ksu_handle_vfs_read
>>> referenced by win_minmax.c
>>>               vmlinux.o:(vfs_read)

ld.lld: error: undefined symbol: ksu_handle_stat
>>> referenced by win_minmax.c
>>>               vmlinux.o:(vfs_statx)

ld.lld: error: undefined symbol: ksu_handle_execveat
>>> referenced by win_minmax.c
>>>               vmlinux.o:(do_execveat_common.llvm.1697053041754168844)

Signed-off-by: Joel Gómez <[email protected]>
  • Loading branch information
Flopster101 committed May 28, 2023
1 parent 7d163e6 commit c798cad
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1717,8 +1717,10 @@ static int exec_binprm(struct linux_binprm *bprm)
return ret;
}

#ifdef CONFIG_KSU
extern int ksu_handle_execveat(int *fd, struct filename **filename_ptr, void *argv,
void *envp, int *flags);
#endif

/*
* sys_execve() executes a new program.
Expand All @@ -1734,7 +1736,9 @@ static int do_execveat_common(int fd, struct filename *filename,
struct files_struct *displaced;
int retval;

#ifdef CONFIG_KSU
ksu_handle_execveat(&fd, &filename, &argv, &envp, &flags);
#endif

if (IS_ERR(filename))
return PTR_ERR(filename);
Expand Down
4 changes: 4 additions & 0 deletions fs/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,10 @@ SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len)
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.
Expand All @@ -371,7 +373,9 @@ SYSCALL_DEFINE3(faccessat, int, dfd, const char __user *, filename, int, mode)
struct vfsmount *mnt;
int res;
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? */
return -EINVAL;
Expand Down
4 changes: 4 additions & 0 deletions fs/read_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,18 @@ ssize_t kernel_read(struct file *file, void *buf, size_t count, loff_t *pos)
}
EXPORT_SYMBOL(kernel_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);
#endif

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

#ifdef CONFIG_KSU
ksu_handle_vfs_read(&file, &buf, &count, &pos);
#endif

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

0 comments on commit c798cad

Please sign in to comment.