-
Notifications
You must be signed in to change notification settings - Fork 8
/
sysfs.c
49 lines (39 loc) · 1.31 KB
/
sysfs.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright 2004-present Facebook. All Rights Reserved.
#include <linux/sysfs.h>
#include <linux/kobject.h>
#include <linux/module.h>
#include <linux/slab.h>
#include "hash.h"
#include "sysfs.h"
struct kobject *camb_kobj;
extern ssize_t syscall_addr_modified_show(struct kobject *obj,
struct attribute *attr,
char *buf);
extern ssize_t text_segment_hash_show(struct kobject *obj,
struct attribute *attr,
char *buf);
struct kobj_attribute attr_syscall_addr_modified =
__ATTR(syscall_addr_modified, 0444, syscall_addr_modified_show, NULL);
struct kobj_attribute attr_text_segment_hash =
__ATTR(text_segment_hash, 0444, text_segment_hash_show, NULL);
struct attribute *camb_attrs[] = {
&attr_text_segment_hash.attr,
&attr_syscall_addr_modified.attr,
NULL,
};
struct attribute_group attr_group = {
.attrs = camb_attrs
};
int expose_sysfs(void) {
int err = 0;
camb_kobj = kobject_create_and_add("camb", kernel_kobj);
if (camb_kobj) {
if ((err = sysfs_create_group(camb_kobj, &attr_group)) != 0) {
kobject_put(camb_kobj);
}
}
return err;
}
MODULE_LICENSE("GPL");
MODULE_AUTHOR("@unixist");
MODULE_DESCRIPTION("Detect kernel tampering");