-
Notifications
You must be signed in to change notification settings - Fork 2
Use kexec_load instead of kexec_file_load #8
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @kvaps, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the kexec loading mechanism to utilize the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request replaces the kexec_file_load syscall with the older kexec_load syscall to avoid kernel signature verification requirements. The changes involve reading the kernel and initramfs into memory instead of using file descriptors, and preparing memory segments for the kexec_load call. My review has identified a few issues. There is a critical risk of a panic when creating kexec segments, as the code doesn't handle cases where kernel or initramfs data might be empty. Additionally, a hardcoded syscall number should be replaced with the constant from the unix package for better maintainability. Overall, the change is in the right direction for the stated goal, but the identified issues should be addressed to ensure robustness.
| segments := []kexecSegment{ | ||
| // Kernel image (entire bzImage) | ||
| { | ||
| buf: uintptr(unsafe.Pointer(&kernelData[0])), |
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.
| }, | ||
| // Initramfs | ||
| { | ||
| buf: uintptr(unsafe.Pointer(&initrdData[0])), |
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.
This will cause a panic if initrdData is an empty slice. An empty initramfs is a valid scenario. The code should handle this by conditionally adding the initramfs segment only if len(initrdData) > 0. The current implementation needs to be refactored to build the segments slice dynamically to support this.
| cmdlinePtr, // cmdline | ||
| flags, // flags | ||
| 0, // unused | ||
| SYS_KEXEC_LOAD, |
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.
For better portability and readability, use the unix.SYS_KEXEC_LOAD constant from the golang.org/x/sys/unix package instead of a locally defined constant with a hardcoded value. This also allows you to remove the SYS_KEXEC_LOAD constant definition on line 197.
| SYS_KEXEC_LOAD, | |
| unix.SYS_KEXEC_LOAD, |
Signed-off-by: Andrei Kvapil kvapss@gmail.com