Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1548404 - dpdk: Partial build flags injection
Summary: dpdk: Partial build flags injection
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: dpdk
Version: 28
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Neil Horman
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: Fedora28BuildFlags 1550708
TreeView+ depends on / blocked
 
Reported: 2018-02-23 12:28 UTC by Florian Weimer
Modified: 2019-05-28 22:38 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1550708 (view as bug list)
Environment:
Last Closed: 2019-05-28 22:38:44 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Florian Weimer 2018-02-23 12:28:41 UTC
/usr/lib64/librte_pmd_avp.so.1 and other binaries in dpdk-17.11-4.fc28.x86_64 were not linked with the standard Fedora linker flags (LDFLAGS) from redhat-rpm-config:

gcc -m64 -O2 -g -pipe  -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -mcet -fcf-protection -Wformat -fPIC -L/builddir/build/BUILD/dpdk-17.11/x86_64-native-linuxapp-gcc/lib -Wl,--version-script=/builddir/build/BUILD/dpdk-17.11/drivers/net/avp/rte_pmd_avp_version.map  -shared avp_ethdev.o -z defs -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring -lrte_ethdev -lrte_net -lrte_kvargs -lrte_bus_pci -Wl,-soname,librte_pmd_avp.so.1 -o librte_pmd_avp.so.1 

CFLAGS is used there, but not LDFLAGS.

Comment 1 Florian Weimer 2018-02-28 17:36:07 UTC
Sorry, dpdk-17.11-4.fc28.x86_64 regressed.  BIND_NOW (aka -Wl,-z,now) is now missing.  I suspect it's because you removed “-e's/,/ /g'” from the sed expression.

Why can't you use the build flags directly?

Comment 2 Neil Horman 2018-02-28 21:33:59 UTC
have you looked at the DPDK build system?  Its a hot mess.  It mangles LDFLAGS, and EXTRA_LDFLAGS to insert -Wl automagically, which is already contained in the rpm macros, so they can't be used directly without further mangling them (hence the sed magic)

As far as your assertion of regression goes, I'm not sure I follow you.  I see the use -z now in the build logs:


https://koji.fedoraproject.org/koji/taskinfo?taskID=25373883

I think the problem was that I accidentally re-ran a scratch build after I added that last commit, which fixes the problem you describe, rather than creates it.

Comment 3 Florian Weimer 2018-03-01 19:42:08 UTC
Can we merge the latest upstream version into Fedora 28?  I would like to keep Fedora 28 as polished as possible, from a build flags point of view.

Comment 4 Neil Horman 2018-03-01 19:51:56 UTC
18.02 is the latest version.  I merged that last week (on Feb 19th).

Comment 5 Florian Weimer 2018-03-01 19:56:13 UTC
(In reply to Neil Horman from comment #4)
> 18.02 is the latest version.  I merged that last week (on Feb 19th).

That was rawhide.  I'm interested in a fix for Fedora 28.

Comment 6 Neil Horman 2018-03-01 20:03:00 UTC
oh, if we've already forked, then yeah, we can update there as well.

Comment 7 Neil Horman 2018-03-01 20:09:23 UTC
actually, scratch that, I don't see an f28 branch for anything yet.  Shouldn't we still be inheriting from rawhide?

Comment 8 Florian Weimer 2018-03-02 05:59:43 UTC
(In reply to Neil Horman from comment #7)
> actually, scratch that, I don't see an f28 branch for anything yet. 
> Shouldn't we still be inheriting from rawhide?

We have already branched, and fixed dpdk packages have not yet been built for Fedora 28.

Comment 9 Neil Horman 2018-03-02 14:56:45 UTC
[nhorman@hmswarspite dpdk]$ fedpkg request-branch f28
Could not execute request_branch: f28 is not a current release branch


Seems like something isn't quite right then.  Any ideas?

Comment 10 Florian Weimer 2018-03-02 15:00:27 UTC
I don't understand what you are trying to do.  There is already an f28 branch:

https://src.fedoraproject.org/rpms/dpdk/commits/f28

Comment 11 Neil Horman 2018-03-02 15:20:45 UTC
Thats very strange, it wasn't showing up in my git tree even after a pull, but deleting and recreating my clone caused it to show up.  Ok, I'll update f28

Comment 12 Florian Weimer 2018-03-05 15:54:56 UTC
Sorry, but it turns out that injection is still missing for dpdk-pmdinfogen.  From the dpdk-devel-18.02-2.fc28.x86_64 build log:

gcc -Wp,-MD,./.pmdinfogen.o.d.tmp  -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wpointer-arith -Wcast-align -Wnested-externs -Wcast-qual -Wformat-nonliteral -Wformat-security -Wundef -Wwrite-strings -Wdeprecated -Wimplicit-fallthrough=2 -Wno-format-truncation -g -I/builddir/build/BUILD/dpdk-18.02/x86_64-native-linuxapp-gcc/include    -o pmdinfogen.o -c /builddir/build/BUILD/dpdk-18.02/buildtools/pmdinfogen/pmdinfogen.c 
gcc    -o dpdk-pmdinfogen pmdinfogen.o  

But on the positive side, this is the only problematic file which remains on x86-64 according to the current tests.

Comment 13 Neil Horman 2018-03-05 23:17:28 UTC
Ugh, apparently binaries build as part of the hostapp class in the dpdk buildsystem use a different linker macro, so it didn't pick up the global one I changed before.  I'll fix it

Comment 14 Florian Weimer 2018-03-19 17:10:50 UTC
Thanks.  Would you please put the fix into Fedora 28 as well?

Comment 15 Fedora Update System 2018-03-20 16:38:35 UTC
dpdk-18.02-4.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2018-38209f4385

Comment 16 Fedora Update System 2018-03-21 14:13:31 UTC
dpdk-18.02-4.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-38209f4385

Comment 17 Florian Weimer 2018-04-05 07:56:09 UTC
Sorry, the build flags are still not correct in dpdk-devel-18.02-4.fc28.x86_64:

gcc   -z,relro -z,now  -o dpdk-pmdinfogen pmdinfogen.o  
/usr/bin/ld: warning: -z ,relro ignored.
/usr/bin/ld: warning: -z ,now ignored.

So /usr/share/dpdk/x86_64-default-linuxapp-gcc/app/dpdk-pmdinfogen is still not linked correctly.

Comment 18 Neil Horman 2018-04-05 15:23:31 UTC
do me a favor, open a new bug for this, the flag are properly set, but something in the DPDK makefile is broken.  This will need to be fixed up stream as well

Comment 19 Neil Horman 2018-04-05 15:25:17 UTC
actually, nm, it still needs fixing upstream, but I may be able to work around it in the spec file

Comment 20 Fedora Update System 2018-04-05 17:17:40 UTC
dpdk-18.02-6.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2018-0c67c5fdc3

Comment 21 Fedora Update System 2018-04-06 18:56:02 UTC
dpdk-18.02-6.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-0c67c5fdc3

Comment 22 Florian Weimer 2018-04-09 09:51:17 UTC
Sorry, /usr/share/dpdk/x86_64-default-linuxapp-gcc/app/dpdk-pmdinfogen in dpdk-devel-18.02-6.fc28.x86_64 is still not PIE. 8-(

gcc   -Wl,-z,relro -Wl,-z,now  -o dpdk-pmdinfogen pmdinfogen.o  

You really need the full %{build_ldflags} there.

Comment 23 Neil Horman 2018-04-09 15:58:42 UTC

I did a scratch build:
https://koji.fedoraproject.org/koji/taskinfo?taskID=26270085

In which I replaced __global_ldflags with build_ldflags, and no additional -fPIE flags were observed.

Looking at my fedora rpm macros on my local system, it appears that -fPIE isn't set in any of the ldflags macros.

Are you sure its intended to be there?

Comment 24 Florian Weimer 2018-04-30 11:14:24 UTC
(In reply to Neil Horman from comment #23)
> Looking at my fedora rpm macros on my local system, it appears that -fPIE
> isn't set in any of the ldflags macros.

We have two goals here: Use the Fedora flags so that future changes are reflected automatically in the package builds, and produce the intended hardening settings (which includes PIE).

The mechanism to enable PIE is somewhat complicated, search for “-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1” here:

https://src.fedoraproject.org/rpms/redhat-rpm-config/blob/master/f/buildflags.md

So you won't necessarily see -fPIE on linker command lines.  This is fine, as long as -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 is there.

Comment 25 Neil Horman 2018-04-30 15:25:54 UTC
Ok, I see what the problem is.  The -spec line was getting removed because its neither a linker nor a gcc flag, but rather some spec file macro expansion magic (for which I can find no documentation).  I can't just use __hardened_ldflags as is because dpdk requires that these flags get massaged into their non-standard build flags.  I'm currently trying to use the %set_build_flags macro to expand CFLAGS and LDFLAGS and use those, but it just expands %{_hardened_ldflags} to    
 -specs=/usr/lib/rpm/redhat/hardened-redhat-ld, which the linker doesn't recognize.  Whats the proscribed method for expanding that argument to the expanded contents of /usr/lib/rpm/redhat/redhat-hardened-ld?

Comment 26 Florian Weimer 2018-07-23 11:34:38 UTC
(In reply to Neil Horman from comment #25)
> Ok, I see what the problem is.  The -spec line was getting removed because
> its neither a linker nor a gcc flag, but rather some spec file macro
> expansion magic (for which I can find no documentation).  I can't just use
> __hardened_ldflags as is because dpdk requires that these flags get massaged
> into their non-standard build flags.  I'm currently trying to use the
> %set_build_flags macro to expand CFLAGS and LDFLAGS and use those, but it
> just expands %{_hardened_ldflags} to    
>  -specs=/usr/lib/rpm/redhat/hardened-redhat-ld, which the linker doesn't
> recognize.  Whats the proscribed method for expanding that argument to the
> expanded contents of /usr/lib/rpm/redhat/redhat-hardened-ld?

The recommended way is to invoke the linker through the gcc compiler driver.  The requirements for PIE, static linking, shared objects etc. are otherwise too hard to express with a single set of command line flags.

I'm asking around if there is a way to run the gcc compiler driver and have it print the linker command line, without actually running the linker, but I don't think there is.

Comment 27 Florian Weimer 2018-07-23 11:51:43 UTC
Jakub Jelinek pointed me to the -### (sic) option.

You can do this:

touch obj.o
gcc -### obj.o
gcc -### $(rpm --eval '%{build_ldflags}') obj.o

And then compare the difference in the set of flags on the lines matching /^ *[^ ]*collect2/.

Comment 28 Neil Horman 2018-07-25 20:45:14 UTC
Ok, I think I've managed to get something cobbled together (I hate the DPDK build system).  Do me a favor and take a look at the build logs here please:
https://koji.fedoraproject.org/koji/taskinfo?taskID=28603326

And confirm that you see all the c/ldflags that you expect.

Comment 29 Florian Weimer 2018-09-24 11:15:04 UTC
(In reply to Neil Horman from comment #28)
> Ok, I think I've managed to get something cobbled together (I hate the DPDK
> build system).  Do me a favor and take a look at the build logs here please:
> https://koji.fedoraproject.org/koji/taskinfo?taskID=28603326
> 
> And confirm that you see all the c/ldflags that you expect.

Sorry, the scratch build has expired by now.  Would you mind creating another one with your changes (for rawhide)?  Thanks.

Comment 31 Florian Weimer 2018-09-24 15:22:26 UTC
(In reply to Neil Horman from comment #30)
> https://koji.fedoraproject.org/koji/taskinfo?taskID=29862773

I still see these failures:

Hardened: dpdk-procinfo: MAYB: The PIC/PIE setting was not recorded.
Hardened: dpdk-procinfo: FAIL: Not linked as a position independent executable (ie need to add '-pie' to link command line).
Hardened: testpmd: MAYB: The PIC/PIE setting was not recorded.
Hardened: testpmd: FAIL: Not linked as a position independent executable (ie need to add '-pie' to link command line).

There is also this on x86_64:

Hardened: librte_pmd_af_packet.so.1: FAIL: GNU Property note is missing, but -fcf-protection is enabled.

That could be due to some included assembler routines which lack CET markup.

It does not happen on aarch64.  (On ppc64le, the annobin tooling is currently broken.)

Comment 32 Neil Horman 2018-09-24 21:41:27 UTC
https://koji.fedoraproject.org/koji/taskinfo?taskID=29867672

Try that, turns out I can't just use -pie as an LDFLAG, as it breaks some of the shared library builds

not sure whats going on with the fcf-protection issue

Comment 33 Florian Weimer 2018-09-27 10:35:11 UTC
(In reply to Neil Horman from comment #32)
> https://koji.fedoraproject.org/koji/taskinfo?taskID=29867672
> 
> Try that, turns out I can't just use -pie as an LDFLAG, as it breaks some of
> the shared library builds

You can compile everything with -fPIC, that's not a problem, it's just a minor loss in performance on some targets.  More recent versions of the annocheck should not report the use of PIC with executables anymore.

But you need to link executables (and only executables) with -pie.  If you use %{build_ldflags} for linking, it will automatically do the right thing: PIE link by default, shared object link (without PIE) with -shared.

> not sure whats going on with the fcf-protection issue

Do you have assembler code?  Upstream will have to fix that.

Comment 34 Neil Horman 2018-09-27 11:15:32 UTC
I know what I need to do, the problem is that DPDK builds both libraries and executables with the same flags that get passed in from the spec file.

And yes, theres lots of assembly in dpdk, and its there intentionally, so I'm not sure what you mean by "upstream will have to fix that".  They're not in the habbit of changing anything that might impact performance.

whats  the exact annocheck command line your using to validate this.  I'll run it here to see if I'm missing anything else

Comment 35 Florian Weimer 2018-09-27 11:22:44 UTC
(In reply to Neil Horman from comment #34)
> I know what I need to do, the problem is that DPDK builds both libraries and
> executables with the same flags that get passed in from the spec file.

It absolutely has to use -shared for linking libraries, and our %{build_flags} flags collection has magic in it which will disable the PIE link with -shared.  This is why we have to use a -specs= option as part of %{build_flags}.

So you absolutely can use the same build flags for libraries and executables.  Your build system is not the only one having this problem.

> And yes, theres lots of assembly in dpdk, and its there intentionally, so
> I'm not sure what you mean by "upstream will have to fix that".  They're not
> in the habbit of changing anything that might impact performance.

That's why the assembler files need review.  #include <cet.h> by itself does not add any new code, but depending on what the assembler files contain and how the functions therein are called, it maybe necessary to add CET markup instructions (which current CPUs treat as a NOP).

> whats  the exact annocheck command line your using to validate this.  I'll
> run it here to see if I'm missing anything else

I personally use “annocheck -v”.  The various --skip flags aren't necessary if you just pass through the Fedora build flags.

Comment 36 Fedora Update System 2018-09-28 18:28:25 UTC
dpdk-17.11.2-2.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2018-3350c45b17

Comment 37 Fedora Update System 2018-09-30 03:03:28 UTC
dpdk-17.11.2-2.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-3350c45b17

Comment 38 Ben Cotton 2019-05-02 20:48:10 UTC
This message is a reminder that Fedora 28 is nearing its end of life.
On 2019-May-28 Fedora will stop maintaining and issuing updates for
Fedora 28. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora 'version' of '28'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 28 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 39 Ben Cotton 2019-05-28 22:38:44 UTC
Fedora 28 changed to end-of-life (EOL) status on 2019-05-28. Fedora 28 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


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