aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
authorWANG Chao <chaowang@redhat.com>2015-02-17 16:46:01 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-17 17:34:52 -0500
commit34b47764297130b21aaeb4cc6119bb811814b8e3 (patch)
tree895a40dc502eb407afd284b9fd4f38bc539eea80 /fs/proc
parentb28c2ee868dbdc0baa89c60fb520be85d5e90a72 (diff)
vmcore: fix PT_NOTE n_namesz, n_descsz overflow issue
When updating PT_NOTE header size (ie. p_memsz), an overflow issue happens with the following bogus note entry: n_namesz = 0xFFFFFFFF n_descsz = 0x0 n_type = 0x0 This kind of note entry should be dropped during updating p_memsz. But because n_namesz is 32bit, after (n_namesz + 3) & (~3), it's overflow to 0x0, the note entry size looks sane and reserved. When userspace (eg. crash utility) is trying to access such bogus note, it could lead to an unexpected behavior (eg. crash utility segment fault because it's reading bogus address). The source of bogus note hasn't been identified yet. At least we could drop the bogus note so user space wouldn't be surprised. Signed-off-by: WANG Chao <chaowang@redhat.com> Cc: Dave Anderson <anderson@redhat.com> Cc: Baoquan He <bhe@redhat.com> Cc: Randy Wright <rwright@hp.com> Cc: Vivek Goyal <vgoyal@redhat.com> Cc: Paul Gortmaker <paul.gortmaker@windriver.com> Cc: Fabian Frederick <fabf@skynet.be> Cc: Vitaly Kuznetsov <vkuznets@redhat.com> Cc: Rashika Kheria <rashika.kheria@gmail.com> Cc: Greg Pearson <greg.pearson@hp.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/vmcore.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
index a90d6d354199..4e61388ec03d 100644
--- a/fs/proc/vmcore.c
+++ b/fs/proc/vmcore.c
@@ -546,8 +546,8 @@ static int __init update_note_header_size_elf64(const Elf64_Ehdr *ehdr_ptr)
546 nhdr_ptr = notes_section; 546 nhdr_ptr = notes_section;
547 while (nhdr_ptr->n_namesz != 0) { 547 while (nhdr_ptr->n_namesz != 0) {
548 sz = sizeof(Elf64_Nhdr) + 548 sz = sizeof(Elf64_Nhdr) +
549 ((nhdr_ptr->n_namesz + 3) & ~3) + 549 (((u64)nhdr_ptr->n_namesz + 3) & ~3) +
550 ((nhdr_ptr->n_descsz + 3) & ~3); 550 (((u64)nhdr_ptr->n_descsz + 3) & ~3);
551 if ((real_sz + sz) > max_sz) { 551 if ((real_sz + sz) > max_sz) {
552 pr_warn("Warning: Exceeded p_memsz, dropping PT_NOTE entry n_namesz=0x%x, n_descsz=0x%x\n", 552 pr_warn("Warning: Exceeded p_memsz, dropping PT_NOTE entry n_namesz=0x%x, n_descsz=0x%x\n",
553 nhdr_ptr->n_namesz, nhdr_ptr->n_descsz); 553 nhdr_ptr->n_namesz, nhdr_ptr->n_descsz);
@@ -732,8 +732,8 @@ static int __init update_note_header_size_elf32(const Elf32_Ehdr *ehdr_ptr)
732 nhdr_ptr = notes_section; 732 nhdr_ptr = notes_section;
733 while (nhdr_ptr->n_namesz != 0) { 733 while (nhdr_ptr->n_namesz != 0) {
734 sz = sizeof(Elf32_Nhdr) + 734 sz = sizeof(Elf32_Nhdr) +
735 ((nhdr_ptr->n_namesz + 3) & ~3) + 735 (((u64)nhdr_ptr->n_namesz + 3) & ~3) +
736 ((nhdr_ptr->n_descsz + 3) & ~3); 736 (((u64)nhdr_ptr->n_descsz + 3) & ~3);
737 if ((real_sz + sz) > max_sz) { 737 if ((real_sz + sz) > max_sz) {
738 pr_warn("Warning: Exceeded p_memsz, dropping PT_NOTE entry n_namesz=0x%x, n_descsz=0x%x\n", 738 pr_warn("Warning: Exceeded p_memsz, dropping PT_NOTE entry n_namesz=0x%x, n_descsz=0x%x\n",
739 nhdr_ptr->n_namesz, nhdr_ptr->n_descsz); 739 nhdr_ptr->n_namesz, nhdr_ptr->n_descsz);