-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kmod: maintain syscall metadata sections in kpatch syscall macros #1376
Conversation
e319690
to
a3a00e1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good other than the trailing semicolon
kmod/patch/kpatch-syscall.h
Outdated
static struct trace_event_call __used \ | ||
__section("_ftrace_events") \ | ||
*__event_enter_##sname = NULL; \ | ||
KPATCH_IGNORE_SECTION("_ftrace_events"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove trailing semicolon
The KPATCH_SYSCALL_DEFINEn macros in kpatch-syscall.h do not provide the same syscall metadata (saved in the __syscalls_metadata and _ftrace_events ELF sections) as the kernel. These same macros also instruct kpatch-build to ignore changes to these sections. This works fine as long as there are other unmodified syscalls present in the object file. However, if not, the kpatch syscall macros may result in either metadata ELF sections not appearing in the patched object file. The create-diff-object program expects to encounter any ELF section that has been marked by KPATCH_IGNORE_SECTION in the patched object file. To avoid this limitation, create dummy __syscalls_metadata and _ftrace_events entries for the kpatch-modified syscall. The specific values shouldn't matter since their sections will still be marked with KPATCH_IGNORE_SECTION and now their presence will be guarenteed for create-diff-object. Closes: dynup#1375 ("kpatch-build error when modifying an object file's only syscall") Signed-off-by: Joe Lawrence <[email protected]>
a3a00e1
to
906bb8f
Compare
A few follow ups:
|
I think either way is fine.
Hm, how does it get passed a NULL sec_patched pointer? |
|
Your version of the code seems to be missing the fix for that: 9fac261 ? |
Ah yes, good find, my older kpatch-build was indeed missing that commit (which fixes the problem). Anything more to tweak for this PR? |
The KPATCH_SYSCALL_DEFINEn macros in kpatch-syscall.h do not provide the same syscall metadata (saved in the __syscalls_metadata and _ftrace_events ELF sections) as the kernel. These same macros also instruct kpatch-build to ignore changes to these sections. This works fine as long as there are other unmodified syscalls present in the object file. However, if not, the kpatch syscall macros may result in either metadata ELF sections not appearing in the patched object file. The create-diff-object program expects to encounter any ELF section that has been marked by KPATCH_IGNORE_SECTION in the patched object file.
To avoid this limitation, create dummy __syscalls_metadata and _ftrace_events entries for the kpatch-modified syscall. The specific values shouldn't matter since their sections will still be marked with KPATCH_IGNORE_SECTION and now their presence will be guarenteed for create-diff-object.
Closes: #1375 ("kpatch-build error when modifying an object file's only syscall")