Skip to content

Commit

Permalink
treewide: update susfs patches
Browse files Browse the repository at this point in the history
* Rev: ec9de84f250e16eab26bc090a64f4aa4c0d2a012

Signed-off-by: Nahuel Gómez <[email protected]>
  • Loading branch information
Flopster101 committed Dec 29, 2024
1 parent 15d8df3 commit e18f22b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 39 deletions.
14 changes: 10 additions & 4 deletions fs/devpts/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
#define DEVPTS_DEFAULT_PTMX_MODE 0000
#define PTMX_MINOR 2

#if defined(CONFIG_KSU_SUSFS_SUS_SU)
extern bool ksu_devpts_hook;
extern int ksu_handle_devpts(struct inode*);
#endif
/*
* sysctl support for setting limits on the number of Unix98 ptys allocated.
* Otherwise one can eat up all kernel memory by opening /dev/ptmx repeatedly.
Expand Down Expand Up @@ -602,10 +606,6 @@ struct dentry *devpts_pty_new(struct pts_fs_info *fsi, int index, void *priv)
return dentry;
}

#ifdef CONFIG_KSU_SUSFS_SUS_SU
extern bool ksu_devpts_hook;
#endif

#ifdef CONFIG_KSU
extern int ksu_handle_devpts(struct inode*);
#endif
Expand All @@ -621,6 +621,12 @@ void *devpts_get_priv(struct dentry *dentry)
#ifdef CONFIG_KSU
ksu_handle_devpts(dentry->d_inode);
#endif

#if defined(CONFIG_KSU_SUSFS_SUS_SU)
if (ksu_devpts_hook) {
ksu_handle_devpts(dentry->d_inode);
}
#endif
if (dentry->d_sb->s_magic != DEVPTS_SUPER_MAGIC)
return NULL;
return dentry->d_fsdata;
Expand Down
1 change: 0 additions & 1 deletion fs/overlayfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ int ovl_getattr(const struct path *path, struct kstat *stat,
goto out;
}
#endif

type = ovl_path_real(dentry, &realpath);
old_cred = ovl_override_creds(dentry->d_sb);
err = vfs_getattr(&realpath, stat, request_mask, flags);
Expand Down
11 changes: 4 additions & 7 deletions fs/proc/cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
#include <asm/setup.h>
#endif

#ifdef CONFIG_KSU_SUSFS_SPOOF_PROC_CMDLINE
extern int susfs_spoof_proc_cmdline(struct seq_file *m);
#ifdef KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG
extern int susfs_spoof_cmdline_or_bootconfig(struct seq_file *m);
#endif


#ifdef CONFIG_INITRAMFS_IGNORE_SKIP_FLAG
#define INITRAMFS_STR_FIND "skip_initramf"
#define INITRAMFS_STR_REPLACE "want_initramf"
Expand All @@ -34,14 +33,12 @@ static void proc_command_line_init(void) {

static int cmdline_proc_show(struct seq_file *m, void *v)
{

#ifdef CONFIG_KSU_SUSFS_SPOOF_PROC_CMDLINE
if (!susfs_spoof_proc_cmdline(m)) {
#ifdef KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG
if (!susfs_spoof_cmdline_or_bootconfig(m)) {
seq_putc(m, '\n');
return 0;
}
#endif

#ifdef CONFIG_INITRAMFS_IGNORE_SKIP_FLAG
seq_puts(m, proc_command_line);
seq_putc(m, '\n');
Expand Down
20 changes: 4 additions & 16 deletions fs/stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
#include <linux/uaccess.h>
#include <asm/unistd.h>

#ifdef CONFIG_KSU_SUSFS_SUS_KSTAT
extern void susfs_sus_ino_for_generic_fillattr(unsigned long ino, struct kstat *stat);
#endif

/**
* generic_fillattr - Fill in the basic attributes from the inode struct
* @inode: Inode to use as the source
Expand All @@ -34,6 +30,10 @@ extern void susfs_sus_ino_for_generic_fillattr(unsigned long ino, struct kstat *
* found on the VFS inode structure. This is the default if no getattr inode
* operation is supplied.
*/
#ifdef CONFIG_KSU_SUSFS_SUS_KSTAT
extern void susfs_sus_ino_for_generic_fillattr(unsigned long ino, struct kstat *stat);
#endif

void generic_fillattr(struct inode *inode, struct kstat *stat)
{
#ifdef CONFIG_KSU_SUSFS_SUS_KSTAT
Expand Down Expand Up @@ -181,12 +181,6 @@ extern int ksu_handle_stat(int *dfd, const char __user **filename_user, int *fla
*
* 0 will be returned on success, and a -ve error code if unsuccessful.
*/

#ifdef CONFIG_KSU_SUSFS_SUS_SU
extern bool susfs_is_sus_su_hooks_enabled __read_mostly;
extern int ksu_handle_stat(int *dfd, const char __user **filename_user, int *flags);
#endif

int vfs_statx(int dfd, const char __user *filename, int flags,
struct kstat *stat, u32 request_mask)
{
Expand All @@ -198,12 +192,6 @@ int vfs_statx(int dfd, const char __user *filename, int flags,
ksu_handle_stat(&dfd, &filename, &flags);
#endif

#ifdef CONFIG_KSU_SUSFS_SUS_SU
if (susfs_is_sus_su_hooks_enabled) {
ksu_handle_stat(&dfd, &filename, &flags);
}
#endif

if ((flags & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT |
AT_EMPTY_PATH | KSTAT_QUERY_FLAGS)) != 0)
return -EINVAL;
Expand Down
6 changes: 3 additions & 3 deletions include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -1465,13 +1465,13 @@ struct task_struct {
bool free_stack;
} async_free;

#ifdef CONFIG_KSU_SUSFS
u64 android_kabi_reserved8;
#endif
/*
* New fields for task_struct should be added above here, so that
* they are included in the randomized portion of task_struct.
*/
#ifdef CONFIG_KSU_SUSFS
u64 android_kabi_reserved8;
#endif
randomized_struct_fields_end

struct fuse_package *fpack;
Expand Down
10 changes: 2 additions & 8 deletions kernel/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -1183,10 +1183,9 @@ static int override_release(char __user *release, size_t len)
}

#ifdef CONFIG_KSU_SUSFS_SPOOF_UNAME
extern int susfs_spoof_uname(struct new_utsname* tmp);
extern void susfs_spoof_uname(struct new_utsname* tmp);
#endif


static uint64_t netbpfload_pid = 0;
SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
{
Expand All @@ -1199,11 +1198,6 @@ SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
}

down_read(&uts_sem);

#ifdef CONFIG_KSU_SUSFS_SPOOF_UNAME
if (likely(!susfs_spoof_uname(&tmp)))
goto bypass_orig_flow;
#endif
memcpy(&tmp, utsname(), sizeof(tmp));
if (bpf_spoof && !strncmp(current->comm, "netbpfload", 10) &&
current->pid != netbpfload_pid) {
Expand All @@ -1213,7 +1207,7 @@ SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
current->comm, current->pid, tmp.release);
}
#ifdef CONFIG_KSU_SUSFS_SPOOF_UNAME
bypass_orig_flow:
susfs_spoof_uname(&tmp);
#endif
up_read(&uts_sem);
if (copy_to_user(name, &tmp, sizeof(tmp)))
Expand Down

0 comments on commit e18f22b

Please sign in to comment.