Bug 799221 - Allow PostgreSQL to talk to self over dblink -- AVC denial
Summary: Allow PostgreSQL to talk to self over dblink -- AVC denial
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy-targeted
Version: 16
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-03-02 07:22 UTC by Jan Pazdziora (Red Hat)
Modified: 2012-03-24 00:36 UTC (History)
1 user (show)

Fixed In Version: selinux-policy-3.10.0-80.fc16
Clone Of:
Environment:
Last Closed: 2012-03-24 00:36:26 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Jan Pazdziora (Red Hat) 2012-03-02 07:22:16 UTC
Description of problem:

When dblink is used with no host specified, PostgreSQL server tries to connect to itself over the socket in /tmp. It leads to AVC denial.

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

# rpm -q selinux-policy postgresql-server postgresql-contrib
selinux-policy-3.10.0-75.fc16.noarch
postgresql-server-9.1.2-2.fc16.i686
postgresql-contrib-9.1.2-2.fc16.i686

How reproducible:

Deterministic.

Steps to Reproduce:
1. # yum install -y postgresql-server postgresql-contrib
2. # postgresql-setup initdb
3. # service postgresql start
4. # su - postgres
5. $ psql
6. postgres=# create extension dblink;
7. postgres=# select * from dblink('dbname=' || current_database(), 'select 1') as x(i numeric);
8. # grep AVC /var/log/audit/audit.log
  
Actual results:

postgres=# select * from dblink('dbname=' || current_database(), 'select 1') as x(i numeric);;
ERROR:  could not establish connection
DETAIL:  could not connect to server: Permission denied
	Is the server running locally and accepting
	connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

type=AVC msg=audit(1330672651.814:210): avc:  denied  { connectto } for  pid=7075 comm="postgres" path="/tmp/.s.PGSQL.5432" scontext=system_u:system_r:postgresql_t:s0 tcontext=system_u:system_r:postgresql_t:s0 tclass=unix_stream_socket

Expected results:

postgres=# select * from dblink('dbname=' || current_database(), 'select 1') as x(i numeric);
 i 
---
 1
(1 row)

which you get when you switch to permissive, and no AVC denial.

Additional info:

In Spacewalk SELinux policy, adding

optional_policy(`
        gen_require(`
                type postgresql_t;
        ')
        allow postgresql_t self:unix_stream_socket { connectto };
')

fixed the problem for us on RHEL 5, 6, Fedora 15, 16.

Comment 1 Miroslav Grepl 2012-03-02 08:40:13 UTC
commit 659cb46cd208fa1750ea930847bf75dbb28355ec
Author: Miroslav Grepl <mgrepl>
Date:   Fri Mar 2 10:33:24 2012 +0000

    Make PostgreSQL working when dblink is used with no host specified


Also added to RHEL.

Comment 2 Fedora Update System 2012-03-13 12:25:13 UTC
selinux-policy-3.10.0-80.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/FEDORA-2012-2733/selinux-policy-3.10.0-80.fc16

Comment 3 Fedora Update System 2012-03-21 02:24:18 UTC
Package selinux-policy-3.10.0-80.fc16:
* should fix your issue,
* was pushed to the Fedora 16 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing selinux-policy-3.10.0-80.fc16'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-2733/selinux-policy-3.10.0-80.fc16
then log in and leave karma (feedback).

Comment 4 Fedora Update System 2012-03-24 00:36:26 UTC
selinux-policy-3.10.0-80.fc16 has been pushed to the Fedora 16 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.