Bug 1581224 - rpm: Adjustments in ELF processing for file 5.33 output change
Summary: rpm: Adjustments in ELF processing for file 5.33 output change
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: rpm
Version: 28
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Mark Wielaard
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1570246 1581227
TreeView+ depends on / blocked
 
Reported: 2018-05-22 11:44 UTC by Florian Weimer
Modified: 2018-05-27 19:31 UTC (History)
8 users (show)

Fixed In Version: rpm-4.14.1-9.fc28
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1581227 (view as bug list)
Environment:
Last Closed: 2018-05-27 19:31:33 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1581343 0 unspecified CLOSED file-5.33 identification of gstreamer1 plugins changed 2021-02-22 00:41:40 UTC

Internal Links: 1581343

Description Florian Weimer 2018-05-22 11:44:23 UTC
file 5.33 changed output for PIE executables:

# file /bin/bash
/bin/bash: ELF 64-bit LSB pie executable x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=59d7babe7e71d4cb6a1168b845a5df9392f175c2, stripped, too many notes (256)
# file --mime /bin/bash
/bin/bash: application/x-pie-executable; charset=binary

It looks like the following scripts need adjustments:

scripts/brp-strip
scripts/brp-strip-shared
scripts/find-debuginfo.sh

Previously, ld.so was excluded from stripping, but this is no longer the case, causing valgrind to fail (bug 1570246).

If you think that ld.so was not stripped in error, please provide a way to preserve the .symtab section again, so that we can build a fixed glibc.

This needs fixing in Fedora 28 and rawhide.

Comment 1 Mark Wielaard 2018-05-22 13:00:17 UTC
I am not sure when brp-strip and brp-strip-shared are used, but for find-debuginfo.sh the fix is easy (although untested):

diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
index a7c2db0..90a4494 100755
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -235,6 +235,7 @@ strip_to_debug()
   $strip_g && case "$(file -bi "$2")" in
   application/x-sharedlib*) g=-g ;;
   application/x-executable*) g=-g ;;
+  application/x-pie-executable*) g=-g ;;
   esac
   eu-strip --remove-comment $r $g ${keep_remove_args} -f "$1" "$2" || exit
   chmod 444 "$1" || exit

Note that instead of using find_debuginfo_args="-g" (or _find_debuginfo_opts), which runs [eu-]strip to only remove the .debug sections, but not other non-allocated sections, you could also use find_debuginfo_args="--keep-section .symtab" to explicitly keep the .symtab section (but still strip away everything else).

Comment 2 Florian Weimer 2018-05-22 13:36:33 UTC
(In reply to Mark Wielaard from comment #1)
> I am not sure when brp-strip and brp-strip-shared are used, but for
> find-debuginfo.sh the fix is easy (although untested):
> 
> diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
> index a7c2db0..90a4494 100755
> --- a/scripts/find-debuginfo.sh
> +++ b/scripts/find-debuginfo.sh
> @@ -235,6 +235,7 @@ strip_to_debug()
>    $strip_g && case "$(file -bi "$2")" in
>    application/x-sharedlib*) g=-g ;;
>    application/x-executable*) g=-g ;;
> +  application/x-pie-executable*) g=-g ;;
>    esac
>    eu-strip --remove-comment $r $g ${keep_remove_args} -f "$1" "$2" || exit
>    chmod 444 "$1" || exit

I patched this manually into a buildroot, and can confirm that this change restores the .symtab section for ld.so, so valgrind works again.  Thanks!

Comment 3 Mark Wielaard 2018-05-22 21:38:13 UTC
(In reply to Florian Weimer from comment #2)
> I patched this manually into a buildroot, and can confirm that this change
> restores the .symtab section for ld.so, so valgrind works again.  Thanks!

Thanks for testing.
I posted the patch upstream:
http://lists.rpm.org/pipermail/rpm-maint/2018-May/007976.html
And added it to fedora rpm and did a build for rawhide (rpm-4.14.1-9.fc29)
http://koji.fedoraproject.org/koji/buildinfo?buildID=1084068

If it works out, it should be trivial to add to f28.

Comment 4 Florian Weimer 2018-05-23 10:17:21 UTC
glibc-2.27.9000-19.fc29.x86_64 unbreaks valgrind.  However, that version was built against file-5.33-4.fc29 as well, so it is not clear which change actually fixed matters. 8-)

Comment 5 Mark Wielaard 2018-05-23 10:51:00 UTC
(In reply to Florian Weimer from comment #4)
> glibc-2.27.9000-19.fc29.x86_64 unbreaks valgrind.  However, that version was
> built against file-5.33-4.fc29 as well, so it is not clear which change
> actually fixed matters. 8-)

Aha, I see file also added a countermeasure in file-5.33-4:

- do not classify shared libraries as pie executables (#1581343)

Good, then either this or that going into f28 would resolve things.

Comment 6 Kamil Dudka 2018-05-23 11:34:24 UTC
We already have an update for file-5.33-4.fc28 at Bodhi:

https://bodhi.fedoraproject.org/updates/FEDORA-2018-d1425c85a7

Despite its karma is +3, it has not yet reached updates-testing, and I see no button to move it forward.

Comment 7 Florian Weimer 2018-05-24 14:05:03 UTC
# rpm -q file
file-5.33-4.fc28.x86_64
# file --mime /sbin/ldconfig 
/sbin/ldconfig: application/x-pie-executable; charset=binary
# file --mime /bin/bash
/bin/bash: application/x-pie-executable; charset=binary

So the file update is definitely NOT sufficient to fix the find-debuginfo.sh issue.  We need the patch from comment 1.

Comment 8 Kamil Dudka 2018-05-24 14:50:52 UTC
I have submitted a new update to fix the MIME output, too:

https://bodhi.fedoraproject.org/updates/file-5.33-5.fc28

Sorry for the troubles!

Comment 9 Fedora Update System 2018-05-24 15:13:54 UTC
rpm-4.14.1-9.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2018-1894f7892a

Comment 10 Fedora Update System 2018-05-25 18:44:38 UTC
rpm-4.14.1-9.fc28 has been pushed to the Fedora 28 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-1894f7892a

Comment 11 Fedora Update System 2018-05-27 19:31:33 UTC
rpm-4.14.1-9.fc28 has been pushed to the Fedora 28 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.