diff options
author | Eric Biggers <ebiggers3@gmail.com> | 2012-06-05 19:46:07 -0400 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2012-06-13 10:33:08 +0900 |
commit | 0e4946bc3009e7b9ce6f9d792077eddd7e40cc14 (patch) | |
tree | 3f1a8b1e9846372fc1e0905b873fa6fec44964a4 /kexec | |
parent | d40badaa2553c44d0585df335ad7e1c465f8ced1 (diff) |
Load bzImages smaller than 32 KiB
Allow bzImages smaller than 32KiB to be kexec'ed.
The current code will fail to load a bzImage smaller than 32768 bytes (sizeof
struct x86_linux_header), but the 'memdisk' program that comes with syslinux is
only about 26 KiB. This patch changes the minimum size to 1024 bytes (2
sectors), which appears to be the limit that syslinux enforces.
Removed the "tail" field of struct x86_linux_header because it doesn't seem to
actually be used (is there a reason for it?).
Also, note that bzImage_probe() was incorrectly using `sizeof (header)', even
though header is a pointer.
Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec')
-rw-r--r-- | kexec/arch/i386/kexec-bzImage.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/kexec/arch/i386/kexec-bzImage.c b/kexec/arch/i386/kexec-bzImage.c index 54c4427..6998587 100644 --- a/kexec/arch/i386/kexec-bzImage.c +++ b/kexec/arch/i386/kexec-bzImage.c @@ -44,7 +44,10 @@ static const int probe_debug = 0; int bzImage_probe(const char *buf, off_t len) { const struct x86_linux_header *header; - if ((uintmax_t)len < (uintmax_t)sizeof(header)) { + if ((uintmax_t)len < (uintmax_t)(2 * 512)) { + if (probe_debug) { + fprintf(stderr, "File is too short to be a bzImage!\n"); + } return -1; } header = (const struct x86_linux_header *)buf; @@ -118,7 +121,7 @@ int do_bzImage_load(struct kexec_info *info, /* * Find out about the file I am about to load. */ - if ((uintmax_t)kernel_len < (uintmax_t)sizeof(setup_header)) { + if ((uintmax_t)kernel_len < (uintmax_t)(2 * 512)) { return -1; } memcpy(&setup_header, kernel, sizeof(setup_header)); |