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 947022

Summary: postgresql package should be built with PIE flags
Product: [Fedora] Fedora Reporter: Dhiru Kholia <dkholia>
Component: postgresqlAssignee: Pavel Raiskup <praiskup>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: rawhideCC: bressers, databases-maint, devrim, dhiru, hhorak, jmlich, mcermak, moez.roy
Target Milestone: ---Keywords: FutureFeature, Security
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: postgresql-9.4.4-5.fc24 Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-09-17 11:13:07 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: 952946    
Bug Blocks: 1199775, 1092574    

Description Dhiru Kholia 2013-04-01 09:16:36 UTC
Description of problem:

http://fedoraproject.org/wiki/Packaging:Guidelines#PIE says that "you MUST enable the PIE compiler flags if your package is long running ...".

However, currently postgresql is not being built with PIE flags. This is a clear violation of the packaging guidelines.

This issue (in its wider scope) is being discussed at,

https://fedorahosted.org/fesco/ticket/1104

https://lists.fedoraproject.org/pipermail/devel/2013-March/180827.html

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

postgresql-server-9.2.3-1.fc19.x86_64.rpm

How reproducible:

You can use following programs to check if a package is hardened:

http://people.redhat.com/sgrubb/files/rpm-chksec

OR

https://github.com/kholia/checksec

Steps to Reproduce:

Get scanner.py from https://github.com/kholia/checksec

$ ./scanner.py postgresql-server-9.2.3-1.fc19.x86_64.rpm                         
...
postgresql-server,postgresql-server-9.2.3-1.fc19.x86_64.rpm,/usr/bin/postgres,NX=Enabled,CANARY=Enabled,RELRO=Partial,PIE=Disabled,RPATH=Disabled,RUNPATH=Disabled

 
Actual results:

/usr/bin/postgres has PIE disabled.

Expected results:

/usr/bin/postgres should have PIE enabled.

Comment 1 Dhiru Kholia 2013-04-01 09:19:35 UTC
Fixing the problem:

"_hardened_build" rpm spec macro can be used to harden a package.

For an example, see
http://pkgs.fedoraproject.org/cgit/clamav.git/tree/clamav.spec

Comment 2 Dhiru Kholia 2013-04-06 07:32:42 UTC
FWIW, other distributions ship PIE enabled postgresql 

https://bugs.launchpad.net/ubuntu/+source/postgresql-9.1/+bug/1039618

Comment 3 Tom Lane 2013-04-17 04:01:35 UTC
I'm concerned about the possible effects of this on the available address space in 32-bit mode: people tend to run Postgres with shared memory segments that are large enough that there's not huge amounts of address space available for ASLR to waste.  However, on my way to try to investigate how bad that issue might be in practice, I found out that there's significantly worse breakage that would have to be dealt with before we can even think about this: see bug #952946.

Comment 4 Fedora Admin XMLRPC Client 2013-05-09 14:06:44 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 5 Fedora Admin XMLRPC Client 2013-05-16 09:59:06 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 7 Pavel Raiskup 2014-04-30 05:30:27 UTC
*** Bug 1092552 has been marked as a duplicate of this bug. ***

Comment 8 Fedora End Of Life 2015-01-09 17:50:15 UTC
This message is a notice that Fedora 19 is now at end of life. Fedora 
has stopped maintaining and issuing updates for Fedora 19. It is 
Fedora's policy to close all bug reports from releases that are no 
longer maintained. Approximately 4 (four) weeks from now this bug will
be closed as EOL if it remains open with a Fedora 'version' of '19'.

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 19 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 9 Pavel Raiskup 2015-01-09 18:22:05 UTC
Adding keyword to keep this filled against Rawhide.

Comment 10 Pavel Raiskup 2015-09-17 09:11:45 UTC
(In reply to Tom Lane from comment #3)
> I'm concerned about the possible effects of this on the available address
> space in 32-bit mode: people tend to run Postgres with shared memory
> segments that are large enough that there's not huge amounts of address
> space available for ASLR to waste.

As PostgreSQL now uses shm_open() & mmap(), it seems to be OK even with ASLR.
From my testing, [heap] segment always grows against mmap()'ed segments, and
it may jump over segments with mmap'ed libraries, etc.. as shown in example
mapping in bug #1263974.  So the address space may be almost ideally
allocated ..

> However, on my way to try to investigate
> how bad that issue might be in practice, I found out that there's
> significantly worse breakage that would have to be dealt with before we can
> even think about this: see bug #952946.

As mentioned in cited bug #952946, this seems to be fixed in Kernel 4.1+, so
we should be OK to finally enable hardening -- I'll do so now.

Readers, please stop me if I missed something important.

Comment 12 Pavel Raiskup 2015-10-15 16:50:27 UTC
*** Bug 1211541 has been marked as a duplicate of this bug. ***