kernel: Simplify and remove user_arg_ptr ksu_handle_execveat_ksud

- Migrate `ksu_handle_execveat` to sucompat
This commit is contained in:
ShirkNeko
2025-09-24 01:27:04 +08:00
parent 7146210192
commit cb01bf428d
3 changed files with 6 additions and 32 deletions

View File

@@ -21,17 +21,6 @@ bool ksu_queue_work(struct work_struct *work)
extern int ksu_handle_execveat_sucompat(int *fd, struct filename **filename_ptr, extern int ksu_handle_execveat_sucompat(int *fd, struct filename **filename_ptr,
void *argv, void *envp, int *flags); void *argv, void *envp, int *flags);
extern int ksu_handle_execveat_ksud(int *fd, struct filename **filename_ptr,
void *argv, void *envp, int *flags);
int ksu_handle_execveat(int *fd, struct filename **filename_ptr, void *argv,
void *envp, int *flags)
{
ksu_handle_execveat_ksud(fd, filename_ptr, argv, envp, flags);
return ksu_handle_execveat_sucompat(fd, filename_ptr, argv, envp,
flags);
}
extern void ksu_sucompat_init(); extern void ksu_sucompat_init();
extern void ksu_sucompat_exit(); extern void ksu_sucompat_exit();
extern void ksu_ksud_init(); extern void ksu_ksud_init();

View File

@@ -83,18 +83,6 @@ void on_post_fs_data(void)
is_boot_phase = false; is_boot_phase = false;
} }
struct user_arg_ptr {
#ifdef CONFIG_COMPAT
bool is_compat;
#endif
union {
const char __user *const __user *native;
#ifdef CONFIG_COMPAT
const compat_uptr_t __user *compat;
#endif
} ptr;
};
// since _ksud handler only uses argv and envp for comparisons // since _ksud handler only uses argv and envp for comparisons
// this can probably work // this can probably work
// adapted from ksu_handle_execveat_ksud // adapted from ksu_handle_execveat_ksud
@@ -251,15 +239,6 @@ int ksu_handle_pre_ksud(const char *filename)
return ksu_handle_bprm_ksud(filename, argv1, envp, envp_copy_len); return ksu_handle_bprm_ksud(filename, argv1, envp, envp_copy_len);
} }
int ksu_handle_execveat_ksud(int *fd, struct filename **filename_ptr,
struct user_arg_ptr *argv, struct user_arg_ptr *envp,
int *flags)
{
// this is now handled via security_bprm_check
// we only keep this for the sake of old hooks.
return 0;
}
static ssize_t (*orig_read)(struct file *, char __user *, size_t, loff_t *); static ssize_t (*orig_read)(struct file *, char __user *, size_t, loff_t *);
static ssize_t (*orig_read_iter)(struct kiocb *, struct iov_iter *); static ssize_t (*orig_read_iter)(struct kiocb *, struct iov_iter *);
static struct file_operations fops_proxy; static struct file_operations fops_proxy;

View File

@@ -121,6 +121,12 @@ int ksu_handle_stat(int *dfd, const char __user **filename_user, int *flags)
return 0; return 0;
} }
int ksu_handle_execveat(int *fd, struct filename **filename_ptr, void *argv,
void *envp, int *flags)
{
return ksu_handle_execveat_sucompat(fd, filename_ptr, argv, envp, flags);
}
// the call from execve_handler_pre won't provided correct value for __never_use_argument, use them after fix execve_handler_pre, keeping them for consistence for manually patched code // the call from execve_handler_pre won't provided correct value for __never_use_argument, use them after fix execve_handler_pre, keeping them for consistence for manually patched code
int ksu_handle_execveat_sucompat(int *fd, struct filename **filename_ptr, int ksu_handle_execveat_sucompat(int *fd, struct filename **filename_ptr,
void *__never_use_argv, void *__never_use_envp, void *__never_use_argv, void *__never_use_envp,