ÿØÿà JFIF  ` ` ÿþš 403 WEBHELL REBORN
403 WEBHELL REBORN
Server : Apache
System : Linux cloud.heroica.com.br 4.18.0-553.36.1.el8_10.x86_64 #1 SMP Wed Jan 22 03:07:54 EST 2025 x86_64
User : farolpborg ( 1053)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /usr/src/file_protector-1.1-1505/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

Buat Folder Baru:
Buat File Baru:

Current File : //usr/src/file_protector-1.1-1505/compat.h
/**
@file
@brief    Support for legacy Linux kernel versions
@details  Copyright (c) 2018-2021 Acronis International GmbH
@author   Mikhail Krivtsov (mikhail.krivtsov@acronis.com)
@since    $Id: $
*/

#pragma once

#include <linux/cred.h>		// current_fsuid_fsgid
#include <linux/file.h>
#include <linux/fs.h>	  	// vfs_stat
#include <linux/mount.h>
#include <linux/stat.h>		// struct kstat
#include <linux/version.h>
#include <linux/namei.h>
#include <linux/mm.h>

// CentOS/RedHat kernel has many backports
// 'LINUX_VERSION_CODE' cannot be trusted on RHEL distros so only 'grep' is used for CentOS and CloudLinux
// For 'normal kernels', 'LINUX_VERSION_CODE' should be used
#ifndef RHEL_RELEASE_VERSION
// 'linux/sched/task.h' appeared in 'stable/v4.11'
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
#  ifdef HAVE_SCHED_TASK_H
#  undef HAVE_SCHED_TASK_H
#  endif
#  ifndef HAVE_SCHED_H
#  define HAVE_SCHED_H
#  endif
#else
#  ifndef HAVE_SCHED_TASK_H
#  define HAVE_SCHED_TASK_H
#  endif
#  ifdef HAVE_SCHED_H
#  undef HAVE_SCHED_H
#  endif
#endif

// 'get_fs_pwd()' appeared in 'stable/v2.6.36'
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
#  ifdef HAVE_GET_FS_ROOT
#  undef HAVE_GET_FS_ROOT
#  endif
#  ifdef HAVE_GET_FS_PWD
#  undef HAVE_GET_FS_PWD
#  endif
#  undef HAVE_GET_FS_PWD
#else
#  ifndef HAVE_GET_FS_ROOT
#  define HAVE_GET_FS_ROOT
#  endif
#  ifndef HAVE_GET_FS_PWD
#  define HAVE_GET_FS_PWD
#  endif
#endif

// Second arg of 'vfs_fstatat()' was made 'const' in 'stable/v2.6.36'
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
#  ifdef HAVE_VFS_FSTATAT_CONST
#  undef HAVE_VFS_FSTATAT_CONST
#  endif
#else
#  ifndef HAVE_VFS_FSTATAT_CONST
#  define HAVE_VFS_FSTATAT_CONST
#  endif
#endif

// 'get_task_exe_file()' appeared in 'stable/v4.8'
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
#  ifdef HAVE_GET_TASK_EXE
#  undef HAVE_GET_TASK_EXE
#  endif
#else
#  ifndef HAVE_GET_TASK_EXE
#  define HAVE_GET_TASK_EXE
#  endif
#endif

// 'data' arg was added to 'probe' callback in v.2.6.35
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
#  ifdef HAVE_TRACEPOINT_PROBE_REGISTER_DATA
#  undef HAVE_TRACEPOINT_PROBE_REGISTER_DATA
#  endif
#else
#  ifndef HAVE_TRACEPOINT_PROBE_REGISTER_DATA
#  define HAVE_TRACEPOINT_PROBE_REGISTER_DATA
#  endif
// registration interface was modified in 'stable/v3.15'
#  if LINUX_VERSION_CODE < KERNEL_VERSION(3, 15, 0)
#    ifdef HAVE_TRACEPOINT_PROBE_REGISTER_STRUCT
#    undef HAVE_TRACEPOINT_PROBE_REGISTER_STRUCT
#    endif
#  else
#    ifndef HAVE_TRACEPOINT_PROBE_REGISTER_STRUCT
#    define HAVE_TRACEPOINT_PROBE_REGISTER_STRUCT
#    endif
#  endif
#endif

// rbtree postorder iteration functions appeared in 'stable/v3.12'
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0)
#  ifdef HAVE_RB_FIRST_POSTORDER
#  undef HAVE_RB_FIRST_POSTORDER
#  endif
#  ifdef HAVE_RB_NEXT_POSTORDER
#  undef HAVE_RB_NEXT_POSTORDER
#  endif
#else
#  ifndef HAVE_RB_FIRST_POSTORDER
#  define HAVE_RB_FIRST_POSTORDER
#  endif
#  ifndef HAVE_RB_NEXT_POSTORDER
#  define HAVE_RB_NEXT_POSTORDER
#  endif
#endif

// kuid/kgid is used instead uid/gid since 'stable/v3.5.0'
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 5, 0)
#  ifdef HAVE_STRUCT_CRED_KUID
#  undef HAVE_STRUCT_CRED_KUID
#  endif
#else
#  ifndef HAVE_STRUCT_CRED_KUID
#  define HAVE_STRUCT_CRED_KUID
#  endif
#endif
#endif

#ifdef HAVE_SCHED_H
#include <linux/sched.h>	// put_task_struct()
#endif
#ifdef HAVE_SCHED_TASK_H
#include <linux/sched/task.h>	// put_task_struct()
#endif

#ifndef HAVE_GET_FS_ROOT
#include <linux/fs_struct.h>
#include <linux/path.h>

static inline void get_fs_root(struct fs_struct *fs, struct path *root)
{
	read_lock(&fs->lock);
	*root = fs->root;
	path_get(root);
	read_unlock(&fs->lock);
}
#endif

#ifndef HAVE_GET_FS_PWD
#include <linux/fs_struct.h>
#include <linux/path.h>

static inline void get_fs_pwd(struct fs_struct *fs, struct path *pwd)
{
	read_lock(&fs->lock);
	*pwd = fs->pwd;
	path_get(pwd);
	read_unlock(&fs->lock);
}
#endif

static inline struct inode *file_inode_compat(const struct file *f)
{
	return f->f_path.dentry->d_inode;
}

#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)
#define GET_TASK_EXE_NOT_EXPORTED
#endif

#if !defined(HAVE_GET_TASK_EXE) || defined(GET_TASK_EXE_NOT_EXPORTED)
struct file *get_task_exe_file_impl(struct task_struct *task);
#endif

#ifndef HAVE_PATH_EQUAL
static inline int path_equal(const struct path *path1, const struct path *path2)
{
	return path1->mnt == path2->mnt && path1->dentry == path2->dentry;
}
#endif

#define TRACE_CB_NAME(name) trace_##name##_cb
#ifndef HAVE_TRACEPOINT_PROBE_REGISTER_DATA
	#define REGISTER_TRACE(name, probe) register_trace_##name(probe)
	#define UNREGISTER_TRACE(name, probe) unregister_trace_##name(probe)
	#define TRACE_CB_PROTO(name, proto) void TRACE_CB_NAME(name)(PARAMS(proto))
#else
	#ifndef HAVE_TRACEPOINT_PROBE_REGISTER_STRUCT
		#define REGISTER_TRACE(name, probe) register_trace_##name(probe, NULL)
		#define UNREGISTER_TRACE(name, probe) unregister_trace_##name(probe, NULL)
	#else
		int tracepoint_probe_register_compat(const char *name, void *probe, void *data);
		#define REGISTER_TRACE(name, probe) \
				tracepoint_probe_register_compat(#name, probe, NULL)
		int tracepoint_probe_unregister_compat(const char *name, void *probe, void *data);
		#define UNREGISTER_TRACE(name, probe) \
				tracepoint_probe_unregister_compat(#name, probe, NULL)
	#endif

	#define TRACE_CB_PROTO(name, proto) \
			void TRACE_CB_NAME(name)(void *cb_data, PARAMS(proto))
#endif

#ifndef HAVE_RB_FIRST_POSTORDER
#include <linux/rbtree.h>
extern struct rb_node *rb_first_postorder(const struct rb_root *);
#endif

#ifndef HAVE_RB_NEXT_POSTORDER
#include <linux/rbtree.h>
extern struct rb_node *rb_next_postorder(const struct rb_node *);
#endif

static inline void get_current_fsuid_fsgid_compat(uid_t* fsuid, gid_t* fsgid)
{
#ifndef HAVE_STRUCT_CRED_KUID
	current_fsuid_fsgid(fsuid, fsgid);
#else
	kuid_t fskuid;
	kgid_t fskgid;
	current_fsuid_fsgid(&fskuid, &fskgid);
	*fsuid = fskuid.val;
	*fsgid = fskgid.val;
#endif
}

static inline struct file* dentry_open_compat(const struct path* path, int flags) {
#ifndef HAVE_PATH_IN_DENTRY_OPEN
	return dentry_open(dget(path->dentry), mntget(path->mnt), flags, current_cred());
#else
	return dentry_open(path, flags, current_cred());
#endif
}

static inline int get_unused_fd_compat(void)
{
#ifdef HAVE_UNUSED_FD_FLAGS
	return get_unused_fd_flags(0);
#else
	return get_unused_fd();
#endif
}


/*
    2.6.32-71.el6

        unsigned int module_refcount(struct module *mod)

    linux-3.10.0-123.el7

        unsigned long module_refcount(struct module *mod)
*/
#define module_refcount_compat(m) ((unsigned long)module_refcount(m))

static inline int vfs_getattr_compat(struct path *path, struct kstat *stat)
{
#if defined(STATX_BASIC_STATS)
	return vfs_getattr(path, stat, STATX_BASIC_STATS, 0);
#elif defined(HAVE_PATH_IN_VFS_GETATTR)
	return vfs_getattr(path, stat);
#else
	return vfs_getattr(path->mnt, path->dentry, stat);
#endif
}

// copy from 2.6.31
static inline int vfs_fstatat_impl(int dfd, const char __user *filename, struct kstat *stat, int flag)
{
	struct path path;
	int error = -EINVAL;
	int lookup_flags = 0;

	if (!(flag & AT_SYMLINK_NOFOLLOW))
		lookup_flags |= LOOKUP_FOLLOW;

	error = user_path_at(dfd, filename, lookup_flags, &path);
	if (error)
		goto out;

	error = vfs_getattr_compat(&path, stat);

	path_put(&path);
out:
	return error;
}

static inline struct file *get_task_exe_file_compat(struct task_struct *task)
{
#if !defined(HAVE_GET_TASK_EXE) || defined(GET_TASK_EXE_NOT_EXPORTED)
	return get_task_exe_file_impl(task);
#else
	return get_task_exe_file(task);
#endif
}

int get_kallsyms_on_each_symbol(void);

unsigned long compat_kallsyms_lookup_name(const char *name);

Anon7 - 2021