EpiRootkit
By STDBOOL
Loading...
Searching...
No Matches
forbid_api.h File Reference
#include <linux/dcache.h>
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/limits.h>
#include <linux/module.h>
#include <linux/namei.h>
#include <linux/slab.h>
#include <linux/types.h>
Include dependency graph for forbid_api.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int forbid_init (void)
 
void forbid_exit (void)
 
int forbid_file (const char *path)
 
int unforbid_file (const char *path)
 
int forbid_contains (const char __user *u_path)
 
int forbid_contains_str (const char *k_path)
 
int forbid_list_get (char *buf, size_t buf_size)
 

Function Documentation

◆ forbid_contains()

int forbid_contains ( const char __user *  u_path)

Definition at line 81 of file forbid_api.c.

81 {
82 char *buf;
83 char *full;
84 int blocked = 0;
85
86 if (!u_path)
87 return 0;
88
89 buf = kmalloc(PATH_MAX, GFP_KERNEL);
90 if (!buf)
91 return 0;
92
93 full = get_abs_path(u_path, buf, PATH_MAX);
94 if (full) {
95 blocked = ulist_contains(&forbid_list, full);
96 }
97
98 kfree(buf);
99 return blocked;
100}
static char * get_abs_path(const char __user *u_path, char *buf, int buflen)
Definition forbid_api.c:65
struct ulist forbid_list
Definition forbid_api.c:6
int ulist_contains(struct ulist *ul, const char *value)
Definition ulist.c:258

◆ forbid_contains_str()

int forbid_contains_str ( const char *  k_path)

Definition at line 102 of file forbid_api.c.

102 {
103 return ulist_contains(&forbid_list, k_path);
104}

◆ forbid_exit()

void forbid_exit ( void  )

Definition at line 19 of file forbid_api.c.

19 {
22}
void ulist_clear(struct ulist *ul)
Definition ulist.c:39
int ulist_save(struct ulist *ul)
Definition ulist.c:169

◆ forbid_file()

int forbid_file ( const char *  path)

Definition at line 24 of file forbid_api.c.

24 {
25 int ret;
26 char modpath[256];
27
28 if (strcmp(path, "/") == 0)
29 return -EINVAL;
30
31 if (strlen(path) >= sizeof(modpath))
32 return -ENAMETOOLONG;
33 strscpy(modpath, path, sizeof(modpath));
34
35 size_t len = strlen(modpath);
36 if (len > 1 && modpath[len - 1] == '/') {
37 modpath[len - 1] = '\0';
38 }
39
40 ret = ulist_add(&forbid_list, modpath, 0, NULL);
41 if (ret < 0)
42 return ret;
43
44 ret = ulist_save(&forbid_list);
45 if (ret < 0)
46 return ret;
47
48 return SUCCESS;
49}
#define SUCCESS
Definition config.h:5
int ulist_add(struct ulist *ul, const char *value, u32 flags, const char *payload)
Definition ulist.c:208

◆ forbid_init()

int forbid_init ( void  )

Definition at line 8 of file forbid_api.c.

8 {
9 int ret;
10
12 ret = ulist_load(&forbid_list);
13 if (ret < 0)
14 return ret;
15
16 return SUCCESS;
17}
#define FORBID_CFG_FILE
Definition config.h:62
int ulist_load(struct ulist *ul)
Definition ulist.c:58
static void ulist_init(struct ulist *ul, const char *fname)
Definition ulist.h:21

◆ forbid_list_get()

int forbid_list_get ( char *  buf,
size_t  buf_size 
)

Definition at line 106 of file forbid_api.c.

106 {
107 return ulist_list(&forbid_list, buf, buf_size);
108}
int ulist_list(struct ulist *ul, char *buf, size_t buf_size)
Definition ulist.c:282

◆ unforbid_file()

int unforbid_file ( const char *  path)

Definition at line 51 of file forbid_api.c.

51 {
52 int ret;
53
54 ret = ulist_remove(&forbid_list, path);
55 if (ret < 0)
56 return ret;
57
58 ret = ulist_save(&forbid_list);
59 if (ret < 0)
60 return ret;
61
62 return SUCCESS;
63}
int ulist_remove(struct ulist *ul, const char *value)
Definition ulist.c:236