From: "Pearson, Greg" <greg.pearson@hp.com>
To: Vivek Goyal <vgoyal@redhat.com>
Cc: "akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"d.hatayama@jp.fujitsu.com" <d.hatayama@jp.fujitsu.com>,
"holzheu@linux.vnet.ibm.com" <holzheu@linux.vnet.ibm.com>,
"dhowells@redhat.com" <dhowells@redhat.com>,
"paul.gortmaker@windriver.com" <paul.gortmaker@windriver.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] vmcore: prevent PT_NOTE p_memsz overflow during header update
Date: Mon, 3 Feb 2014 22:57:58 +0000 [thread overview]
Message-ID: <52F01EF5.506@hp.com> (raw)
In-Reply-To: <20140203213813.GH10795@redhat.com>
On 02/03/2014 02:38 PM, Vivek Goyal wrote:
> On Mon, Feb 03, 2014 at 01:18:38PM -0700, Greg Pearson wrote:
>
> [..]
>> diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
>> index 2ca7ba0..051c803 100644
>> --- a/fs/proc/vmcore.c
>> +++ b/fs/proc/vmcore.c
>> @@ -468,12 +468,14 @@ 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: dropping PT_NOTE entry\n");
>> + break;
>> + }
> Hi Greg,
>
> Couple of minor nits.
>
> I think it is a good idea to give more data in warning which tells why
> are we dropping a note entry. May be something like.
>
> "Warning: Total note entry size exceeded PT_NOTE memsz. Dropping PT_NOTE entry, n_namesz=<> n_descsz=<>".
Sounds good I'll add more information to the pr_warn().
>
> Secondly, if there is only on note entry in a PT_NOTE header and we drop
> it, then that PT_NOTE header is empty and needs to be cleaned up.
>
> I think you will have to modify get_note_number_and_size_elf64() and
> other relevant functions which are not expecting ->p_memsz=0.
What about treating this as an error condition and adding a check to the
update_note_header_size_elf32()/update_note_header_size_elf64() routines
that would return a failure, something like the following at the end of
the routine:
if (real_sz == 0)
return -EINVAL
I could also add a pr_warn() with a message indicating no PT_NOTE
entries were found.
This seems like a lower risk change to handle the case I'm currently
seeing as opposed to changing the code to handle a p_memsz==0.
Thoughts?
--
Greg
next prev parent reply other threads:[~2014-02-03 22:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-03 20:18 [PATCH v2] vmcore: prevent PT_NOTE p_memsz overflow during header update Greg Pearson
2014-02-03 21:38 ` Vivek Goyal
2014-02-03 22:57 ` Pearson, Greg [this message]
2014-02-05 13:31 ` 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=52F01EF5.506@hp.com \
--to=greg.pearson@hp.com \
--cc=akpm@linux-foundation.org \
--cc=d.hatayama@jp.fujitsu.com \
--cc=dhowells@redhat.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 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.