kexec.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: 张子康 <zhangzikang1992@126.com>
Cc: kexec@lists.infradead.org, zhangzikang <zhangzikang@kylinos.cn>
Subject: Re: [PATCH] kexec: fix stack buffer overflow in update_purgatory()
Date: Tue, 10 Nov 2026 12:55:08 +0000	[thread overview]
Message-ID: <20261110125508.GA369680@horms.kernel.org> (raw)
In-Reply-To: <61359f90.7bfb.1a1c57577b6.Coremail.zhangzikang1992@126.com>

On Tue, Nov 10, 2026 at 08:36:12PM +0800, 张子康  wrote:
> 
> Hi Simon,
> 
> Thanks for your review and for taking the time to share your suggestion — I really appreciate the detailed feedback.
> 
> I did consider adding a die when the 16-segment limit is reached in add_segment_phys_virt, but after looking at the overall design I think the current approach of printing a warning without terminating may be the reasonable one, for two reasons:
> 
> 1. KEXEC_MAX_SEGMENTS in kexec-tools is only an expectation on the userspace tool side. Printing a warning and then letting the kernel perform the final validation and return an error keeps the flow complete. If we changed this to die, kexec-tools would exit before even issuing the system call. Although the outcome is failure either way, what the user sees would be the tool giving up on its own, rather than the kernel explicitly reporting "invalid argument" (EINVAL).
> 
> 2. The value of KEXEC_MAX_SEGMENTS has historically been increased from 8 to 16 in kexec-tools, with KEXEC_SEGMENT_MAX on the kernel side adjusted in tandem. This limit is inherently arbitrary, so in update_purgatory merely avoiding out-of-bounds writes and emitting a warning that the region limit has been reached — and then deferring final validation to the kernel — is more flexible than a hard termination, and can accommodate the actual limits of different kernel versions.
> 
> Please let me know what you think.

Hi Zikang,

Thanks for the response, likewise much appreciated.

I understand what you are saying about the desirability of the Kernel
enforcing the kernel limit. But to my mind we the kexec-tools limit is also
a limit, even if it has the same value as the kernel limit.  And it is
appropriate for kexec-tools to enforce the limit it has.

I think that if kexec-tools used dynamic buffers, and thus had no limit,
then we could happily leave it up to the kernel to enforce what would then
be the only limit. But I also don't think it's worth moving kexec-tools to
use dynamic buffers to achieve this.

So I do think, given the implementation of kexec-tools, that the approach I
suggested is a good way to go.


      reply	other threads:[~2026-11-10 12:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30  3:09 [PATCH] kexec: fix stack buffer overflow in update_purgatory() zhangzikang1992
2026-11-10 10:58 ` Simon Horman
2026-11-10 11:21   ` Simon Horman
2026-11-10 12:36     ` 张子康 
2026-11-10 12:55       ` Simon Horman [this message]

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=20261110125508.GA369680@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=kexec@lists.infradead.org \
    --cc=zhangzikang1992@126.com \
    --cc=zhangzikang@kylinos.cn \
    /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;
as well as URLs for NNTP newsgroup(s).