-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Make read_version_from_raw() more robust #44
base: master
Are you sure you want to change the base?
Make read_version_from_raw() more robust #44
Conversation
Ignore the "parsed" Linux kernel version information if there are non-ASCII at the beginning of the selected buffer. Fixes projg2#27. Signed-off-by: Florian Schmaus <[email protected]>
c5824c7
to
f3201f5
Compare
I suppose this would work most of the time, though I would prefer to know why some files don't have the version there. I suspect you may still accidentally grab some random string as version. |
Likely because they are not a Linux kernel. As I wrote in #27 (comment) that happens when eclean-kernel looks at an initramfs. For example,
|
Hmm, the logic got a bit messy with that "raw" image support. Previously the version reading logic did also serve the purpose of recognizing valid image formats (bzImage, EFI). The "raw" reader just does the version string search without actually attempting to verify the file format. I suppose the correct approach would be to add some kind of minimal header verification there. CC @Jannik2099, you've added "support for non-bzImage kernels". Do you think we could narrow it down to specific image formats, with explicit magic checks? |
hmm, do the raw, decompressed kernel images share some magic? Are they guaranteed to be ELF files on all arches? |
I hoped you'd have some idea. |
CC @AndrewAmmerlaan too. |
No, the |
I'm not sure I understand the original issue this is fixing, what non-ASCII characters are there and how did they get there? |
tl;dr: The match logic employed by The |
@Flowdalic, btw doesn't it incorrectly recognize your initramfs as kernel then? |
That is correct. |
@AndrewAmmerlaan, the problem is that the original logic combined getting internal version with checking file magic for kernel. However, as we added support for "raw" kernels, we've ended up looking for strings without any extra magic verification, so we end up treating any file containing My idea is that we ought to require some kind of magic for "raw" kernels. |
That would be ideal, if feasible. In addition (or in the meantime), can we get this PR merged to make things more robust? |
Then how about tacking on something like this, to make files with invalid magic be percieved as invalid kernels in the caller?
Seems to work for me at least, but I've not tested it everywhere available to me. Will need some tests to have magic added to their test kernel files, too, I think. |
I am still running into this. Could we please get a fix into eclean-kernel? If ajakk's suggestion of using |
tried your changed file.py and it totally breaks the entire program with |
Ignore the "parsed" Linux kernel version information if there are non-ASCII at the beginning of the selected buffer.
Fixes #27.