/[gentoo-projects]/pax-utils/scanelf.c |
Parent Directory
|
Revision Log
Links to HEAD: | (view) (download) (as text) (annotate) |
moved to git://git.overlays.gentoo.org/proj/pax-utils.git
scanelf: add more range checks to deal with corrupt elfs
scanelf: check shdrs are valid before using them
scanelf: handle corrupted hash chains that have infinite loops
scanelf: rework interp lookup Prefer PT_INTERP over the section headers since that gets used at runtime. Add verification to the pointer we do find.
scanelf: add a few more elf->phdr checks
drop __DATE__ usage as the rcsid provides all the details we care about
scanelf: improve shdr string overflow check more Rather than operate on the result of the pointers (which might have overflowed due to the offset being huge), check the offset directly against the size of the file like we do elsewhere in scanelf.
scanelf: fix logic error in shdr string overflow Reported-by: Jakub Wilk <jwilk@debian.org> URL: https://bugs.debian.org/775270
scanelf: add a note in the rpath warning when we fix the ELF automatically #334819 by Dennis Schridde
scanelf: make sure to clear the symtab inputs when the section does not match #527490 by Juergen Rose
scanelf: do not use debug syms with runtime strings or vice versa
add support for symbol visibility
note that which() does not handle PATH="/foo::/bar" correctly
rewrite which() so that it works and does not break $PATH we were walking the $PATH in reverse which it should have been forwards. we were also modifying the pointer we got back from getenv() which meant any time we ran external code, $PATH would be truncated. finally, we never actually checked the first element -- we would bail before we got a chance.
tweak style -- no functional changes
scanelf: convert -E option to use array_t this avoids silently (and wrongly) truncating the options given to -E. it also makes the code a lot easier to handle. #504340 by David Binderman
move array_cnt check into array_for_each init atm, if you try to use array_for_each or array_flatten_str on an array that has no members, you will get a segfault. this is an easy rule to forget (and the current code does just that in at least one place), so move the array_cnt check into the init phase. theres negligible code size impact so it should not be a big deal.
scanelf: fix comment in middle of define
scanelf: flag object files that have a +x stack (even if it is -w) since its almost assured the final ELF will add +w automatically this makes a difference too -- see bug 445962 where dvdauthor produced a mpeg2desc.o that had a +x w/gcc-4.8 and a nested function, but the output only flagged the final mpeg2desc binary as that included +w stack markings
scanelf: use bool rather than char to avoid bogus gcc warning (filed upstream already)
scanelf: fix more warnings from gcc-4.8
scanelf: auto-align help output
scanelf: put the opendir() warning at the same verbose level as open() warning
scanelf: add support for multiple quiet levels and fix the wrap around behavior to max out instead
update ldconfig flags
scanelf/pspax: drop PT_LOAD counts since more than "normal" is not a bug and is semi-common with some targets, and the warning has out lived its usefulness -- it was added as an initial sanity check to get a feel for the real world
scanelf: use PT_INTERP if .interp could not be found
skip freeing of memory at exit since the kernel takes care of that for us
scanelf: pre-compile all the regexes up front rather than everytime we try to match the symbol
scanelf: convert -s parsing to arrays and allow multiple -s options
update copyright years
scanelf: if people use -g twice, switch to case insensitive regexes #433425
scanelf: add warnings when we cannot open an elf #427640 by Anthony Basile
when looking for symbol sections, ignore ones labeled NOBITS as that means they dont have any actual data (like in split debug files) #411023 by Mark
only append a slash if there isnt one already #404003 by Slawomir Nizio
drop EI_PAX setting when modifying pax flags #411919
fix help output to properly handle non-letter opts all the time
add --use-ldpath option that considers ld.so.conf when outputting full paths for %n
clarify --ldcache help option
fix typo in symbol description
use warnfp/errp rather than calling strerror(errno) ourselves
support ! negation with the -N (SONAME) operator
optimize fd closing when scanning ELFs to avoid double closing it
scanelf: support scanning for strings in ELFs that lack section headers by looking up the string tables via dynamic tags
fix off-by-one logic when adding strings to arrays
redo root support to use *at funcs and avoid memory operations where possible
simplify rcsid a little
convert fgets() to getline(), and simplify which() to avoid memory allocation
remove useless duplicate prototypes
simplify match_etype logic
convert ldpaths over to new array code to make it easier to maintain
allow people to search for multiple libraries (-N) or data sections (-k)
constify the return of scanelf_file_{sections,sym}
fixup style in previous root patch
[PATCH pax-utils 1/2] add --root option # Ludwig Nussel <ludwig.nussel@suse.de>
constify help string array
add a -C/--nocolor option and respect env $NOCOLOR #332289
change to simpler const argv0 string
use normal glob funcs rather than hardcoding 64bit vers since _GNU_SOURCE should transparently rewrite these to 64bit when feasible
check return value of lseek for errors
convert core pointers to void* to avoid ugly casts and gcc alignment warnings #290543
tweak -a description #236540
split out, simplify, and document the extended version matching code
extend symbol lookup syntax to allow matching of symbols based on more fields
unify some of the scanelf symtabs code paths
cleanup lookup_cache_lib() and return first match, not last #258090
fix dragonfly define check and tweak whitespace in scanelf_ldpath
trick gcc into not warning about write() when outputting the banner -- we dont care if this fails
store return value of system() since gcc whines about it now, but dont actually use it since we dont care
For bug #249731, add an xstrndup wrapper, and implement strndup on hosts that don't have it, based on the strndup implementation of sandbox, with a little change to make it C90 compliant.
use __PAX_UTILS_PATH_MAX, not BUFSIZ, when dealing with paths
convert getstr_perms() to strfileperms() and share it among all files
drop excessive parenthesis
fixup const handling in getstr_perms()
mark local state vars as static and drop unused ones
use MAP_FAILED rather than custom constant
drop pointless casts on mmap() return
undo accidential 'fix'
Fix manpage, thanks pipping
Remove the half-assed versioned_symname support. Matching against versioned symbol is possible (when the file is not stripped, for now) by using the regular expression matching (-g).
Rewrite symbol matching code in scanelf. The previous code was entirely broken when trying to match symbols in unstripped binaries when giving multiple symbols as target. The new code differs from the old one in quite a few ways: - debug output when -g option is passed is disabled in the code (hacky, but still better than before!); - regular expression matching is actually used when -g option is passed; - by default, the symbol name is tested against the symbol name without version; no-version symbol name matching is possible by using the -g option and adding a final $; - multiple symbols and single symbols are handled in the same way so that there is no more difference between them; - the returned symbol name is the actual symbol name as found in the file, so includes the version when the file is not stripped. While this means that there are some minimal differences between the previous code, it's arguable that this code is less buggy and more consistent than the one before.
Fixing whitespace.
Avoid crashes when scanning files with "corrupt symbols". Instead of dereferencing sym without checking, stop as soon as the pointer goes out of the ELF file range.
fix by Fabian Groffen to make sure default output format starts off initialized before we start strcating it #236539
add a cast to off_t printf to silence warning #236464
only issue warnings on missing cache code when targeting an ELF system
- add OSABI/EABI support to scanelf --osabi/--eabi to scanelf. Update elf.h
- add -Z/--size option
- mainly whitespace updates
- fix for when we are scanning BE Elf files from a LE system and vs versa.
residual xfunc changeover: dont check return value of xmalloc()
split xfuncs off into a sep file for all utils to use, cleanup misc things, and add some more comments
as pointed out by swegner, dont scan PHDRs that dont actually have a filesize (avoids scanning split debug info)
add missing void into empty function definitions
- show endian in -a display and be sure to exclude *macho* files from normal releases
- make -M take symbolic names in addition to numerical values
- add endian scanning support
- Print only ELF files with matching specified octal bits (like 755)
- update copyright headers
- update copyright headers
- display U for undefined symbols and D for defined symbols when using scanelf -s\* file
- make things a tad more portable to sparc and darwin
typo
- added regexp symbol matching using existing gmatch option
move format/elf documentation out of usage() and into docbook
fix whitespace in which() and remove unneeded memset()
add support for %M to display ECLASS
- dont call objdump without first making sure it exists.
generally improve textrel output
fix warnings on 32bit host
add support for running objdump when using -T -v to get automatic host disassemble
add support for displaying em_machine via %a format flag
move/rename do_state macro to a more appropriate place
- initial start of making scanelf return code mean something
- just a little whitespace cleanup
just whitespace
pass the stat struct down to scanelf_file() from scanelf_dir() so we dont run stat() twice on every file
Ludwig Nussel wrote: SuSE Linux includes /etc/ld.so.conf.d/*.conf by default but there are no files in there by default. Attached patch prevents scanelf from aborting.
dont output when scanning bind info on static elfs #153286
make sure we check QA_EXECSTACKS when .o objects are missing .note.GNU-stack #144986
eat whitespace
fix handling of defined/undefined versioned symbols
move utility funcs back to the bottom where they belong
- add work arounds for NetBSD
- make sure we really want to read from stdin
cleanup style, touchup new QA envvar code, and be better about cleaning up after ourselves
Fix segfault when envvars have no tokens (noted by SpanKY)
touchup style
use a new ARRAY_SIZE() macro for calculating the # of elements in a static array
cut down on the arch-specific ifdef cruft
move porting-specific stuff to porting.h
SET_STDOUT isnt needed
Add QA_WX_LOAD for filtering W|X PT_LOAD headers - bug #131779
- make sure we scan versioned symbols correctly on unstripped ELF files
- minor style fixups
Process QA_TEXTRELS and QA_EXECSTACK, whitespace-separated lists of ${D}-relative exemptions from textrel and executable stack (i.e. PF_X on PT_GNU_STACK) checks, so portage can hand this off to scanelf (bug #131779)
Implement function to lookup into ld-elf.so.hints file on FreeBSD and DragonFly, change to GLIBC/UCLIBC conditionals access to ld.so.conf and ls.so.cache (should work on GNU/kFreeBSD).
fix detection of defined/undefined symbols
only default to grep stdin style when no arguments were given to us
touchup style
- non linux hosts dont really need the glob code so invert the ifdefs
- add invert matching for section headers from spanky for flameeyes. Example: scanelf -B -k \!.symtab /usr/lib/debug -Rq -F%F#k
- invert logic for glob64
add support for scanning for just defined/undefined symbols
declare a few more things const
- add new + format modifier for verbose output. Auto detect stdin file handling
- we do not want to display lazy bindings incorrectly on executable files that were linked static
- dont try to remove the execbits on a PT_LOAD section when using -Xe
- Make -E take strings vs just numerics. Fixed off by one in ld.so.conf include file handling(Reported by PaX autho.r). Made sure we only set ei pax flags when etype is ET_EXEC || ET_DYN. Updated README, man page
- finished up ei_pax handling
- added the -z/--setpax flags. PT_PAX_FLAGS flags start off with with ---xe- ; EI_PAX is not done yet. Renamed the reference to elmer fudd back.
touchup output for new scan section code
- add -k option to manpage and -vh output
- add -k/--section <arg> flag so we can quickly identify executables that contain a given section by name
- add include globbing support for ld.so.conf handling. mainly only useful on distros other than gentoo
dont bother eating spaces anymore as our format string should cover that
- print ELF e_types when -h flag is given. Add missing PT_NUM to paxelf.c. Document new -M feature.
- add ability to scan files based on bits via new -M option. syntax is -M 32 or -M 64 ; invalid numerics are ignored
- add ability to scan files based on etype via new -E option. syntax is -E 1 or -E 1,2,3,4
fix phdr scanning
- skip multi load scan checks if ehdr->e_type is not ET_DYN or ET_EXEC. Make 'make debug' build with -g3 -nopie
- reset ldcache to 0 if set to -1 so we dont end up trying to memcmp later
fix up handling of corrupt symbol tables
make first verbose level actually useful
make the error messages of invalid options useful
previous fix actually broke symbol scanning
dont crash when scanning for symbols in a busted symbol table
cast pointers as void* to get rid of warnings
ignore invalid symbols in textrel lookup code
add some sanity checks to program header scanning
- dont write to memory when NULL rpaths exists and not using -X/--fix
refactor code a bit to allow to improve support for archive scanning
initial support for reading archive files (*.a)
define and use our own copy of PATH_MAX
zero out the whole dyn rpath section rather than just changing the tag
improve rpath output thanks to Ludwig Nussel and touchup the rpath fixing code to handle some corner cases
add support for automatically "fixing" insecure runpaths and removing the executable bit from stack/load program headers
make sure we warn about zero length rpaths and that we dont break out of the rpath checking too early. also dont bother duping the arg for the -f option
split the pt_load check out into a sep func for easier managing in the future and to shut up openbsd
update copyright years and unify headers in porting.h
touchup lookup_cache_lib() func a bit by plugging some memleaks, adding some comments, and handling 64/32 bit multilib systems
- initial function to do ld.so.cache lookups for DT_NEEDED entries
add support for scanning for multiple symbols at a time
st_size is unsigned, so dont cast it to signed
shouldnt need to dupe the args given to us since they are just pointers to argv ...
remove __USE_GNU
add support for scanning .note.GNU-stack in object files
fix #e (it used to act like %e)
split common non-elf features into paxinc.[ch]
touchup output of TEXTREL matches and update the format help output
use smaller license header
- add gmatching option to scanelf so that matching libz.so works with the -N option
complain if a shared object is missing DT_NEEDED and if we are in verbose mode
add support for showing SONAME (-S)
- add a few rpath security checks
change textrel scanner to check .text section instead of PT_LOAD ... also update -a to not include bind/interp info
make sure we check all the libraries a file needs instead of just the first one (-N)
tweak version output to include $PV
dont scan for TEXTREL locations if ELF doesnt have any TEXTRELs ... also flush stdout after each line
fix so -Tq works
make sure REL is an offset inside the symtab before using and create a func to pick the better sym/tab headers based on size
add support by kev quinn for showing textrels
fix runpath parsing in quiet mode
fix warning in printf
- Lets rename *stack* to phdr as the scope of the function has changed quite a bit from initial creation
add support for scanning for symbols (-N)
add support for checking if the PT_LOAD program header is +wx
add support for silent tests via # instead of %
fix warnings about signed compares and add support for parsing RPATH in silent mode
- make scanelf/pspax happy with -Wwrite-strings
fall back to runtime section headers if the debug ones have been stripped
add support for mangling of the matched filename (%p->strip search path %f->just basename)
add generic bswap macros and macro the stdout stuff so OS X builds
- make parseargs checks for already alloced buffers simpler. fixed typo in -s handling
- added initial inconsistent state detection for pax flags. update some of the copyright headers removing myself and assigning over to the foundation. fixed bug in pf display 5 is not 4
add some more checks to make sure people dont double specify options and make us malloc extra memory
- make scanelf display the PT_PAX_FLAGS if they exist and fall back on EI_PAX if they dont as the kernel would.
fixes for FreeBSD
make sure we use EGET() when accessing elf members
make sure -F disables -b too
- update manpages and code. Release 0.0.8
only fstat when we need to
make sure we dont try to read a symlink to a directory as an ELF
be quieter
- update formating for stk/rel and updated the manpage
- remove high chars. sorry spanky but everybody hates these.
dont try to parse program headers if none exist
add BIND to all output
add support for scanning bind/lazy info, fix a few cases where bad ELFs would trigger infinite loops, and allow people to use debug --verbose with --quiet
cache /etc/ld.so.conf so we can check it while scanning rpath
style tweak
update the help output
- add option to read from streams
make sure we verify pointers before using them and use variables with larger sizes than just int
err we need the buffer to be a real string since we use it later in strcat
use memcpy so we only overwrite the correct # of bytes
buffer output so quiet + format works
- update README and manpage for new options.
break scanelf_file() up into smaller functions to easily support custom --format output
add support for displaying an ELFs interp section
add a -y option to handle whether we scan symlinked files
move common warn/warnf/err macros to paxelf.h
- getting ready to cut 0.0.6
- vapier draws funny pictures http://dev.gentoo.org/~vapier/getenv-howto.png
- free orig pointer locations and not ptr that has been incremented. Use puts/fputs in place of printf() when no format identifier is used. Don't scan symlinks in scanelf_file()
merge some fixes from tigger and add support for dumping DT_NEEDED information
- just use 1 libc call to fill buf
- add a malloc check
fix quiet output with symbol scanning
- refine symbol formatting
add symbol scanning support to scanelf
handle any bitsize / endian type
add basic sanity check if user didnt give us any paths to scan
make -o failure abort
handle rpath and runpath and make sure they are sane
remove check_elf_header and IS_ELF since readelf() has these checks built in now
- added -o --file= option for redirecting stdout, use _POSIX_PATH_MAX vs PATH_MAX to mimic what is used elsewhere within the code.
- work around problem freeing memory on uclibc systems by using a static buffer for path handling. this should also speed up the scanelf_dir function
- change formatting on --version
remove useless null
make sure scanelf_ldpath scans /lib /usr/lib /usr/local/lib even if it isnt in ld.so.conf
- updated manpage again, rename -s/--stack to -e/--header and rename -H/--noheader to -B/--nobanner
make output with verbose easier to parse
add --mount, --verbose, and --noheader options
- added relro to header and uses puts vs printf for minor speed updated where printf was used without a format modifier
- update formatting to not be so ulgy
- update authors
fold pttool, scanexec, and scanrpath into scanelf and added ability to scan for TEXTRELs
more functions and cleanups
cleanup and unify duplicated code
use lstat()/S_ISREG to avoid reporting dups for symlinks. (speeds things up quite a bit)
update scanelf
paxelf touchup
small touchups
header cleanups, send all usage to stderr. add scanelf to README
change puts to scanelf
added scanelf.c
This form allows you to request diffs between any two revisions of this file. For each of the two "sides" of the diff, select a symbolic revision name using the selection box, or choose 'Use Text Field' and enter a numeric revision.
ViewVC Help | |
Powered by ViewVC 1.1.20 |