Bug 1567797

Summary: root permission needed to read globally readable file
Product: [Fedora] Fedora Reporter: jiri vanek <jvanek>
Component: libdasmAssignee: Michal Ambroz <rebus>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: rebus
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-17 18:11:54 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description jiri vanek 2018-04-16 08:45:56 UTC
Hello!

Maybe it is feature, not  a bug, but to disassemble system libraries, one needs to be root, even if the file is globally readable and executable:

 $    ls -l   /bin/das  /usr/lib/libasound.so.2.0.0 
-rwxr-xr-x 1 root root   11328 Apr  3 21:30 /bin/das
-rwxr-xr-x 1 root root 1093988 Nov 14 10:03 /usr/lib/libasound.so.2.0.0

ˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇ
 $    /bin/das  /usr/lib/libasound.so.2.0.0  | head
Error: unable to open file "/usr/lib/libasound.so.2.0.0"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 $     cat    /bin/das  /usr/lib/libasound.so.2.0.0  | head
ELF>�
          @@@%@8	@@@@@@

 $    sudo    /bin/das  /usr/lib/libasound.so.2.0.0  | head
00000000  7f45              jg 0x47
00000002  4c                dec esp
00000003  46                inc esi
00000004  0101              add [ecx],eax
00000006  0100              add [eax],eax
00000008  0000              add [eax],al
0000000a  0000              add [eax],al
0000000c  0000              add [eax],al
0000000e  0000              add [eax],al
00000010  0300              add eax,[eax]

Comment 1 Michal Ambroz 2018-04-17 17:01:12 UTC
It is a bug, fopen is called with parameter "r+b" (read and write, binary) instead of "rb" (read binary).

Comment 2 Michal Ambroz 2018-04-17 18:11:54 UTC
Created pull request upstream to fix this:
https://github.com/jtpereyda/libdasm/pull/9

Patched also the fedora package in rawhide for next release.
I won't be pushing the update packages now as this is not core or even purpose of libdasm or "das" example application to disassemble whole libraries. The libdasm / das is meant to be used for 32-bit opcode such as snippets of the shellcode / functions etc.

Comment 3 jiri vanek 2018-04-17 18:16:54 UTC
Sure. Thanx!