kernel: fix memory leaks and x86_64 args

This commit is contained in:
weishu
2022-12-14 16:26:43 +07:00
parent 2934ec1718
commit c6300ccf94
2 changed files with 8 additions and 3 deletions

View File

@@ -4,7 +4,6 @@
#if defined(__aarch64__)
#define __PT_REGS_CAST(x) ((const struct user_pt_regs *)(x))
#define __PT_PARM1_REG regs[0]
#define __PT_PARM2_REG regs[1]
#define __PT_PARM3_REG regs[2]

View File

@@ -54,9 +54,11 @@ static int faccessat_handler_pre(struct kprobe *p, struct pt_regs *regs) {
}
if (!memcmp(filename->name, su, sizeof(su))) {
pr_info("faccessat su->sh!\n");
regs->regs[1] = sh_user_path();
PT_REGS_PARM2(regs) = sh_user_path();
}
putname(filename);
return 0;
}
@@ -76,9 +78,11 @@ static int newfstatat_handler_pre(struct kprobe *p, struct pt_regs *regs) {
}
if (!memcmp(filename->name, su, sizeof(su))) {
pr_info("newfstatat su->sh!\n");
regs->regs[1] = sh_user_path();
PT_REGS_PARM2(regs) = sh_user_path();
}
putname(filename);
return 0;
}
@@ -104,6 +108,8 @@ static int execve_handler_pre(struct kprobe *p, struct pt_regs *regs) {
escape_to_root(false);
}
putname(filename);
return 0;
}