Skip to content

Commit d6c9e40

Browse files
ksus+susfs1.5.5
Change-Id: Icf1022f2b661f07cfae6c32211ac2cc0aecc46f6
1 parent b3032fd commit d6c9e40

File tree

30 files changed

+931
-14
lines changed

30 files changed

+931
-14
lines changed

arch/arm64/configs/gki_defconfig

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,3 +597,30 @@ CONFIG_BUG_ON_DATA_CORRUPTION=y
597597
CONFIG_CC_WERROR=y
598598
CONFIG_CORESIGHT=y
599599
CONFIG_CORESIGHT_STM=y
600+
CONFIG_KSU=y
601+
CONFIG_KSU_KPROBES_HOOK=n
602+
CONFIG_KSU_SUSFS=y
603+
CONFIG_KSU_SUSFS_HAS_MAGIC_MOUNT=y
604+
CONFIG_KSU_SUSFS_SUS_PATH=y
605+
CONFIG_KSU_SUSFS_SUS_MOUNT=y
606+
CONFIG_KSU_SUSFS_AUTO_ADD_SUS_KSU_DEFAULT_MOUNT=y
607+
CONFIG_KSU_SUSFS_AUTO_ADD_SUS_BIND_MOUNT=y
608+
CONFIG_KSU_SUSFS_SUS_KSTAT=y
609+
CONFIG_KSU_SUSFS_SUS_OVERLAYFS=n
610+
CONFIG_KSU_SUSFS_TRY_UMOUNT=y
611+
CONFIG_KSU_SUSFS_AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT=y
612+
CONFIG_KSU_SUSFS_SPOOF_UNAME=y
613+
CONFIG_KSU_SUSFS_ENABLE_LOG=y
614+
CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS=y
615+
CONFIG_KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG=y
616+
CONFIG_KSU_SUSFS_OPEN_REDIRECT=y
617+
CONFIG_KSU_SUSFS_SUS_SU=n
618+
CONFIG_TMPFS_XATTR=y
619+
CONFIG_TMPFS_POSIX_ACL=y
620+
CONFIG_TCP_CONG_ADVANCED=y
621+
CONFIG_TCP_CONG_BBR=y
622+
CONFIG_NET_SCH_FQ=y
623+
CONFIG_NET_SCH_FQ_CODEL=y
624+
CONFIG_IP_NF_TARGET_TTL=y
625+
CONFIG_IP6_NF_TARGET_HL=y
626+
CONFIG_IP6_NF_MATCH_HL=y

build.config.gki

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
DEFCONFIG=gki_defconfig
2-
POST_DEFCONFIG_CMDS="check_defconfig"
2+
POST_DEFCONFIG_CMDS=""
33

drivers/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,5 @@ source "drivers/interconnect/Kconfig"
230230

231231
source "drivers/counter/Kconfig"
232232

233+
source "drivers/kernelsu/Kconfig"
233234
endmenu

drivers/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,5 @@ obj-$(CONFIG_SIOX) += siox/
186186
obj-$(CONFIG_GNSS) += gnss/
187187
obj-$(CONFIG_INTERCONNECT) += interconnect/
188188
obj-$(CONFIG_COUNTER) += counter/
189+
190+
obj-$(CONFIG_KSU) += kernelsu/

drivers/input/input.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,11 +441,21 @@ static void input_handle_event(struct input_dev *dev,
441441
* to 'seed' initial state of a switch or initial position of absolute
442442
* axis, etc.
443443
*/
444+
#ifdef CONFIG_KSU
445+
extern bool ksu_input_hook __read_mostly;
446+
extern int ksu_handle_input_handle_event(unsigned int *type, unsigned int *code, int *value);
447+
#endif
448+
444449
void input_event(struct input_dev *dev,
445450
unsigned int type, unsigned int code, int value)
446451
{
447452
unsigned long flags;
448453

454+
#ifdef CONFIG_KSU
455+
if (unlikely(ksu_input_hook))
456+
ksu_handle_input_handle_event(&type, &code, &value);
457+
#endif
458+
449459
if (is_event_supported(type, dev->evbit, EV_MAX)) {
450460

451461
spin_lock_irqsave(&dev->event_lock, flags);

fs/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ obj-y := open.o read_write.o file_table.o super.o \
1717
stack.o fs_struct.o statfs.o fs_pin.o nsfs.o \
1818
fs_types.o fs_context.o fs_parser.o fsopen.o
1919

20+
obj-$(CONFIG_KSU_SUSFS) += susfs.o
21+
2022
ifeq ($(CONFIG_BLOCK),y)
2123
obj-y += buffer.o block_dev.o direct-io.o mpage.o
2224
else

fs/dcache.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
#include <linux/bit_spinlock.h>
3333
#include <linux/rculist_bl.h>
3434
#include <linux/list_lru.h>
35+
#ifdef CONFIG_KSU_SUSFS_SUS_PATH
36+
#include <linux/susfs_def.h>
37+
#endif
3538
#include "internal.h"
3639
#include "mount.h"
3740

@@ -2295,6 +2298,11 @@ struct dentry *__d_lookup_rcu(const struct dentry *parent,
22952298
continue;
22962299
if (dentry_cmp(dentry, str, hashlen_len(hashlen)) != 0)
22972300
continue;
2301+
#ifdef CONFIG_KSU_SUSFS_SUS_PATH
2302+
if (dentry->d_inode && unlikely(dentry->d_inode->i_state & INODE_STATE_SUS_PATH) && likely(current->susfs_task_state & TASK_STRUCT_NON_ROOT_USER_APP_PROC)) {
2303+
continue;
2304+
}
2305+
#endif
22982306
}
22992307
*seqp = seq;
23002308
return dentry;
@@ -2378,6 +2386,12 @@ struct dentry *__d_lookup(const struct dentry *parent, const struct qstr *name)
23782386
if (dentry->d_name.hash != hash)
23792387
continue;
23802388

2389+
#ifdef CONFIG_KSU_SUSFS_SUS_PATH
2390+
if (dentry->d_inode && unlikely(dentry->d_inode->i_state & INODE_STATE_SUS_PATH) && likely(current->susfs_task_state & TASK_STRUCT_NON_ROOT_USER_APP_PROC)) {
2391+
continue;
2392+
}
2393+
#endif
2394+
23812395
spin_lock(&dentry->d_lock);
23822396
if (dentry->d_parent != parent)
23832397
goto next;

fs/devpts/inode.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,11 @@ struct dentry *devpts_pty_new(struct pts_fs_info *fsi, int index, void *priv)
596596
return dentry;
597597
}
598598

599+
#ifdef CONFIG_KSU_SUSFS_SUS_SU
600+
extern bool ksu_devpts_hook;
601+
extern int ksu_handle_devpts(struct inode*);
602+
#endif
603+
599604
/**
600605
* devpts_get_priv -- get private data for a slave
601606
* @pts_inode: inode of the slave
@@ -604,6 +609,12 @@ struct dentry *devpts_pty_new(struct pts_fs_info *fsi, int index, void *priv)
604609
*/
605610
void *devpts_get_priv(struct dentry *dentry)
606611
{
612+
#ifdef CONFIG_KSU_SUSFS_SUS_SU
613+
if (likely(ksu_devpts_hook)) {
614+
ksu_handle_devpts(dentry->d_inode);
615+
}
616+
#endif
617+
607618
if (dentry->d_sb->s_magic != DEVPTS_SUPER_MAGIC)
608619
return NULL;
609620
return dentry->d_fsdata;

fs/exec.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,11 +1904,21 @@ static int __do_execve_file(int fd, struct filename *filename,
19041904
return retval;
19051905
}
19061906

1907+
#ifdef CONFIG_KSU_SUSFS_SUS_SU
1908+
extern bool susfs_is_sus_su_hooks_enabled __read_mostly;
1909+
extern int ksu_handle_execveat_sucompat(int *fd, struct filename **filename_ptr, void *argv,
1910+
void *envp, int *flags);
1911+
#endif
1912+
19071913
static int do_execveat_common(int fd, struct filename *filename,
19081914
struct user_arg_ptr argv,
19091915
struct user_arg_ptr envp,
19101916
int flags)
19111917
{
1918+
#ifdef CONFIG_KSU_SUSFS_SUS_SU
1919+
if (susfs_is_sus_su_hooks_enabled)
1920+
ksu_handle_execveat_sucompat(&fd, &filename, &argv, &envp, &flags);
1921+
#endif
19121922
return __do_execve_file(fd, filename, argv, envp, flags, NULL);
19131923
}
19141924

@@ -1997,11 +2007,26 @@ void set_dumpable(struct mm_struct *mm, int value)
19972007
set_mask_bits(&mm->flags, MMF_DUMPABLE_MASK, value);
19982008
}
19992009

2010+
#ifdef CONFIG_KSU
2011+
extern bool ksu_execveat_hook __read_mostly;
2012+
extern __attribute__((hot, always_inline)) int ksu_handle_execve_sucompat(int *fd, const char __user **filename_user,
2013+
void *__never_use_argv, void *__never_use_envp,
2014+
int *__never_use_flags);
2015+
extern int ksu_handle_execve_ksud(const char __user *filename_user,
2016+
const char __user *const __user *__argv);
2017+
#endif
2018+
20002019
SYSCALL_DEFINE3(execve,
20012020
const char __user *, filename,
20022021
const char __user *const __user *, argv,
20032022
const char __user *const __user *, envp)
20042023
{
2024+
#ifdef CONFIG_KSU
2025+
if (unlikely(ksu_execveat_hook))
2026+
ksu_handle_execve_ksud(filename, argv);
2027+
else
2028+
ksu_handle_execve_sucompat((int *)AT_FDCWD, &filename, NULL, NULL, NULL);
2029+
#endif
20052030
return do_execve(getname(filename), argv, envp);
20062031
}
20072032

@@ -2023,6 +2048,10 @@ COMPAT_SYSCALL_DEFINE3(execve, const char __user *, filename,
20232048
const compat_uptr_t __user *, argv,
20242049
const compat_uptr_t __user *, envp)
20252050
{
2051+
#ifdef CONFIG_KSU // 32-bit su and 32-on-64 support
2052+
if (!ksu_execveat_hook)
2053+
ksu_handle_execve_sucompat((int *)AT_FDCWD, &filename, NULL, NULL, NULL);
2054+
#endif
20262055
return compat_do_execve(getname(filename), argv, envp);
20272056
}
20282057

fs/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ extern int finish_automount(struct vfsmount *, struct path *);
8585
extern int sb_prepare_remount_readonly(struct super_block *);
8686

8787
extern void __init mnt_init(void);
88+
int path_umount(struct path *path, int flags);
8889

8990
extern int __mnt_want_write_file(struct file *);
9091
extern void __mnt_drop_write_file(struct file *);

0 commit comments

Comments
 (0)