Bug 32826

Summary: verify_rpath when both RUNPATH and RPATH are set
Product: Sisyphus Reporter: Ivan Zakharyaschev <imz>
Component: rpm-buildAssignee: placeholder <placeholder>
Status: CLOSED FIXED QA Contact: qa-sisyphus
Severity: enhancement    
Priority: P3 CC: arseny, glebfm, imz, ldv, placeholder, vt
Version: unstable   
Hardware: all   
OS: Linux   
Bug Depends on:    
Bug Blocks: 32821    

Description Ivan Zakharyaschev 2016-11-30 13:23:32 MSK
rpm-build-4.0.4-alt100.95

In the last release, I have made verify-elf to pass both RUNPATH and RPATH to verify_rpath(). This is a buggy.

If both are set, now, this makes such ELFs be discarded:


$ RPM_BUILD_ROOT=/usr /usr/lib/rpm/verify-elf /usr/lib64/libdw-0.155.so
section [18] '.tbss': alloc flag set but section not in any loaded segment
verify-elf: ERROR: /usr/lib64/libdw-0.155.so: eu-elflint failed
verify-elf: ERROR: /usr/lib64/libdw-0.155.so: RPATH contains a non-ascii entry: /usr/lib64/elfutils
/usr/lib64/elfutils
verify-elf: ERROR: /usr/lib64/libdw-0.155.so: RPATH contains illegal entry "/usr": /usr/lib64/elfutils
/usr/lib64/elfutils
$ objdump -p /usr/lib64/libdw-0.155.so | fgrep PATH
  RPATH                /usr/lib64/elfutils
  RUNPATH              /usr/lib64/elfutils
$ rpm -qf /usr/lib64/libdw-0.155.so
elfutils-0.155-alt2
$ 

(This is an old version of elfutils, just used as an example here.)

Hopefully, this is a very rare case that both are set in Sisyphus.

This case should be error_strict.

(I have overlooked that in verify_rpath(), unlike in other 3 cses where rpath is analyzed, it is not split into lines by : first.)

BTW, here is an example of the output of LD_DEBUG=libs , which I'd like to use in a further enhancement to get the standard search path (and to prefix it with RPM_BUILD_ROOT) -- to be as close to the real behavior of the runtime linker as possible. (As for verify_rpath()'s check for the presence of standard patsh in rpath, it should probably take into account not only the arch-specific set of search paths, but all possible ones as looked into by ldconfig, because their presence may signal an error, too.)


$ LD_TRACE_LOADED_OBJECTS=1 LD_DEBUG=libs /lib64/ld-linux-x86-64.so.2 --inhibit-cache /usr/lib64/libdw-0.155.so
      9473:	find library=libelf.so.1 [0]; searching
      9473:	 search path=/usr/lib64/elfutils/tls/x86_64:/usr/lib64/elfutils/tls:/usr/lib64/elfutils/x86_64:/usr/lib64/elfutils		(RUNPATH from file /usr/lib64/libdw-0.155.so)
      9473:	  trying file=/usr/lib64/elfutils/tls/x86_64/libelf.so.1
      9473:	  trying file=/usr/lib64/elfutils/tls/libelf.so.1
      9473:	  trying file=/usr/lib64/elfutils/x86_64/libelf.so.1
      9473:	  trying file=/usr/lib64/elfutils/libelf.so.1
      9473:	 search path=/lib64/tls/x86_64:/lib64/tls:/lib64/x86_64:/lib64:/usr/lib64/tls/x86_64:/usr/lib64/tls:/usr/lib64/x86_64:/usr/lib64		(system search path)
      9473:	  trying file=/lib64/tls/x86_64/libelf.so.1
      9473:	  trying file=/lib64/tls/libelf.so.1
      9473:	  trying file=/lib64/x86_64/libelf.so.1
      9473:	  trying file=/lib64/libelf.so.1
      9473:	  trying file=/usr/lib64/tls/x86_64/libelf.so.1
      9473:	  trying file=/usr/lib64/tls/libelf.so.1
      9473:	  trying file=/usr/lib64/x86_64/libelf.so.1
      9473:	  trying file=/usr/lib64/libelf.so.1
      9473:	
      9473:	find library=libdl.so.2 [0]; searching
      9473:	 search path=/usr/lib64/elfutils		(RUNPATH from file /usr/lib64/libdw-0.155.so)
      9473:	  trying file=/usr/lib64/elfutils/libdl.so.2
      9473:	 search path=/lib64:/usr/lib64		(system search path)
      9473:	  trying file=/lib64/libdl.so.2
      9473:	
      9473:	find library=liblzma.so.5 [0]; searching
      9473:	 search path=/usr/lib64/elfutils		(RUNPATH from file /usr/lib64/libdw-0.155.so)
      9473:	  trying file=/usr/lib64/elfutils/liblzma.so.5
      9473:	 search path=/lib64:/usr/lib64		(system search path)
      9473:	  trying file=/lib64/liblzma.so.5
      9473:	
      9473:	find library=libbz2.so.1 [0]; searching
      9473:	 search path=/usr/lib64/elfutils		(RUNPATH from file /usr/lib64/libdw-0.155.so)
      9473:	  trying file=/usr/lib64/elfutils/libbz2.so.1
      9473:	 search path=/lib64:/usr/lib64		(system search path)
      9473:	  trying file=/lib64/libbz2.so.1
      9473:	
      9473:	find library=libz.so.1 [0]; searching
      9473:	 search path=/usr/lib64/elfutils		(RUNPATH from file /usr/lib64/libdw-0.155.so)
      9473:	  trying file=/usr/lib64/elfutils/libz.so.1
      9473:	 search path=/lib64:/usr/lib64		(system search path)
      9473:	  trying file=/lib64/libz.so.1
      9473:	
      9473:	find library=libgcc_s.so.1 [0]; searching
      9473:	 search path=/usr/lib64/elfutils		(RUNPATH from file /usr/lib64/libdw-0.155.so)
      9473:	  trying file=/usr/lib64/elfutils/libgcc_s.so.1
      9473:	 search path=/lib64:/usr/lib64		(system search path)
      9473:	  trying file=/lib64/libgcc_s.so.1
      9473:	
      9473:	find library=libc.so.6 [0]; searching
      9473:	 search path=/usr/lib64/elfutils		(RUNPATH from file /usr/lib64/libdw-0.155.so)
      9473:	  trying file=/usr/lib64/elfutils/libc.so.6
      9473:	 search path=/lib64:/usr/lib64		(system search path)
      9473:	  trying file=/lib64/libc.so.6
      9473:	
	linux-vdso.so.1 (0x00007fff157fe000)
	libelf.so.1 => /usr/lib64/libelf.so.1 (0x0000003de3400000)
	libdl.so.2 => /lib64/libdl.so.2 (0x0000003ddc800000)
	liblzma.so.5 => /lib64/liblzma.so.5 (0x0000003dec200000)
	libbz2.so.1 => /lib64/libbz2.so.1 (0x0000003df0800000)
	libz.so.1 => /lib64/libz.so.1 (0x0000003ddd400000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000003dddc00000)
	libc.so.6 => /lib64/libc.so.6 (0x0000003ddc400000)
	/lib64/ld-linux-x86-64.so.2 (0x0000003ddc000000)
$
Comment 1 Ivan Zakharyaschev 2016-11-30 13:25:21 MSK
$ RPM_BUILD_ROOT=/var/empty /usr/lib/rpm/verify-elf /usr/lib64/libdw-0.155.so
section [18] '.tbss': alloc flag set but section not in any loaded segment
verify-elf: ERROR: /usr/lib64/libdw-0.155.so: eu-elflint failed
verify-elf: ERROR: /usr/lib64/libdw-0.155.so: RPATH contains a non-ascii entry: /usr/lib64/elfutils
/usr/lib64/elfutils
$
Comment 2 Repository Robot 2016-11-30 20:07:10 MSK
rpm-4.0.4-alt100.96 -> sisyphus:

* Wed Nov 30 2016 Ivan Zakharyaschev <imz@altlinux> 4.0.4-alt100.96
- verify-elf: don't confuse the initial verify_rpath() in case
  of two RUNPATH/RPATHs (ALT#32826).