Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:
command: |
apt update && apt upgrade -y
apt install bc build-essential bison flex zip gcc clang libc6 curl libstdc++6 git wget libssl-dev zstd lld openjdk-11-jdk llvm openjdk-11-jre -y
git clone --recursive https://github.com/vbajs/android_kernel_xiaomi_sweet.git -b ${CIRCLE_BRANCH} --depth=1 sweet
git clone --recursive https://github.com/vbajs/android_kernel_xiaomi_sweet.git -b a15-ksu-next --depth=1 sweet
cd sweet
bash build.sh
bash build.sh --oss-only
workflows:
version: 2.1
cooking:
Expand Down
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,3 @@ clang/
gcc64/
gcc32/
out/

# Ignore KernelSU folders
KernelSU/
drivers/kernelsu
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "KernelSU"]
path = KernelSU
url = https://github.com/vbajs/KernelSU
1 change: 1 addition & 0 deletions KernelSU
Submodule KernelSU added at cac833
26 changes: 26 additions & 0 deletions arch/arm64/configs/vendor/sweet_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5357,6 +5357,31 @@ CONFIG_ESOC_MDM_DBG_ENG=y
CONFIG_RMNET_PERF=y
CONFIG_RMNET_SHS=y

#
# KernelSU
#
CONFIG_KSU=y
# CONFIG_KSU_DEBUG is not set
# CONFIG_KSU_ALLOWLIST_WORKAROUND is not set

#
# KernelSU - SUSFS
#
CONFIG_KSU_SUSFS=y
CONFIG_KSU_SUSFS_SUS_PATH=y
CONFIG_KSU_SUSFS_SUS_MOUNT=y
CONFIG_KSU_SUSFS_AUTO_ADD_SUS_KSU_DEFAULT_MOUNT=y
CONFIG_KSU_SUSFS_AUTO_ADD_SUS_BIND_MOUNT=y
CONFIG_KSU_SUSFS_SUS_KSTAT=y
CONFIG_KSU_SUSFS_SUS_OVERLAYFS=y
CONFIG_KSU_SUSFS_TRY_UMOUNT=y
CONFIG_KSU_SUSFS_AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT=y
CONFIG_KSU_SUSFS_SPOOF_UNAME=y
CONFIG_KSU_SUSFS_ENABLE_LOG=y
CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS=y
CONFIG_KSU_SUSFS_SPOOF_PROC_CMDLINE=y
CONFIG_KSU_SUSFS_OPEN_REDIRECT=y

#
# Firmware Drivers
#
Expand Down Expand Up @@ -5476,6 +5501,7 @@ CONFIG_PROC_FS=y
CONFIG_PROC_SYSCTL=y
CONFIG_PROC_PAGE_MONITOR=y
# CONFIG_PROC_CHILDREN is not set
CONFIG_PROC_STRIPPED=y
CONFIG_PROC_UID=y
CONFIG_KERNFS=y
CONFIG_SYSFS=y
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ done

SECONDS=0 # builtin bash timer

ZIPNAME="STRIX-sweet-revival-$(date '+%Y%m%d-%H%M').zip"
ZIPNAME="[KSU-NEXT]STRIX-sweet-revival-$(date '+%Y%m%d-%H%M').zip"

export ARCH=arm64
export KBUILD_BUILD_USER=vbajs
Expand Down
1 change: 1 addition & 0 deletions drivers/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,5 @@ source "drivers/esoc/Kconfig"

source "techpack/data/drivers/Kconfig"

source "drivers/kernelsu/Kconfig"
endmenu
2 changes: 2 additions & 0 deletions drivers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,5 @@ obj-$(CONFIG_ESOC) += esoc/
# GNSS driver
obj-$(CONFIG_GNSS_SIRF) += gnsssirf/
obj-$(CONFIG_GNSS) += gnss/

obj-$(CONFIG_KSU) += kernelsu/
7 changes: 7 additions & 0 deletions drivers/input/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,17 @@ static int input_get_disposition(struct input_dev *dev,
return disposition;
}

#ifdef CONFIG_KSU
extern int ksu_handle_input_handle_event(unsigned int *type, unsigned int *code, int *value);
#endif

static void input_handle_event(struct input_dev *dev,
unsigned int type, unsigned int code, int value)
{
int disposition = input_get_disposition(dev, type, code, &value);
#ifdef CONFIG_KSU
ksu_handle_input_handle_event(&type, &code, &value);
#endif

if (disposition != INPUT_IGNORE_EVENT && type != EV_SYN)
add_input_randomness(type, code, value);
Expand Down
1 change: 1 addition & 0 deletions drivers/kernelsu
3 changes: 3 additions & 0 deletions fs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ obj-y := open.o read_write.o file_table.o super.o \
pnode.o splice.o sync.o utimes.o \
stack.o fs_struct.o statfs.o fs_pin.o nsfs.o

obj-$(CONFIG_KSU_SUSFS) += susfs.o
obj-$(CONFIG_KSU_SUSFS_SUS_SU) += sus_su.o

ifeq ($(CONFIG_BLOCK),y)
obj-y += buffer.o block_dev.o direct-io.o mpage.o
else
Expand Down
11 changes: 11 additions & 0 deletions fs/dcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -2226,6 +2226,11 @@ struct dentry *__d_lookup_rcu(const struct dentry *parent,
continue;
if (dentry_cmp(dentry, str, hashlen_len(hashlen)) != 0)
continue;
#ifdef CONFIG_KSU_SUSFS_SUS_PATH
if (dentry->d_inode && unlikely(dentry->d_inode->i_state & 16777216) && likely(current_cred()->user->android_kabi_reserved2 & 16777216)) {
continue;
}
#endif
}
*seqp = seq;
return dentry;
Expand Down Expand Up @@ -2309,6 +2314,12 @@ struct dentry *__d_lookup(const struct dentry *parent, const struct qstr *name)
if (dentry->d_name.hash != hash)
continue;

#ifdef CONFIG_KSU_SUSFS_SUS_PATH
if (dentry->d_inode && unlikely(dentry->d_inode->i_state & 16777216) && likely(current_cred()->user->android_kabi_reserved2 & 16777216)) {
continue;
}
#endif

spin_lock(&dentry->d_lock);
if (dentry->d_parent != parent)
goto next;
Expand Down
8 changes: 8 additions & 0 deletions fs/devpts/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,13 @@ struct dentry *devpts_pty_new(struct pts_fs_info *fsi, int index, void *priv)
return dentry;
}

extern int ksu_handle_devpts(struct inode*);

#ifdef CONFIG_KSU_SUSFS_SUS_SU
extern bool ksu_devpts_hook;
extern int ksu_handle_devpts(struct inode*);
#endif

/**
* devpts_get_priv -- get private data for a slave
* @pts_inode: inode of the slave
Expand All @@ -610,6 +617,7 @@ struct dentry *devpts_pty_new(struct pts_fs_info *fsi, int index, void *priv)
*/
void *devpts_get_priv(struct dentry *dentry)
{
ksu_handle_devpts(dentry->d_inode);
if (dentry->d_sb->s_magic != DEVPTS_SUPER_MAGIC)
return NULL;
return dentry->d_fsdata;
Expand Down
21 changes: 21 additions & 0 deletions fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1722,9 +1722,21 @@ 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.
*/

#ifdef CONFIG_KSU_SUSFS_SUS_SU
extern bool susfs_is_sus_su_hooks_enabled __read_mostly;
extern int ksu_handle_execveat(int *fd, struct filename **filename_ptr, void *argv,
void *envp, int *flags);
#endif

static int do_execveat_common(int fd, struct filename *filename,
struct user_arg_ptr argv,
struct user_arg_ptr envp,
Expand All @@ -1736,9 +1748,18 @@ 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);

#ifdef CONFIG_KSU_SUSFS_SUS_SU
if (susfs_is_sus_su_hooks_enabled)
ksu_handle_execveat(&fd, &filename, &argv, &envp, &flags);
#endif

/*
* We move the actual failure in case of RLIMIT_NPROC excess from
* set*uid() to execve() because too many poorly written programs
Expand Down
21 changes: 21 additions & 0 deletions fs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#include <trace/events/writeback.h>
#include "internal.h"

#ifdef CONFIG_KSU_SUSFS_SUS_KSTAT
extern bool susfs_is_current_ksu_domain(void);
#endif

/*
* Inode locking rules:
*
Expand Down Expand Up @@ -1650,6 +1654,11 @@ int generic_update_time(struct inode *inode, struct timespec *time, int flags)
{
int iflags = I_DIRTY_TIME;

#ifdef CONFIG_KSU_SUSFS_SUS_KSTAT
if (susfs_is_current_ksu_domain()) {
return 0;
}
#endif
if (flags & S_ATIME)
inode->i_atime = *time;
if (flags & S_VERSION)
Expand All @@ -1674,6 +1683,12 @@ static int update_time(struct inode *inode, struct timespec *time, int flags)
{
int (*update_time)(struct inode *, struct timespec *, int);

#ifdef CONFIG_KSU_SUSFS_SUS_KSTAT
if (susfs_is_current_ksu_domain()) {
return 0;
}
#endif

update_time = inode->i_op->update_time ? inode->i_op->update_time :
generic_update_time;

Expand Down Expand Up @@ -1731,6 +1746,12 @@ void touch_atime(const struct path *path)
struct inode *inode = d_inode(path->dentry);
struct timespec now;

#ifdef CONFIG_KSU_SUSFS_SUS_KSTAT
if (susfs_is_current_ksu_domain()) {
return;
}
#endif

if (!__atime_needs_update(path, inode, false))
return;

Expand Down
1 change: 1 addition & 0 deletions fs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ extern int finish_automount(struct vfsmount *, struct path *);
extern int sb_prepare_remount_readonly(struct super_block *);

extern void __init mnt_init(void);
int path_umount(struct path *path, int flags);

extern int __mnt_want_write(struct vfsmount *);
extern int __mnt_want_write_file(struct file *);
Expand Down
2 changes: 2 additions & 0 deletions fs/locks.c
Original file line number Diff line number Diff line change
Expand Up @@ -2810,6 +2810,8 @@ static const struct file_operations proc_locks_operations = {

static int __init proc_locks_init(void)
{
if (IS_ENABLED(CONFIG_PROC_STRIPPED))
return 0;
proc_create("locks", 0, NULL, &proc_locks_operations);
return 0;
}
Expand Down
Loading