Bug 564277 - SELinux is preventing /usr/sbin/dnsmasq "setattr" access on /var/log/dnsmasq.
Summary: SELinux is preventing /usr/sbin/dnsmasq "setattr" access on /var/log/dns...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 14
Hardware: x86_64
OS: Linux
low
medium
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard: setroubleshoot_trace_hash:b67107cbf46...
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-02-12 08:25 UTC by Sandro
Modified: 2010-12-13 20:12 UTC (History)
7 users (show)

Fixed In Version: selinux-policy-3.9.7-16.fc14
Clone Of:
Environment:
Last Closed: 2010-12-13 20:12:41 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Sandro 2010-02-12 08:25:20 UTC
Summary:

SELinux is preventing /usr/sbin/dnsmasq "setattr" access on /var/log/dnsmasq.

Detailed Description:

[SELinux is in permissive mode. This access was not denied.]

SELinux denied access requested by dnsmasq. It is not expected that this access
is required by dnsmasq and this access may signal an intrusion attempt. It is
also possible that the specific version or configuration of the application is
causing it to require additional access.

Allowing Access:

You can generate a local policy module to allow this access - see FAQ
(http://docs.fedoraproject.org/selinux-faq-fc5/#id2961385) Please file a bug
report.

Additional Information:

Source Context                unconfined_u:system_r:dnsmasq_t:s0
Target Context                system_u:object_r:var_log_t:s0
Target Objects                /var/log/dnsmasq [ file ]
Source                        dnsmasq
Source Path                   /usr/sbin/dnsmasq
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           dnsmasq-2.51-1.fc12
Target RPM Packages           
Policy RPM                    selinux-policy-3.6.32-84.fc12
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Permissive
Plugin Name                   catchall
Host Name                     (removed)
Platform                      Linux (removed)
                              2.6.31.12-174.2.3.fc12.x86_64 #1 SMP Mon Jan 18
                              19:52:07 UTC 2010 x86_64 x86_64
Alert Count                   8
First Seen                    Mon 08 Feb 2010 11:57:08 PM CET
Last Seen                     Fri 12 Feb 2010 09:18:50 AM CET
Local ID                      6441645b-7dea-44db-9e8d-af03b6f65654
Line Numbers                  

Raw Audit Messages            

node=(removed) type=AVC msg=audit(1265962730.699:64070): avc:  denied  { setattr } for  pid=4184 comm="dnsmasq" name="dnsmasq" dev=dm-1 ino=1443 scontext=unconfined_u:system_r:dnsmasq_t:s0 tcontext=system_u:object_r:var_log_t:s0 tclass=file

node=(removed) type=AVC msg=audit(1265962730.699:64070): avc:  denied  { chown } for  pid=4184 comm="dnsmasq" capability=0 scontext=unconfined_u:system_r:dnsmasq_t:s0 tcontext=unconfined_u:system_r:dnsmasq_t:s0 tclass=capability

node=(removed) type=SYSCALL msg=audit(1265962730.699:64070): arch=c000003e syscall=93 success=yes exit=0 a0=a a1=63 a2=ffffffff a3=418 items=0 ppid=4183 pid=4184 auid=500 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=1 comm="dnsmasq" exe="/usr/sbin/dnsmasq" subj=unconfined_u:system_r:dnsmasq_t:s0 key=(null)



Hash String generated from  catchall,dnsmasq,dnsmasq_t,var_log_t,file,setattr
audit2allow suggests:

#============= dnsmasq_t ==============
allow dnsmasq_t self:capability chown;
allow dnsmasq_t var_log_t:file setattr;

Comment 1 Sandro 2010-02-12 08:33:32 UTC
I get this together with bug 564276 whenever I (re)start dnsmasq.

# /sbin/service dnsmasq restart

I use dnsmasq as a local name server and have it reload its configuration triggered by NetworkManager changing the network connection.

Comment 2 Daniel Walsh 2010-02-12 14:25:23 UTC
Did you setup special logging in dnsmasq?  It looks like it wants to create a log file named /var/log/dnsmasq?

Comment 3 Daniel Walsh 2010-02-12 14:32:46 UTC
Miroslav add

type dnsmasq_var_log_t;
logging_log_file(dnsmasq_var_log_t)


manage_files_pattern(dnsmasq_t, dnsmasq_var_log_t, dnsmasq_var_log_t)
logging_log_filetrans(dnsmasq_t, dnsmasq_var_log_t, file)


/var/log/dnsmasq\.log			gen_context(system_u:object_r:dnsmasq_var_log_t,s0)

Comment 4 Daniel Walsh 2010-02-12 14:35:51 UTC
We might need to add the following also.

#============= dnsmasq_t ==============
allow dnsmasq_t self:capability dac_override; 

#============= dnsmasq_t ==============
allow dnsmasq_t self:capability chown;

Comment 5 Miroslav Grepl 2010-02-12 16:25:40 UTC
Fixed in selinux-policy-3.6.32-90.fc12

Comment 6 Sandro 2010-02-12 22:06:50 UTC
(In reply to comment #2)

I have log-facility=/var/log/dnsmasq in /etc/dnsmasq.conf. I believe I set this up when I was debugging the setup. According to the man page, dnsmasq, by default, sends its log messages to the DAEMON facility of syslog.

If I remember correctly, I created the log file my self.

# ls -lZ /var/log/dnsmasq
-rw-r-----. nobody root system_u:object_r:var_log_t:s0   /var/log/dnsmasq

Comment 7 Daniel Walsh 2010-02-13 14:27:42 UTC
Well it is probably best if you turn it off.

Comment 8 Fedora Update System 2010-02-23 20:55:29 UTC
selinux-policy-3.6.32-92.fc12 has been submitted as an update for Fedora 12.
http://admin.fedoraproject.org/updates/selinux-policy-3.6.32-92.fc12

Comment 9 Fedora Update System 2010-02-26 03:42:06 UTC
selinux-policy-3.6.32-92.fc12 has been pushed to the Fedora 12 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update selinux-policy'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F12/FEDORA-2010-2953

Comment 10 Fedora Update System 2010-03-04 00:10:51 UTC
selinux-policy-3.6.32-92.fc12 has been pushed to the Fedora 12 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 11 Sandro 2010-12-03 08:40:47 UTC
Looks like this had been fixed previously.

I usually do 'sudo service dnsmasq restart' and get this AVC. This a clean install of F14 and I already tried autorelabel to no avail.

Comment 12 Miroslav Grepl 2010-12-03 10:45:21 UTC
Sandro,
you mean you are seeing the same AVC messages which are mentioned in the comment #1 ?

# rpm -q selinux-policy


My the latest F14 policy has

# sesearch -A -s dnsmasq_t -t dnsmasq_t -c capability
Found 2 semantic av rules:
   allow dnsmasq_t dnsmasq_t : capability { chown dac_override setgid setuid net_bind_service net_admin net_raw } ; 
   allow dnsmasq_t dnsmasq_t : capability net_bind_service ;

# rpm -q selinux-policy
selinux-policy-3.9.7-14.fc14.noarch

# matchpathcon /var/log/dnsmasq.log
/var/log/dnsmasq.log	system_u:object_r:dnsmasq_var_log_t:s0

Comment 13 Sandro 2010-12-05 00:19:21 UTC
I used the SELinux Security Alert "Report this Bug..." button and it happened to attach my report to this bug. The exact message is:


Summary:

SELinux is preventing /usr/sbin/dnsmasq "setattr" access on /var/log/dnsmasq.

Detailed Description:

SELinux denied access requested by dnsmasq. It is not expected that this access
is required by dnsmasq and this access may signal an intrusion attempt. It is
also possible that the specific version or configuration of the application is
causing it to require additional access.

Allowing Access:

You can generate a local policy module to allow this access - see FAQ
(http://docs.fedoraproject.org/selinux-faq-fc5/#id2961385) Please file a bug
report.

Additional Information:

Source Context                system_u:system_r:dnsmasq_t:s0
Target Context                system_u:object_r:var_log_t:s0
Target Objects                /var/log/dnsmasq [ file ]
Source                        dnsmasq
Source Path                   /usr/sbin/dnsmasq
Port                          <Unknown>
Host                          gethen.penguinpee.nl
Source RPM Packages           dnsmasq-2.52-1.fc13
Target RPM Packages           
Policy RPM                    selinux-policy-3.9.7-12.fc14
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Plugin Name                   catchall
Host Name                     gethen.penguinpee.nl
Platform                      Linux gethen.penguinpee.nl 2.6.35.6-48.fc14.x86_64
                              #1 SMP Fri Oct 22 15:36:08 UTC 2010 x86_64 x86_64
Alert Count                   3
First Seen                    Tue 23 Nov 2010 01:51:33 PM CET
Last Seen                     Tue 30 Nov 2010 08:03:45 PM CET
Local ID                      1e66dccc-0078-47e7-9ce3-613a2248a628
Line Numbers                  

Raw Audit Messages            

node=gethen.penguinpee.nl type=AVC msg=audit(1291143825.520:10): avc:  denied  { setattr } for  pid=1854 comm="dnsmasq" name="dnsmasq" dev=dm-2 ino=524812 scontext=system_u:system_r:dnsmasq_t:s0 tcontext=system_u:object_r:var_log_t:s0 tclass=file

node=gethen.penguinpee.nl type=SYSCALL msg=audit(1291143825.520:10): arch=c000003e syscall=93 success=no exit=-13 a0=a a1=63 a2=ffffffff a3=418 items=0 ppid=1 pid=1854 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="dnsmasq" exe="/usr/sbin/dnsmasq" subj=system_u:system_r:dnsmasq_t:s0 key=(null)

Comment 14 Miroslav Grepl 2010-12-06 12:01:23 UTC
Ok, then the situation is the same as in the comment #6, #7.

# restorecon -R -v /var/log/dnsmasq

or 

you turn it off.

Comment 15 Sandro 2010-12-06 13:40:55 UTC
restorecon doesn't change the context of the log file (system_u:object_r:var_log_t:s0). Since logging to a file is a configurable option in dnsmasq, I presume it should be able to take what ever action is necessary to be able to do so.

How do other applications handle this situation? I know, for one, that vsftpd allows you to choose logging to a file or to syslog.

Comment 16 Miroslav Grepl 2010-12-06 14:05:10 UTC
Ok, the problem is you created the log file by hand and it got "var_log_t" label. 

We define the label for "/var/log/dnsmasq.log" file in policy. This is why restorecon does not work. 

So you can change the label for now using

# chcon -t dnsmasq_var_log_t /var/log/dnsmasq

or rename the log to dnsmasq.log and run restorecon.


If you create a new log file with the different name by hand, you will need to setup the label for it. 

The situation would be easier if the default directory existed for customized log files.

Comment 17 Miroslav Grepl 2010-12-06 14:08:42 UTC
I have fixed the labeling which will cover /var/log/dnsmasq* log files in selinux-policy-3.9.7-15.fc14.

Comment 18 Sandro 2010-12-06 14:42:08 UTC
Thanks for putting this in selinux-policy. How coud I have found out about the rule for /var/log/dnsmasq.log myself?

About having a default place for dnsmasq to put its logfile: I believe this could very easily be achieved by the package maintainer providing a dnsmasq directory in /var/log and patching the configuration.

Comment 19 Fedora Update System 2010-12-10 13:54:33 UTC
selinux-policy-3.9.7-16.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/selinux-policy-3.9.7-16.fc14

Comment 20 Fedora Update System 2010-12-10 20:28:59 UTC
selinux-policy-3.9.7-16.fc14 has been pushed to the Fedora 14 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update selinux-policy'.  You can provide feedback for this update here: https://admin.fedoraproject.org/updates/selinux-policy-3.9.7-16.fc14

Comment 21 Fedora Update System 2010-12-13 20:11:41 UTC
selinux-policy-3.9.7-16.fc14 has been pushed to the Fedora 14 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.