[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CAGXu5j+Oro9nchbayNXCpnebqZJbf05Wf5W1OyuFc7D_R2MimQ@mail.gmail.com>
Date: Tue, 12 Feb 2019 12:07:34 -0800
From: Kees Cook <keescook@...omium.org>
To: Yue Hu <huyue2@...ong.com>
Cc: Anton Vorontsov <anton@...msg.org>,
Colin Cross <ccross@...roid.com>,
Tony Luck <tony.luck@...el.com>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] pstore: Avoid to write records with null size
On Thu, Jan 31, 2019 at 6:26 PM Yue Hu <huyue2@...ong.com> wrote:
>
> From 57cb7141b227b7f75a6e4afb8319f803510cc07f Mon Sep 17 00:00:00 2001
> From: Yue Hu <huyue2@...ong.com>
> Date: Thu, 31 Jan 2019 18:12:46 +0800
> Subject: [PATCH] pstore: Avoid to write records with null size
>
> Sometimes pstore_console_write() will write record with null size
> to persistent ram zone, that is unnecessary. It will only increase
> resource consumtion. ramoops_write_kmsg_hdr() has same logic if
> null hdr happened. So let's avoid those cases.
>
> Signed-off-by: Yue Hu <huyue2@...ong.com>
> ---
> fs/pstore/platform.c | 3 +++
> fs/pstore/ram.c | 6 ++++--
> 2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
> index 7486e48..5e9b817 100644
> --- a/fs/pstore/platform.c
> +++ b/fs/pstore/platform.c
> @@ -504,6 +504,9 @@ static void pstore_console_write(struct console *con, const char *s, unsigned c)
> {
> struct pstore_record record;
>
> + if (!c)
> + return;
> +
> pstore_record_init(&record, psinfo);
> record.type = PSTORE_TYPE_CONSOLE;
>
> diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
> index 0bb086b..7e188f6 100644
> --- a/fs/pstore/ram.c
> +++ b/fs/pstore/ram.c
> @@ -364,8 +364,10 @@ static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz,
> (time64_t)record->time.tv_sec,
> record->time.tv_nsec / 1000,
> record->compressed ? 'C' : 'D');
> - WARN_ON_ONCE(!hdr);
> - len = hdr ? strlen(hdr) : 0;
> + if (WARN_ON_ONCE(!hdr))
> + return 0;
> +
> + len = strlen(hdr);
> persistent_ram_write(prz, hdr, len);
> kfree(hdr);
Applied, thanks!
--
Kees Cook
Powered by blists - more mailing lists