public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Baoquan He <bhe@redhat.com>
To: Qiang Ma <maqianga@uniontech.com>
Cc: akpm@linux-foundation.org, kexec@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 4/4] kexec_file: Fix the issue of mismatch between loop variable types
Date: Wed, 5 Nov 2025 14:56:43 +0800	[thread overview]
Message-ID: <aQr1K/+I91RhVGuo@MiWiFi-R3L-srv> (raw)
In-Reply-To: <0C92443D3E2100AF+c669d240-1ee8-4897-a30d-3efefe161085@uniontech.com>

On 11/05/25 at 11:47am, Qiang Ma wrote:
> 
> 在 2025/11/5 11:05, Baoquan He 写道:
> > On 11/03/25 at 02:34pm, Qiang Ma wrote:
> > > The type of the struct kimage member variable nr_segments is unsigned long.
> > > Correct the loop variable i and the print format specifier type.
> > I can't see what's meaningful with this change. nr_segments is unsigned
> > long, but it's the range 'i' will loop. If so, we need change all for
> > loop of the int iterator.
> If image->nr_segments is large enough, 'i' overflow causes an infinite loop.

Please check kexec_add_buffer(), there's checking for the value which
upper limit is restricted to 16.

        if (kbuf->image->nr_segments >= KEXEC_SEGMENT_MAX)
                return -EINVAL;

> > > Signed-off-by: Qiang Ma <maqianga@uniontech.com>
> > > ---
> > >   kernel/kexec_file.c | 5 +++--
> > >   1 file changed, 3 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
> > > index 4a24aadbad02..7afdaa0efc50 100644
> > > --- a/kernel/kexec_file.c
> > > +++ b/kernel/kexec_file.c
> > > @@ -366,7 +366,8 @@ SYSCALL_DEFINE5(kexec_file_load, int, kernel_fd, int, initrd_fd,
> > >   	int image_type = (flags & KEXEC_FILE_ON_CRASH) ?
> > >   			 KEXEC_TYPE_CRASH : KEXEC_TYPE_DEFAULT;
> > >   	struct kimage **dest_image, *image;
> > > -	int ret = 0, i;
> > > +	int ret = 0;
> > > +	unsigned long i;
> > >   	/* We only trust the superuser with rebooting the system. */
> > >   	if (!kexec_load_permitted(image_type))
> > > @@ -432,7 +433,7 @@ SYSCALL_DEFINE5(kexec_file_load, int, kernel_fd, int, initrd_fd,
> > >   		struct kexec_segment *ksegment;
> > >   		ksegment = &image->segment[i];
> > > -		kexec_dprintk("segment[%d]: buf=0x%p bufsz=0x%zx mem=0x%lx memsz=0x%zx\n",
> > > +		kexec_dprintk("segment[%lu]: buf=0x%p bufsz=0x%zx mem=0x%lx memsz=0x%zx\n",
> > >   			      i, ksegment->buf, ksegment->bufsz, ksegment->mem,
> > >   			      ksegment->memsz);
> > > -- 
> > > 2.20.1
> > > 
> > 
> 


  reply	other threads:[~2025-11-05  6:56 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-03  6:34 [PATCH v2 0/4] kexec: print out debugging message if required for kexec_load Qiang Ma
2025-11-03  6:34 ` [PATCH v2 1/4] kexec: Fix uninitialized struct kimage *image pointer Qiang Ma
2025-11-03  6:34 ` [PATCH v2 2/4] kexec: add kexec_core flag to control debug printing Qiang Ma
2025-11-05  3:09   ` Baoquan He
2025-11-05  4:32     ` Qiang Ma
2025-11-03  6:34 ` [PATCH v2 3/4] kexec: print out debugging message if required for kexec_load Qiang Ma
2025-11-05  3:01   ` Baoquan He
2025-11-05  3:41     ` Qiang Ma
2025-11-05  7:53       ` Baoquan He
2025-11-05  8:35         ` Qiang Ma
2025-11-05  8:55           ` Baoquan He
2025-11-05 11:28             ` Qiang Ma
2025-11-05 13:01               ` Baoquan He
2025-11-05 15:05                 ` Qiang Ma
2025-11-05  8:48         ` Qiang Ma
2025-11-03  6:34 ` [PATCH v2 4/4] kexec_file: Fix the issue of mismatch between loop variable types Qiang Ma
2025-11-05  3:05   ` Baoquan He
2025-11-05  3:47     ` Qiang Ma
2025-11-05  6:56       ` Baoquan He [this message]
2025-11-05  7:06         ` Qiang Ma
     [not found]     ` <c669d240-1ee8-4897-a30d-3efefe161085@uniontech.com>
2025-11-05  4:31       ` Qiang Ma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aQr1K/+I91RhVGuo@MiWiFi-R3L-srv \
    --to=bhe@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maqianga@uniontech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox