kernel: fix compile err on lower kernel
This commit is contained in:
@@ -4,6 +4,15 @@
|
|||||||
#include "linux/fs.h"
|
#include "linux/fs.h"
|
||||||
#include "linux/key.h"
|
#include "linux/key.h"
|
||||||
#include "linux/version.h"
|
#include "linux/version.h"
|
||||||
|
#include "linux/uaccess.h"
|
||||||
|
|
||||||
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
|
||||||
|
#define ksu_strncpy_from_user_nofault strncpy_from_user_nofault
|
||||||
|
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)
|
||||||
|
#define ksu_strncpy_from_user_nofault strncpy_from_unsafe_user
|
||||||
|
#else
|
||||||
|
#define ksu_strncpy_from_user_nofault strncpy_from_user
|
||||||
|
#endif
|
||||||
|
|
||||||
extern struct key *init_session_keyring;
|
extern struct key *init_session_keyring;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
#include "asm/current.h"
|
#include "asm/current.h"
|
||||||
#include "linux/string.h"
|
|
||||||
#include "linux/compat.h"
|
#include "linux/compat.h"
|
||||||
#include "linux/cred.h"
|
|
||||||
#include "linux/dcache.h"
|
#include "linux/dcache.h"
|
||||||
#include "linux/err.h"
|
#include "linux/err.h"
|
||||||
#include "linux/fs.h"
|
#include "linux/fs.h"
|
||||||
@@ -12,12 +10,12 @@
|
|||||||
#include "linux/uaccess.h"
|
#include "linux/uaccess.h"
|
||||||
#include "linux/version.h"
|
#include "linux/version.h"
|
||||||
#include "linux/workqueue.h"
|
#include "linux/workqueue.h"
|
||||||
#include "linux/input.h"
|
|
||||||
|
|
||||||
#include "allowlist.h"
|
#include "allowlist.h"
|
||||||
#include "arch.h"
|
#include "arch.h"
|
||||||
#include "klog.h" // IWYU pragma: keep
|
#include "klog.h" // IWYU pragma: keep
|
||||||
#include "ksud.h"
|
#include "ksud.h"
|
||||||
|
#include "kernel_compat.h"
|
||||||
#include "selinux/selinux.h"
|
#include "selinux/selinux.h"
|
||||||
|
|
||||||
static const char KERNEL_SU_RC[] =
|
static const char KERNEL_SU_RC[] =
|
||||||
@@ -174,13 +172,7 @@ int ksu_handle_execveat_ksud(int *fd, struct filename **filename_ptr,
|
|||||||
const char __user *p = get_user_arg_ptr(*ptr, 1);
|
const char __user *p = get_user_arg_ptr(*ptr, 1);
|
||||||
if (p && !IS_ERR(p)) {
|
if (p && !IS_ERR(p)) {
|
||||||
char first_arg[16];
|
char first_arg[16];
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
|
ksu_strncpy_from_user_nofault(first_arg, p, sizeof(first_arg));
|
||||||
strncpy_from_user_nofault(first_arg, p, sizeof(first_arg));
|
|
||||||
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)
|
|
||||||
strncpy_from_unsafe_user(first_arg, p, sizeof(first_arg));
|
|
||||||
#else
|
|
||||||
strncpy_from_user(first_arg, p, sizeof(first_arg));
|
|
||||||
#endif
|
|
||||||
pr_info("first arg: %s\n", first_arg);
|
pr_info("first arg: %s\n", first_arg);
|
||||||
if (!strcmp(first_arg, "second_stage")) {
|
if (!strcmp(first_arg, "second_stage")) {
|
||||||
pr_info("/system/bin/init second_stage executed\n");
|
pr_info("/system/bin/init second_stage executed\n");
|
||||||
|
|||||||
@@ -16,16 +16,11 @@
|
|||||||
#include "arch.h"
|
#include "arch.h"
|
||||||
#include "klog.h" // IWYU pragma: keep
|
#include "klog.h" // IWYU pragma: keep
|
||||||
#include "ksud.h"
|
#include "ksud.h"
|
||||||
|
#include "kernel_compat.h"
|
||||||
|
|
||||||
#define SU_PATH "/system/bin/su"
|
#define SU_PATH "/system/bin/su"
|
||||||
#define SH_PATH "/system/bin/sh"
|
#define SH_PATH "/system/bin/sh"
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
|
|
||||||
#define ksu_strncpy_from_user_nofault strncpy_from_user_nofault
|
|
||||||
#else
|
|
||||||
#define ksu_strncpy_from_user_nofault strncpy_from_unsafe_user
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern void escape_to_root();
|
extern void escape_to_root();
|
||||||
|
|
||||||
static void __user *userspace_stack_buffer(const void *d, size_t len)
|
static void __user *userspace_stack_buffer(const void *d, size_t len)
|
||||||
|
|||||||
Reference in New Issue
Block a user