aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* security.c: whitelist ipc() syscall for fakeroot on ppc64 and friendsHEADv1.2.4masterSergei Trofimovich2019-01-141-0/+6
| | | | | | | | | | | | | | | | | | On amd64 and friends msgget() and similar syscalls are standalone syscalls. On i386 and friends msgget() is a subcall of ipc() syscall. This makes fakechroot break 'scanelf' as: $ LANG=C fakeroot scanelf -t /bin/bash /usr/bin/fakeroot: line 178: 6820 Bad system call (core dumped) The change whitelists ipc() call which allows all sysv syscalls, namely: - semop, semget, semctl, semtimedop - msgsnd, msgrcv, msgget, msgctl - shmat, shmdt, shmget, shmctl Reported-and-fixed-by: Samuel Holland Bug: https://bugs.gentoo.org/675378 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* lddtree.py: use errno properlyOleksandr Natalenko2018-11-191-1/+1
| | | | | | | | | | | | os.errno interface is removed [1], thus should not be used. In fact, it is not used in other places of lddtree.py, so fix this one too, because it breaks --copy-to-tree on systems with Python 3.7. [1] https://bugs.python.org/issue33666 Bug: https://bugs.gentoo.org/671522 Signed-off-by: Oleksandr Natalenko <oleksandr@natalenko.name> Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* paxelf: constify elfobj pointersMike Frysinger2018-06-073-19/+30
| | | | | | We rarely need to modify the memory from our input ELFs, so constify all the buffers. We end up having to cast away the const in the "fix" paths in scanelf (which is a bit ugly), but otherwise everything else works.
* scanelf: add general const markings to Elf pointersMike Frysinger2018-06-071-36/+36
|
* scanelf: use asprintf instead of manual malloc/sprintfMike Frysinger2018-06-071-5/+7
| | | | | This makes the code a bit nicer to deal with. For portable targets, we already include asprintf from gnulib.
* paxelf: constify elfobj pointer in helpersMike Frysinger2018-06-072-18/+18
| | | | This helper funcs only read data, so mark elfobj as const.
* paxelf: constify misc pointersMike Frysinger2018-06-071-4/+4
| | | | Mark internal pointers as const that we don't modify anywhere.
* dumpelf: constify misc pointersMike Frysinger2018-06-071-7/+7
| | | | Mark all possible pointers const since we don't modify anything.
* paxldso: constify elf structsMike Frysinger2018-06-071-2/+2
|
* pspax: constify all the pointersMike Frysinger2018-06-071-15/+15
|
* build: support clang a bit betterMike Frysinger2018-06-071-4/+6
| | | | | Use the -Werror=unknown-warning-option option if available so clang will reject some of the extra -W flags we add ourselves.
* paxelf: constify elf_findsecbynameMike Frysinger2018-06-073-26/+26
| | | | | We need to also constify scanelf_file_get_symtabs due to cascading const markings.
* scanelf: constify most scanelf_file_* helpersMike Frysinger2018-06-071-7/+7
| | | | Just house keeping -- all of these pointers are already used as const mem.
* scanelf: constify rpath_security_checksMike Frysinger2018-06-071-1/+1
|
* scanelf.c: fix TEXTREL parsing for files with non-zero load addressv1.2.3Sergei Trofimovich2018-02-181-5/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In bug #566118 scanelf failed to decode TEXTRELs on gcc binaries where program headers have absolute addresses: $ dumpelf ia64_bug_gcc/cc1plus /* Dynamic tag #25 'DT_RELA' 0x2099518 */ { .d_tag = 0x7 , .d_un = { .d_val = 0x4000000000104B08 , .d_ptr = 0x4000000000104B08 , }, }, /* Section Header #8 '.rela.dyn' 0x20AA610 */ { .sh_type = 4 , /* [SHT_RELA] */ .sh_addr = 0x4000000000104B08 , .sh_offset = 1067784 , /* (bytes) */ }, Before the change scanelf assumed DT_RELA.d_ptr is a relative offset. This is not true in general case but good-enough for DSOs as they have zero load address. This change extends the check for executables. To make addresses relative again we find load address of first byte from program header with 'p_offset'. /* Program Header #2 0xB0 */ { .p_type = 1 , /* [PT_LOAD] */ .p_offset = 0 , /* (bytes into file) */ .p_vaddr = 0x4000000000000000 , /* (virtual addr at runtime) */ .p_paddr = 0x4000000000000000 , /* (physical addr at runtime) */ }, Bug: https://bugs.gentoo.org/566118 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* autogen.sh: add gnulib modules for SolarisMichael Haubenwallner2017-09-182-1/+3
| | | | | | | Need gnulib modules stpcpy, euidaccess for Solaris 10, where euidaccess uses eaccess when available, probably via LIB_EACCESS. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* check for linux/securebits.h, missing on Linux 2.6.32Michael Haubenwallner2017-09-182-1/+5
| | | | Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* scanelf: fix out-of-bounds access in ia64Sergei Trofimovich2017-09-181-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | commit 2eb852129394f97dae89c0ff1f9f48637edcb0e9 slightly changed decoder and added unchecked read from elf header: ``` switch (EGET(dpltrel->d_un.d_val)) { \ case DT_REL: \ rel = REL##B(elf->vdata + EGET(drel->d_un.d_val)); \ ``` On ia64 'EGET(drel->d_un.d_val)' returns absolute address: ``` $ dumpelf bug/luatex ... /* Dynamic tag #31 'DT_RELA' 0x97E310 */ { .d_tag = 0x7 , .d_un = { .d_val = 0x4000000000031C30 , .d_ptr = 0x4000000000031C30 , }, }, ``` That causes 'scanelf' crash on binaries like 'luatex'. This change restores check and loudly skips such sections: scanelf: bug/luatex: DT_RELA is out of file range Bug: https://bugs.gentoo.org/624356 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* paxelf: constify pax_short_* helpersMike Frysinger2017-03-033-9/+8
|
* lddtree: move parser logic into a funcMike Frysinger2017-02-161-2/+8
| | | | This keeps the main func a bit cleaner.
* pylint: add a helper to keep python code cleanMike Frysinger2017-02-163-5/+94
| | | | Fix up some lddtree logic at the same time so it's warning free.
* tests: rename files to avoid ".py" suffix on non-python filesMike Frysinger2017-02-167-7/+7
|
* add helper for checking memory/elf rangesMike Frysinger2017-02-113-25/+19
| | | | Less likely to screw up the logic this way.
* scanelf: check range of hash bucketMike Frysinger2017-02-111-1/+2
| | | | | | | Make sure we don't walk off the end of the ELF with a corrupt hash table. URL: https://bugs.gentoo.org/608766 Reported-by: Agostino Sarubbo <ago@gentoo.org>
* dumpelf: check for invalid notesMike Frysinger2017-02-011-7/+16
| | | | | | | Handle cases where the size fields would overflow the additions. URL: https://bugs.gentoo.org/607898 Reported-by: Agostino Sarubbo <ago@gentoo.org>
* dumpelf: check for invalid program headersMike Frysinger2017-02-012-4/+9
| | | | | URL: https://bugs.gentoo.org/607896 Reported-by: Agostino Sarubbo <ago@gentoo.org>
* dumpelf: check for invalid section entry sizesMike Frysinger2017-02-011-22/+28
| | | | | URL: https://bugs.gentoo.org/607894 Reported-by: Agostino Sarubbo <ago@gentoo.org>
* TODO: drop fixed issues and add some new onesv1.2.2Mike Frysinger2017-01-241-7/+4
|
* scanelf: revert back to looking at .dynstr directlyMike Frysinger2017-01-242-6/+25
| | | | | | The rpath/needed/soname strings are only listed in .dynstr, so trying to locate them in .strtab fails. Which means using the lookup helper breaks behavior on non-stripped files.
* scanelf: switch all string table lookups to scanelf_file_get_symtabsv1.2.1Mike Frysinger2017-01-231-23/+23
| | | | | | We don't care about the .strtab-vs-.dynstr, but we do want to fall back to tables that can only be found via dynamic tags and program headers.
* scanelf: add helper for walking dynamic tagsMike Frysinger2017-01-231-96/+35
| | | | | | | | We have many loops that operate on dynamic tags which all crash when given an ELF with a corrupt dynamic table. Add a helper to walk the table so we can centralize bounds checking in one place. Reported-by: Agostino Sarubbo <ago@gentoo.org>
* scanelf: fix offset checking when looking up symbols via hashMike Frysinger2017-01-231-4/+5
| | | | | | | | A number of refactors hid bugs here in that the first offset value here would be left over from earlier code. Localize the code a bit to try and keep that from happening again. We also reload phdr since this loop expects to walk the whole table.
* scanelf: change abs() to a size_t castMike Frysinger2017-01-231-1/+1
| | | | | | | The point of using abs here was to avoid a signed-vs-unsigned warning, but it doesn't actually work because abs() returns a signed integer. Since we always know end is larger than start, cast the result to a size_t instead.
* security: fix building on much older systemsv1.2Mike Frysinger2017-01-211-1/+24
| | | | | | Basically wrap all defines in ifdefs or add fallback stubs. URL: https://bugs.gentoo.org/606184
* travis: drop pyelftools installMike Frysinger2017-01-211-2/+0
| | | | | They aren't available apparently, and it seems like Travis has made it a failure now rather than being ignored.
* scanmacho: fix 126 byte limit on -E optionMike Frysinger2016-11-261-3/+3
|
* scanelf: rewrite textrels decoder to use program segmentsMike Frysinger2016-11-251-28/+88
| | | | | | Previously, we only looked at the section name ".text". This fails when other names are used, or when the section headers are incomplete. Since the runtime only looks at program headers, change the code to match.
* scanelf: add helper funcs for looking up program headersMike Frysinger2016-11-251-182/+222
|
* scanelf: standardize macro indentation levelsMike Frysinger2016-11-231-255/+254
| | | | | The style for indentation of ELF macros has drifted over time. Realign them all to follow the same style. No functional changes.
* scanelf: unify some boiler plate logic with ELF-sized macrosMike Frysinger2016-11-231-73/+42
| | | | | Shouldn't be any functional changes here, just making life easier for adding more macros like this.
* dumpelf: add support for prelink sectionsMike Frysinger2016-11-231-0/+34
|
* dumpelf: add support for dumping notesMike Frysinger2016-11-234-9/+151
|
* dumpelf: clean up types all over the placeMike Frysinger2016-11-173-88/+90
| | | | | | Rather than blindly cast everything to unsigned long (which doesn't work when working with 64-bit ELFs on a 32-bit host), use the proper types in all the printf statements.
* paxldso: fix unused arg warnings when support is disabledMike Frysinger2016-11-141-2/+2
|
* paxldso: always expose ldpaths arrayMike Frysinger2016-11-142-3/+4
| | | | | | | This fixes building when ldso config logic is unavailable since consumers (like scanelf) always attempt to walk the array. Changing the code to be an empty array by default so it won't suck up too much space when support isn't available.
* paxldso: fix building when ldso support is disabledMike Frysinger2016-11-141-0/+2
|
* paxldso: properly decode the flags bits in the cachev1.1.7Mike Frysinger2016-11-121-34/+114
| | | | | This fixes handling of multiple ABIs for a single arch like x86/x86_64/x32 or mips o32/n32/n64. It also fixes decoding of arm float libs.
* paxldso: clean up local vars & types a bitMike Frysinger2016-11-121-11/+13
| | | | | | | | Use the same types (unsigned-vs-signed) as glibc's cache code, and move relevant variables down into the scope where they're used rather than putting all of them in the top func scope. Should be no real functional changes here.
* paxldso: switch from a static sized path buffer to dynamicMike Frysinger2016-11-121-3/+21
| | | | | | We keep the buffer around to avoid the malloc overhead between calls, and we should really only need to grow it once or twice. This way we work with an sized lib path and not just the static limit.
* paxldso: delete netbsd cache logicMike Frysinger2016-11-122-30/+1
| | | | | | This doesn't actually parse the cache file, it walks the registered ld.so.conf paths. Since common code takes care of that via with the --use-ldpaths option, delete the duplicate ldpath logic.