All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Yue Hu <huyue2@yulong.com>
Cc: Anton Vorontsov <anton@enomsg.org>,
	Colin Cross <ccross@android.com>, Tony Luck <tony.luck@intel.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] pstore/ram: Add kmsg hlen null check to ramoops_pstore_write
Date: Tue, 12 Feb 2019 12:27:06 -0800	[thread overview]
Message-ID: <CAGXu5j+PjfQ9dm6PbfL=K+0wa2pUSqPB2J=GoGBD60XX7-ywJA@mail.gmail.com> (raw)
In-Reply-To: <5c53f6d3.1c69fb81.a1e8c.eb7aSMTPIN_ADDED_BROKEN@mx.google.com>

On Thu, Jan 31, 2019 at 11:35 PM Yue Hu <huyue2@yulong.com> wrote:
>
> From 9385613f546a4d0b2497dc2ed22cb9475eb3621c Mon Sep 17 00:00:00 2001
> From: Yue Hu <huyue2@yulong.com>
> Date: Fri, 1 Feb 2019 11:27:32 +0800
> Subject: [PATCH] pstore/ram: Add kmsg hlen null check to ramoops_pstore_write
>
> If null hdr happened in ramoops_write_kmsg_hdr(), that means
> we cannot get the dmesg record since it will be treated as
> invalid header in ramoops_pstore_read(). So we should not
> execute the following code but return the error.
>
> Signed-off-by: Yue Hu <huyue2@yulong.com>
> ---
>  fs/pstore/ram.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
> index 7e188f6..4a06675 100644
> --- a/fs/pstore/ram.c
> +++ b/fs/pstore/ram.c
> @@ -467,6 +467,9 @@ static int notrace ramoops_pstore_write(struct pstore_record *record)
>
>         /* Build header and append record contents. */
>         hlen = ramoops_write_kmsg_hdr(prz, record);
> +       if (!hlen)
> +               return -EINVAL;
> +
>         size = record->size;
>         if (size + hlen > prz->buffer_size)
>                 size = prz->buffer_size - hlen;

Yeah, this seems right. If we don't generate a header, then
ramoops_pstore_read() will ignore anything written there. This
probably means we need to refactor this to avoid memory allocation
during the write. I'll apply this and do some follow-up changes.

Thanks!

-- 
Kees Cook

           reply	other threads:[~2019-02-12 20:27 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <5c53f6d3.1c69fb81.a1e8c.eb7aSMTPIN_ADDED_BROKEN@mx.google.com>]

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='CAGXu5j+PjfQ9dm6PbfL=K+0wa2pUSqPB2J=GoGBD60XX7-ywJA@mail.gmail.com' \
    --to=keescook@chromium.org \
    --cc=anton@enomsg.org \
    --cc=ccross@android.com \
    --cc=huyue2@yulong.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tony.luck@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.