Bug 1956998

Summary: annocheck reports that pigz is compiled without -fstack-protector-strong, -D_FORTIFY_SOURCE=2, and -fPIE/-fPIC
Product: Red Hat Enterprise Linux 9 Reporter: Jan Pazdziora <jpazdziora>
Component: pigzAssignee: Prarit Bhargava <prarit>
Status: CLOSED ERRATA QA Contact: Robin Hack <rhack>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.0CC: bnater, hwkernel-mgr, jjaburek, jpazdziora, lpol, prarit, qe-baseos-daemons, rhack, rlemosor
Target Milestone: betaKeywords: TestCaseNotNeeded, Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pigz-2.5-4.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-17 15:52:50 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2044387    

Description Jan Pazdziora 2021-05-04 20:04:32 UTC
Description of problem:

Running annocheck on pigz reports that binaries in /usr/bin were compiled without stack protector and without position independent code.

Version-Release number of selected component (if applicable):

pigz-2.5-2.el9.x86_64

How reproducible:

Deterministic

Steps to Reproduce:
1. rpm -ql pigz | xargs annocheck -v --ignore-gaps | grep FAIL:

Actual results:

Hardened: /usr/bin/unpigz: FAIL: pie test because not linked with -Wl,-pie 
Hardened: /usr/bin/unpigz: FAIL: bind-now test because not linked with -Wl,-z,now 
Hardened: /usr/bin/unpigz: FAIL: stack-prot test because stack protection deliberately disabled (addr range: 0x403580..0x403585) 
Hardened: /usr/bin/pigz: FAIL: pie test because not linked with -Wl,-pie 
Hardened: /usr/bin/pigz: FAIL: bind-now test because not linked with -Wl,-z,now 
Hardened: /usr/bin/pigz: FAIL: stack-prot test because stack protection deliberately disabled (addr range: 0x403580..0x403585) 

Expected results:

No FAILs reported by annocheck.

Additional info:

Comment 6 Jan Pazdziora 2021-10-05 20:11:29 UTC
Any reason why the Makefile sets its own flags rather than using the defaults from rpm macros, for example via %{optflags}, per https://developers.redhat.com/blog/2018/03/21/compiler-and-linker-flags-gcc?

Comment 7 Jan Pazdziora 2021-10-06 14:58:45 UTC
This document might also be useful: https://src.fedoraproject.org/rpms/redhat-rpm-config/blob/rawhide/f/buildflags.md.

I see that pigz.spec already does

  %make_build CFLAGS="$RPM_OPT_FLAGS"

so it might be just a matter of using

  %make_build CFLAGS="$RPM_OPT_FLAGS" LDFLAGS="$RPM_LD_FLAGS"

or

  %make_build CFLAGS="%{build_cflags}" LDFLAGS="%{build_ldflags}"

Comment 8 Prarit Bhargava 2021-10-06 17:58:40 UTC
(In reply to Jan Pazdziora from comment #7)
> This document might also be useful:
> https://src.fedoraproject.org/rpms/redhat-rpm-config/blob/rawhide/f/
> buildflags.md.
> 
> I see that pigz.spec already does
> 
>   %make_build CFLAGS="$RPM_OPT_FLAGS"
> 
> so it might be just a matter of using
> 
>   %make_build CFLAGS="$RPM_OPT_FLAGS" LDFLAGS="$RPM_LD_FLAGS"
> 
> or
> 
>   %make_build CFLAGS="%{build_cflags}" LDFLAGS="%{build_ldflags}"

Yep.  My above comment was kind of to myself :)

P.

Comment 9 Prarit Bhargava 2021-10-06 19:46:05 UTC
QE: This is a small change.  Before these changes,

[03:40 PM root@intel-purley-04 SPECS]# rpm -ivh pigz-2.5-3.el9.x86_64.rpm
[03:40 PM root@intel-purley-04 SPECS]# rpm -ql pigz | xargs annocheck -v --ignore-gaps | grep FAIL: | grep pigz

<snip>
Hardened: /usr/bin/pigz: FAIL: pie test because not built with '-Wl,-pie' (gcc/clang) or '-buildmode pie' (go) 
Hardened: /usr/bin/pigz: FAIL: bind-now test because not linked with -Wl,-z,now 
Hardened: /usr/bin/unpigz: FAIL: pie test because not built with '-Wl,-pie' (gcc/clang) or '-buildmode pie' (go) 
Hardened: /usr/bin/unpigz: FAIL: bind-now test because not linked with -Wl,-z,now 
<snip>

Note, you will see warnings from static /usr/lib/.build-id/ files.  These are okay.

After the change

[03:43 PM root@intel-purley-04 SPECS]# rpm -ivh pigz-2.5-4.el9.x86_64.rpm
[03:43 PM root@intel-purley-04 SPECS]# rpm -ql pigz | xargs annocheck -v --ignore-gaps | grep FAIL: | grep pigz

You will not see any warnings from /usr/bin/pigz.

QE can you set ITM and provide qa_ack?

Thanks,

P.

Comment 10 Prarit Bhargava 2021-10-11 23:21:51 UTC
QE?  ping?

P.

Comment 21 errata-xmlrpc 2022-05-17 15:52:50 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (new packages: pigz), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:3944