Bug 1299964 (CVE-2016-2091)

Summary: CVE-2016-2091 libdwarf: Out-of-bounds read in dwarf_frame2.c
Product: [Other] Security Response Reporter: Adam Mariš <amaris>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED WONTFIX QA Contact:
Severity: low Docs Contact:
Priority: low    
Version: unspecifiedCC: carnil, cbuissar, fche, orion, slawomir
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-04-01 13:45:00 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1299966, 1299967    
Bug Blocks: 1299970    
Attachments:
Description Flags
Patch extracted from upstream commit 9565964f26 none

Description Adam Mariš 2016-01-19 15:58:26 UTC
An out-of-bounds vulnerability was found in dwarf_read_cie_fde_prefix function causing the aplication to crash.

CVE request (contains reproducer and crash report):

http://seclists.org/oss-sec/2016/q1/135

Comment 1 Adam Mariš 2016-01-19 15:58:53 UTC
Created libdwarf tracking bugs for this issue:

Affects: fedora-all [bug 1299966]
Affects: epel-all [bug 1299967]

Comment 2 Andrej Nemec 2016-01-29 12:15:30 UTC
CVE assignment: http://seclists.org/oss-sec/2016/q1/237

Comment 7 Cedric Buissart 2016-04-01 12:28:46 UTC
- The issue appears to be resolved upstream
- After bisecting, the patch seems to be included in the following 9565964f26 commit :
https://github.com/tomhughes/libdwarf/commit/9565964f26

In particular, the following pick appears to be sufficient :

----8<----
diff --git a/libdwarf/dwarf_frame2.c b/libdwarf/dwarf_frame2.c
index 472a174..e776020 100644
--- a/libdwarf/dwarf_frame2.c
+++ b/libdwarf/dwarf_frame2.c
@@ -964,7 +964,12 @@ dwarf_read_cie_fde_prefix(Dwarf_Debug dbg,
     Dwarf_Small *frame_ptr = frame_ptr_in;
     Dwarf_Small *cie_ptr_addr = 0;
     Dwarf_Unsigned cie_id = 0;
+    Dwarf_Small *section_end = section_ptr_in + section_length_in;
 
+    if(section_end < (frame_ptr +4)) {
+        _dwarf_error(dbg,error,DW_DLE_DEBUG_FRAME_LENGTH_BAD);
+        return DW_DLV_ERROR;
+    }
     /* READ_AREA_LENGTH updates frame_ptr for consumed bytes */
     READ_AREA_LENGTH(dbg, length, Dwarf_Unsigned,
         frame_ptr, local_length_size,
@@ -976,6 +981,10 @@ dwarf_read_cie_fde_prefix(Dwarf_Debug dbg,
             data. We should be very close to end of section. */
         return DW_DLV_NO_ENTRY;
     }
+    if((frame_ptr + local_length_size) >= section_end) {
+        _dwarf_error(dbg,error,DW_DLE_DEBUG_FRAME_LENGTH_BAD);
+        return DW_DLV_ERROR;
+    }
 
     cie_ptr_addr = frame_ptr;
     READ_UNALIGNED(dbg, cie_id, Dwarf_Unsigned,
--->8---

Comment 8 Cedric Buissart 2016-04-01 12:33:38 UTC
Created attachment 1142549 [details]
Patch extracted from upstream commit 9565964f26

Comment 10 Cedric Buissart 2016-04-01 13:31:27 UTC
Statement:

Red Hat Product Security has rated this issue as having Low security impact. This issue is not currently planned to be addressed in future updates. 
For additional information, refer to the Issue Severity Classification: https://access.redhat.com/security/updates/classification/.