-
Notifications
You must be signed in to change notification settings - Fork 336
RFC - 4.9 unwinder #659
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
RFC - 4.9 unwinder #659
Conversation
|
Thanks for looking at this. Something just occurred to me that somehow eluded me before. Instead of using the x86-specific interfaces, how about we use the arch-independent save_stack_trace_tsk(). That interface is stable and also easy to use, and can be used for old and new kernels alike. |
148b81e to
479df05
Compare
|
Whoops... I had only checked that v2, I modified for |
jpoimboe
left a comment
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, added one minor comment.
kmod/core/core.c
Outdated
| .skip = 0, | ||
| }; | ||
|
|
||
| save_stack_trace_tsk(t, &trace); |
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.
It would be good to report an error if there were more than 64 functions on the stack and the entries array filled up.
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.
Will do. BTW, I picked 64 since that was the value used in the proc stack interface. It could just as easily be a module parameter (default to 64) if you think it should be more flexible.
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.
I think a hard coded value is fine, as we make a loud warning when it's not big enough.
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.
Er, I meant to say as long as we make a loud warning. Having trouble with English this week!
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.
Got it, how about "kpatch: more than X trace entries!" with a stack dump of the ones we did get?
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.
Sounds good, and then it should also return an error and abort the patch.
ERROR: initramfs_data.o: 2 unsupported section change(s) initramfs_data.o: changed section .init.ramfs not selected for inclusion initramfs_data.o: changed section .init.ramfs.info not selected for inclusion /usr/local/libexec/kpatch/create-diff-object: unreconcilable difference cmdline.o: changed function: cmdline_proc_show ERROR: 1 error(s) encountered. Check /root/.kpatch/build.log for more details.
479df05 to
c503c66
Compare
|
v3 - rebased against master, added warnings when Tested the following kernel/configurations:
Each for the following scenarios: 0 - kpatch: builds 3 - MAX_STACK_TRACE_DEPTH=2 (for debug): builds and fails to load patch. dmesg x 5: I couldn't think of a better errno value for when we've exceeded MAX_STACK_TRACE_DEPTH, so I just used -EBUSY like the other cases. Any suggestions? |
kmod/core/core.c
Outdated
| }; | ||
| entries = kmalloc(MAX_STACK_TRACE_DEPTH * sizeof(*entries), GFP_KERNEL); | ||
| if (!entries) | ||
| return -ENOMEM; |
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.
I think sleeping isn't allowed in stop_machine(), so this should probably be allocated on the stack.
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.
Ah, good catch! I'll fix that up.
The dump_trace interface was deprecated in v4.9: instead of adding yet another kernel-specific code block to kpatch's stack safety checks, use save_stack_trace_tsk. It's relatively simple (no callbacks like dump_trace), arch-independent, and its interface is stable across kernel releases. Fixes: dynup#623.
c503c66 to
586feb4
Compare
|
v4
Tested: same kernel/config + tests as v3, this time without bogus |
|
👍 |
This is based on @flaming-toast 's 4.7-changes branch, so I don't know how well the github review interface will work, but here goes.
patch 1 - I don't know if this is a kernel config or v4.9 thing, but kpatch-build was complaining about
initramfs_data.oso just skipped the file so I could continue on.patch 2 - adds in v4.9+ support for the shiny new
unwind_{start,done,next_frame}interface. Much simpler than the deprecateddump_traceand callback mechanism! (Good work, @jpoimboe ) My modifications are pretty straightforward, I tested with a patch that changedn_tty_read, which an agetty process will always be sitting on... and verified the safety check detected and returned-EBUSY.Hope this is on the right track. If this is easier to review as a branch off master rather than 4.7-changes, let me know and I can respin.