Solution: to resolve this issue, a corresponding custom policy module can be created and added to SELinux policy with the "audit2allow" tool.
Case: for example, consider the following AVC audit log, after invoking following command from a remote Windows host:
"tftp -i 192.168.0.120 PUT installed_apps.txt"
----------------------------------------------------------------------
Summary:
SELinux is preventing in.tftpd (tftpd_t) "search" to ./mnt (mnt_t).
Detailed Description:
SELinux denied access requested by in.tftpd. It is not expected that this access
is required by in.tftpd 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:
Sometimes labeling problems can cause SELinux denials. You could try to restore
the default system file context for ./mnt,
restorecon -v './mnt'
If this does not work, there is currently no automatic way to allow this access.
Instead, you can generate a local policy module to allow this access - see FAQ
(http://fedora.redhat.com/docs/selinux-faq-fc5/#id2961385) Or you can disable
SELinux protection altogether. Disabling SELinux protection is not recommended.
Please file a bug report (http://bugzilla.redhat.com/bugzilla/enter_bug.cgi)
against this package.
Additional Information:
Source Context system_u:system_r:tftpd_t:s0-s0:c0.c1023
Target Context system_u:object_r:mnt_t:s0
Target Objects ./mnt [ dir ]
Source in.tftpd
Source Path /usr/sbin/in.tftpd
Port
Host efe1272.efe
Source RPM Packages tftp-server-0.49-1.fc10
Target RPM Packages filesystem-2.4.19-1.fc10
Policy RPM selinux-policy-3.5.13-74.fc10
Selinux Enabled True
Policy Type targeted
MLS Enabled True
Enforcing Mode Enforcing
Plugin Name catchall_file
Host Name efe1272.efe
Platform Linux efe1272.efe 2.6.27.41-170.2.117.fc10.i686 #1
SMP Thu Dec 10 11:00:29 EST 2009 i686 i686
Alert Count 25
First Seen Mon 12 Mar 2012 09:21:50 AM CET
Last Seen Mon 12 Mar 2012 01:30:02 PM CET
Local ID e48f9047-a5b0-4f62-8510-d57f015c60c1
Line Numbers
Raw Audit Messages
node=efe1272.efe type=AVC msg=audit(1331555402.558:42): avc: denied { search } for pid=12268 comm="in.tftpd" name="mnt" dev=sda3 ino=1036321 scontext=system_u:system_r:tftpd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:mnt_t:s0 tclass=dir
node=efe1272.efe type=SYSCALL msg=audit(1331555402.558:42): arch=40000003 syscall=12 success=no exit=-13 a0=bfe35e81 a1=1 a2=4f5dec4a a3=bfe34734 items=0 ppid=2289 pid=12268 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="in.tftpd" exe="/usr/sbin/in.tftpd" subj=system_u:system_r:tftpd_t:s0-s0:c0.c1023 key=(null)
By running "audit2allow" on above alert and reviewing the resultant "mntfixlocal.te" policy file will show us (as root):
---------------------------------------------------------------------------
# grep mnt_t /var/log/audit/audit.log | audit2allow -M mntfixlocal
******************** IMPORTANT ***********************
To make this policy package active, execute:
semodule -i mntfixlocal.pp
# cat mntfixlocal.te
module mntfixlocal 1.0;
require {
type tftpd_t;
type mnt_t;
class dir search;
}
#============= tftpd_t ==============
allow tftpd_t mnt_t:dir search;
----------------------------------------------------------
To compile and load this policy module invoke following command (as root):
-----------------------------------------------------------
# semodule -i mntfixlocal.pp
-----------------------------------------------------------
To make sure that the custom policy module is activated, look for any policies regarding "tftpd_t" and "mnt_t" (as user):
-----------------------------------------------------------
$ sesearch -A | grep tftpd_t | grep mnt_t
WARNING: This policy contained disabled aliases; they have been removed.
allow tftpd_t mnt_t : dir search ;
------------------------------------------------------------
Alternatively, we can edit the custom policy module .te file to prevent auditing of such alert whilst still allowing SELinux to continue preventing access. We do this by changing the "allow" line to "dontaudit":
------------------------------------------------------------
#============= tftpd_t ==============
dontaudit tftpd_t mnt_t:dir search;
------------------------------------------------------------
This way we can change any alerts to custom policy modules and add them to SELinux policy.
Finally our custom policy module will be shown as follows (as user):
-----------------------------------------------------------
$ sesearch -A | grep tftpd_t | grep vmblock_t
WARNING: This policy contained disabled aliases; they have been removed.
allow tftpd_t vmblock_t : file { read write create getattr } ;
allow tftpd_t vmblock_t : dir { write add_name search } ;
-------------------------------------------------------------
Source: http://wiki.centos.org/HowTos/SELinux
and also: http://serverfault.com/questions/106007/tftp-uploads-failing