This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] Prevent illegal memory accesses when parsing incorrecctly formated core notes.
- From: Nick Clifton <nickc at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 16 Nov 2017 14:54:20 -0000
- Subject: [binutils-gdb] Prevent illegal memory accesses when parsing incorrecctly formated core notes.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=80a0437873045cc08753fcac4af154e2931a99fd
commit 80a0437873045cc08753fcac4af154e2931a99fd
Author: Nick Clifton <nickc@redhat.com>
Date: Thu Nov 16 14:53:32 2017 +0000
Prevent illegal memory accesses when parsing incorrecctly formated core notes.
PR 22421
* elf.c (elfcore_grok_netbsd_procinfo): Check that the note is big enough.
(elfcore_grok_openbsd_procinfo): Likewise.
(elfcore_grok_nto_status): Likewise.
Diff:
---
bfd/ChangeLog | 7 +++++++
bfd/elf.c | 10 ++++++++++
2 files changed, 17 insertions(+)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 8e358dd..8ac7765 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,12 @@
2017-11-16 Nick Clifton <nickc@redhat.com>
+ PR 22421
+ * elf.c (elfcore_grok_netbsd_procinfo): Check that the note is big enough.
+ (elfcore_grok_openbsd_procinfo): Likewise.
+ (elfcore_grok_nto_status): Likewise.
+
+2017-11-16 Nick Clifton <nickc@redhat.com>
+
* merge.c (sec_merge_emit): Always create padding buffer. Add
asserts to make sure that the buffer is long enough.
diff --git a/bfd/elf.c b/bfd/elf.c
index 694e435..93ed443 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -9871,6 +9871,7 @@ elfcore_grok_freebsd_psinfo (bfd *abfd, Elf_Internal_Note *note)
/* Check for version 1 in pr_version. */
if (bfd_h_get_32 (abfd, (bfd_byte *) note->descdata) != 1)
return FALSE;
+
offset = 4;
/* Skip over pr_psinfosz. */
@@ -10051,6 +10052,9 @@ elfcore_netbsd_get_lwpid (Elf_Internal_Note *note, int *lwpidp)
static bfd_boolean
elfcore_grok_netbsd_procinfo (bfd *abfd, Elf_Internal_Note *note)
{
+ if (note->descsz <= 0x7c + 31)
+ return FALSE;
+
/* Signal number at offset 0x08. */
elf_tdata (abfd)->core->signal
= bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + 0x08);
@@ -10135,6 +10139,9 @@ elfcore_grok_netbsd_note (bfd *abfd, Elf_Internal_Note *note)
static bfd_boolean
elfcore_grok_openbsd_procinfo (bfd *abfd, Elf_Internal_Note *note)
{
+ if (note->descsz <= 0x48 + 31)
+ return FALSE;
+
/* Signal number at offset 0x08. */
elf_tdata (abfd)->core->signal
= bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + 0x08);
@@ -10206,6 +10213,9 @@ elfcore_grok_nto_status (bfd *abfd, Elf_Internal_Note *note, long *tid)
short sig;
unsigned flags;
+ if (note->descsz < 16)
+ return FALSE;
+
/* nto_procfs_status 'pid' field is at offset 0. */
elf_tdata (abfd)->core->pid = bfd_get_32 (abfd, (bfd_byte *) ddata);