public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: Greg Pearson <greg.pearson@hp.com>
Cc: akpm@linux-foundation.org, d.hatayama@jp.fujitsu.com,
	holzheu@linux.vnet.ibm.com, dhowells@redhat.com,
	paul.gortmaker@windriver.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] vmcore: prevent PT_NOTE p_memsz overflow during header update
Date: Wed, 5 Feb 2014 08:39:12 -0500	[thread overview]
Message-ID: <20140205133912.GC6042@redhat.com> (raw)
In-Reply-To: <1391556352-15881-1-git-send-email-greg.pearson@hp.com>

On Tue, Feb 04, 2014 at 04:25:52PM -0700, Greg Pearson wrote:

[..]
> diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
> index 2ca7ba0..88d4585 100644
> --- a/fs/proc/vmcore.c
> +++ b/fs/proc/vmcore.c
> @@ -468,17 +468,24 @@ static int __init update_note_header_size_elf64(const Elf64_Ehdr *ehdr_ptr)
>  			return rc;
>  		}
>  		nhdr_ptr = notes_section;
> -		while (real_sz < max_sz) {
> -			if (nhdr_ptr->n_namesz == 0)
> -				break;
> +		while (nhdr_ptr->n_namesz != 0) {
>  			sz = sizeof(Elf64_Nhdr) +
>  				((nhdr_ptr->n_namesz + 3) & ~3) +
>  				((nhdr_ptr->n_descsz + 3) & ~3);
> +			if ((real_sz + sz) > max_sz) {
> +				pr_warn("Warning: Exceeded p_memsz, dropping PT_NOTE entry n_namesz=0x%x, n_descsz=0x%x\n",
> +					nhdr_ptr->n_namesz, nhdr_ptr->n_descsz);

You will need line break in pr_warn(). Too long a line. Limit it 80
columns per line.

> +				break;
> +			}
>  			real_sz += sz;
>  			nhdr_ptr = (Elf64_Nhdr*)((char*)nhdr_ptr + sz);
>  		}
>  		kfree(notes_section);
>  		phdr_ptr->p_memsz = real_sz;
> +		if (real_sz == 0) {
> +			pr_warn("Warning: Zero PT_NOTE entries found\n");
> +			return -EINVAL;

Given the fact that this is the first time I have heard about a PT_NOTE
being corrup, I will be fine with this patch too. If one encounters
an empty PT_NOTE, error out and don't create vmcore.

So please repost this patch with line lenght fixed.

Thanks
Vivek

  reply	other threads:[~2014-02-05 13:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-04 23:25 [PATCH v3] vmcore: prevent PT_NOTE p_memsz overflow during header update Greg Pearson
2014-02-05 13:39 ` Vivek Goyal [this message]
2014-02-05 13:43   ` Vivek Goyal
2014-02-05 16:39   ` Pearson, Greg
2014-02-05 16:49     ` Vivek Goyal

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=20140205133912.GC6042@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=d.hatayama@jp.fujitsu.com \
    --cc=dhowells@redhat.com \
    --cc=greg.pearson@hp.com \
    --cc=holzheu@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul.gortmaker@windriver.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox