[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221108154846.11584119794413c7682280fc@linux-foundation.org>
Date: Tue, 8 Nov 2022 15:48:46 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: Stephen Brennan <stephen.s.brennan@...cle.com>
Cc: Baoquan He <bhe@...hat.com>, Vivek Goyal <vgoyal@...hat.com>,
kexec@...ts.infradead.org, linux-kernel@...r.kernel.org,
Dave Young <dyoung@...hat.com>
Subject: Re: [PATCH] vmcoreinfo: Warn if we exceed vmcoreinfo data size
On Thu, 27 Oct 2022 13:50:08 -0700 Stephen Brennan <stephen.s.brennan@...cle.com> wrote:
> Though vmcoreinfo is intended to be small, at just one page, useful
> information is still added to it, so we risk running out of space.
> Currently there is no runtime check to see whether the vmcoreinfo buffer
> has been exhausted. Add a warning for this case.
>
> Currently, my static checking tool[1] indicates that a good upper bound
> for vmcoreinfo size is currently 3415 bytes, but the best time to add
> warnings is before the risk becomes too high.
>
> ...
>
> --- a/kernel/crash_core.c
> +++ b/kernel/crash_core.c
> @@ -383,6 +383,9 @@ void vmcoreinfo_append_str(const char *fmt, ...)
> memcpy(&vmcoreinfo_data[vmcoreinfo_size], buf, r);
>
> vmcoreinfo_size += r;
> +
> + WARN_ONCE(vmcoreinfo_size == VMCOREINFO_BYTES,
> + "vmcoreinfo data exceeds allocated size, truncating");
> }
Seems that vmcoreinfo_append_str() will truncate (ie: corrupt) the
final entry when limiting the overall data size to VMCOREINFO_BYTES.
And that final entry will be missing any terminating \n or \0.
Is all this desirable, or should we be checking for (and warning about)
sufficient space _before_ appending this string?
Powered by blists - more mailing lists