lkml.org 
[lkml]   [2019]   [Feb]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] pstore/ram: Add kmsg hlen null check to ramoops_pstore_write
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

\
 
 \ /
  Last update: 2019-02-12 21:28    [W:0.049 / U:0.476 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site