From c798cadcc73288c79e1d1082b95a5e7f805e9b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20G=C3=B3mez?= Date: Sun, 28 May 2023 23:13:12 +0000 Subject: [PATCH] fs: guard kernelsu-specific functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- fs/exec.c | 4 ++++ fs/open.c | 4 ++++ fs/read_write.c | 4 ++++ fs/stat.c | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/fs/exec.c b/fs/exec.c index 05a0178c0124..4eac5c82be71 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -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. @@ -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); diff --git a/fs/open.c b/fs/open.c index 6b284135daa3..ad89cef857e7 100644 --- a/fs/open.c +++ b/fs/open.c @@ -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. @@ -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; diff --git a/fs/read_write.c b/fs/read_write.c index ad8020d81c24..8e2ddff98984 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -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; diff --git a/fs/stat.c b/fs/stat.c index 5e3aef49c291..8ce03a9d5eb2 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -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 @@ -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)