Skip to content

Commit 6973941

Browse files
fix(tp/syscalls): detach handle_getdents_patch on sys_exit_getdents64 (#176)
确保 handle_getdents_patch 仅通过尾调用执行。 移除在 sys_exit_getdents64 上的 attach,避免非尾调用路径被意外触发。 Signed-off-by: zyj <zhongyinjiebit@sina.com> Co-authored-by: zyj <zhongyinjiebit@sina.com>
1 parent 1a2744f commit 6973941

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/24-hide/pidhide.bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ int handle_getdents_exit(struct trace_event_raw_sys_exit *ctx)
174174
return 0;
175175
}
176176

177-
SEC("tp/syscalls/sys_exit_getdents64")
177+
SEC("tp/unused")
178178
int handle_getdents_patch(struct trace_event_raw_sys_exit *ctx)
179179
{
180180
// Only patch if we've already checked and found our pid's folder to hide

src/24-hide/pidhide.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ int main(int argc, char **argv)
180180
goto cleanup;
181181
}
182182

183+
// 禁用 patch 程序的自动 attach,因为它只能通过尾调用执行
184+
bpf_program__set_autoattach(skel->progs.handle_getdents_patch, false);
185+
183186
// Setup Maps for tail calls
184187
int index = PROG_01;
185188
int prog_fd = bpf_program__fd(skel->progs.handle_getdents_exit);

0 commit comments

Comments
 (0)