Bug 25831

Summary: Assertion failure in eu-objdump
Product: elfutils Reporter: Manh-Dung Nguyen <nguyenmanhdung1710>
Component: generalAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: elfutils-devel, mark, nguyenmanhdung1710
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed: 2020-04-16 00:00:00
Attachments: PoC for an assertion failure

Description Manh-Dung Nguyen 2020-04-16 06:28:01 UTC
Created attachment 12465 [details]
PoC for an assertion failure

Hi,

An assertion failure was discovered in the latest commit 1a9fe4b of elfutils 0.179, as demonstrated by eu-objdump via a crafted file.

To reproduce: eu-objdump -d PoC

Valgrind says:
objdump: ../../libcpu/i386_disasm.c:449: x86_64_disasm: Assertion `correct_prefix == 0 || (prefixes & correct_prefix) != 0' failed.
==6901== 
==6901== Process terminating with default action of signal 6 (SIGABRT)
==6901==    at 0x56F5428: raise (raise.c:54)
==6901==    by 0x56F7029: abort (abort.c:89)
==6901==    by 0x56EDBD6: __assert_fail_base (assert.c:92)
==6901==    by 0x56EDC81: __assert_fail (assert.c:101)
==6901==    by 0x47BF64: x86_64_disasm (i386_disasm.c:448)
==6901==    by 0x4E4ECE0: disasm_cb (disasm_cb.c:178)
==6901==    by 0x407017: show_disasm (objdump.c:737)
==6901==    by 0x407017: handle_elf (objdump.c:783)
==6901==    by 0x4029BD: process_file (objdump.c:251)
==6901==    by 0x4029BD: main (objdump.c:164)

Thanks,
Manh Dung
Comment 1 Mark Wielaard 2020-04-16 13:54:29 UTC
It is bad code and so correct to reject it. But we can reject it without asserting and just printing "(bad)". Proposed patch:
https://sourceware.org/pipermail/elfutils-devel/2020q2/002619.html
Comment 2 Mark Wielaard 2020-04-21 20:29:08 UTC
Pushed the fix:

commit 25d40a626d36c140c8bb309f410f25af2836ec9b
Author: Mark Wielaard <mark@klomp.org>
Date:   Thu Apr 16 15:41:57 2020 +0200

    libcpu: Replace assert with goto invalid_op for bad prefix.
    
    https://sourceware.org/bugzilla/show_bug.cgi?id=25831
    
    Signed-off-by: Mark Wielaard <mark@klomp.org>