lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CAGXu5j+PjfQ9dm6PbfL=K+0wa2pUSqPB2J=GoGBD60XX7-ywJA@mail.gmail.com>
Date:   Tue, 12 Feb 2019 12:27:06 -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/ram: Add kmsg hlen null check to ramoops_pstore_write

On Thu, Jan 31, 2019 at 11:35 PM Yue Hu <huyue2@...ong.com> wrote:
>
> From 9385613f546a4d0b2497dc2ed22cb9475eb3621c Mon Sep 17 00:00:00 2001
> From: Yue Hu <huyue2@...ong.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@...ong.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ