public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Greg Pearson <greg.pearson@hp.com>
Cc: vgoyal@redhat.com, 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] vmcore: prevent PT_NOTE p_memsz overflow during header update
Date: Fri, 31 Jan 2014 15:16:51 -0800	[thread overview]
Message-ID: <20140131151651.26ff54cd7bd06fc5feb6fcc6@linux-foundation.org> (raw)
In-Reply-To: <1391209566-4734-1-git-send-email-greg.pearson@hp.com>

On Fri, 31 Jan 2014 16:06:06 -0700 Greg Pearson <greg.pearson@hp.com> wrote:

> Currently, update_note_header_size_elf64() and
> update_note_header_size_elf32() will add the size
> of a PT_NOTE entry to real_sz even if that causes real_sz
> to exceeds max_sz. This patch corrects the while loop logic
> in those routines to ensure that does not happen.
> 
> ...
>
> Occasionally, a second entry is encountered with very
> large n_namesz and n_descsz sizes:
> 
>   n_namesz = 0x80000008
>   n_descsz = 0x510ae163
>   n_type   = 0x80000008

Hang on.

> --- a/fs/proc/vmcore.c
> +++ b/fs/proc/vmcore.c
> @@ -468,12 +468,13 @@ 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);
> +			/* Silently drop further PT_NOTE entries */
> +			if ((real_sz + sz) > max_sz)
> +				break;

If we are encountering notes with these crazy sizes then what is
preventing (real_sx + sz) from wrapping through zero, which would
defeat this check?



  parent reply	other threads:[~2014-01-31 23:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-31 23:06 [PATCH] vmcore: prevent PT_NOTE p_memsz overflow during header update Greg Pearson
2014-01-31 23:14 ` Andrew Morton
2014-01-31 23:16 ` Andrew Morton [this message]
2014-02-01  1:07   ` Pearson, Greg
2014-02-01  2:12     ` Andrew Morton
2014-02-02 22:25       ` Eric W. Biederman
2014-02-03 15:47         ` Vivek Goyal
2014-02-03 16:57           ` Pearson, Greg
2014-02-03 17:05             ` 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=20140131151651.26ff54cd7bd06fc5feb6fcc6@linux-foundation.org \
    --to=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 \
    --cc=vgoyal@redhat.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