[PATCH] kexec: remove the 2GB size limit on initrd file

Bhupesh Sharma bhsharma at redhat.com
Wed Sep 2 14:17:51 EDT 2020


Hi Robi,

On Wed, Sep 2, 2020 at 1:05 PM Robi Buranyi <rburanyi at google.com> wrote:
>
> Enable loading initrd files exceeding the INT_MAX size. Remove the
> INT_MAX limit completely, and let any initrd load if it fits in the
> memory.
>
> Signed-off-by: Robi Buranyi <rburanyi at google.com>
> ---
>  kernel/kexec_file.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
> index ca40bef75a61..659a9d165198 100644
> --- a/kernel/kexec_file.c
> +++ b/kernel/kexec_file.c
> @@ -222,7 +222,7 @@ kimage_file_prepare_segments(struct kimage *image, int kernel_fd, int initrd_fd,
>         loff_t size;
>
>         ret = kernel_read_file_from_fd(kernel_fd, &image->kernel_buf,
> -                                      &size, INT_MAX, READING_KEXEC_IMAGE);
> +                                      &size, 0, READING_KEXEC_IMAGE);
>         if (ret)
>                 return ret;
>         image->kernel_buf_len = size;
> @@ -242,7 +242,7 @@ kimage_file_prepare_segments(struct kimage *image, int kernel_fd, int initrd_fd,
>         /* It is possible that there no initramfs is being loaded */
>         if (!(flags & KEXEC_FILE_NO_INITRAMFS)) {
>                 ret = kernel_read_file_from_fd(initrd_fd, &image->initrd_buf,
> -                                              &size, INT_MAX,
> +                                              &size, 0,
>                                                READING_KEXEC_INITRAMFS);
>                 if (ret)
>                         goto out;
> --
> 2.28.0.402.g5ffc5be6b7-goog

Can you share some background about this fix? For example why is it
needed or what is failing at your end?
I think a 2GB initramfs is a good enough size to accommodate while
loading it via kexec_file_load(). Eventually the initramfs to be
loaded is passed via user-space as a command line argument to the
kexec_file_load() syscall, so we should be careful about the file
sizes we might be loading here.

I am just trying to understand what initramfs size limits you are
working with from a kexec_file_load() p-o-v.

Thanks,
Bhupesh




More information about the kexec mailing list