sched_setscheduler()
I am having some problems with asterisk (the VOIP server).
According to strace it does the following:sched_setscheduler(0, SCHED_OTHER, { 0 }) = -1 EACCES (Permission denied)
This failure happens in enforcing mode but not in permissive mode, however nothing is audited!
I have attached the relevant section of strace output as asterisk.strace.
I wrote a little test program (attached as test.c) which seems to never fail.
The asterisk policy I've written is attached, and the following needs to be added to net_contexts:
ifdef(asterisk.te',
portcon tcp 1720 system_u:object_r:asterisk_port_t portcon tcp 2000 system_u:object_r:asterisk_port_t portcon udp 2427 system_u:object_r:asterisk_port_t portcon udp 4569 system_u:object_r:asterisk_port_t portcon udp 5060 system_u:object_r:asterisk_port_t ')
Signature · 4 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page
setsid() = 2560
chdir("/") = 0
open("/dev/null", O_RDWR) = 3
fstat64(3, {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 3), ...}) = 0
dup2(3, 0) = 0
dup2(3, 1) = 1
dup2(3, 2) = 2
close(3) = 0unlink("/var/run/asterisk/asterisk.pid") = 0 open("/var/run/asterisk/asterisk.pid", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3getpid() = 2560fstat64(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40018000
write(3, "2560\n", 5) = 5 close(3) = 0 munmap(0x40018000, 4096) = 0
unlink("/var/run/asterisk/asterisk.ctl") = 0socket(PF_FILE, SOCK_STREAM, 0) = 3bind(3, {sa_family=AF_FILE, path="/var/run/asterisk/asterisk.ctl"}, 110) = 0listen(3, 2) = 0mmap2(NULL, 8392704, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40207000mprotect(0x40207000, 4096, PROT_NONE) = 0
clone(child_stack=0x40a07b48, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|CLONE_DETACHED, parent_tidptr=0x40a07bf8, {entry_number:6, base_addr:0x40a07bb0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}, child_tidptr=0x40a07bf8) = 2561 rt_sigprocmask(SIG_BLOCK, [HUP INT PIPE TERM WINCH], NULL, 8) = 0rt_sigaction(SIGURG, {0x80751b8, [URG], SA_RESTART}, {SIG_DFL}, 8) = 0rt_sigaction(SIGINT, {0x8075878, [INT], SA_RESTART}, {SIG_DFL}, 8) = 0rt_sigaction(SIGTERM, {0x8075878, [TERM], SA_RESTART}, {SIG_DFL}, 8) = 0rt_sigaction(SIGHUP, {0x80751f0, [HUP], SA_RESTART}, {SIG_DFL}, 8) = 0rt_sigaction(SIGCHLD, {0x807523c, [CHLD], SA_RESTART}, {SIG_DFL}, 8) = 0rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_DFL}, 8) = 0sched_setscheduler(0, SCHED_OTHER, { 0 }) = -1 EACCES (Permission denied)time([1087655102]) = 1087655102open("/etc/localtime", O_RDONLY) = 4fstat64(4, {st_mode=S_IFREG|0644, st_size=785, ...}) = 0mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40a08000read(4, "TZif\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\0\0\0\4\0"..., 4096) = 785
close(4) = 0munmap(0x40a08000, 4096) = 0fstat64(1, {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 3), ...}) = 0ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfffd20c) = -1 ENOTTY (Inappropriate ioctl for device)mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40a08000write(1, "Unable to set normal priority\n", 30) = 30munmap(0x40a08000, 4096) = 0exit_group(1) = ?
#include <sched.h>
#include <stdio.h>
#include <string.h>
int main()
{
struct sched_param p;
memset(&p, 0, sizeof(p));
printf("return:%d\n", sched_setscheduler(0, SCHED_OTHER, &p)); return 0;
}
# asterisk /usr/sbin/asterisk -- system_u:object_r:asterisk_exec_t /var/run/asterisk(/.*)? system_u:object_r:asterisk_var_run_t /etc/asterisk(/.*)? system_u:object_r:asterisk_etc_t /var/log/asterisk(/.*)? system_u:object_r:asterisk_log_t /var/lib/asterisk(/.*)? system_u:object_r:asterisk_var_lib_t /var/spool/asterisk(/.*)? system_u:object_r:asterisk_spool_t
#DESC Asterisk IP telephony server
#
# Author: Russell Coker <[email protected]>
#
# X-Debian-Packages: asterisk
type asterisk_port_t, port_type;
daemon_domain(asterisk)
allow asterisk_t asterisk_var_run_t:{ sock_file fifo_file } create_file_perms; allow initrc_t asterisk_var_run_t:fifo_file unlink;
etcdir_domain(asterisk)logdir_domain(asterisk)var_lib_domain(asterisk)
allow asterisk_t asterisk_port_t:{ udp_socket tcp_socket } name_bind;
allow asterisk_t device_t:lnk_file read;
allow asterisk_t sound_device_t:chr_file rw_file_perms;
type asterisk_spool_t, file_type, sysadmfile;rw_dir_create_file(asterisk_t, asterisk_spool_t)
allow asterisk_t var_spool_t:dir search;
can_network(asterisk_t)
allow asterisk_t etc_t:file { getattr read };
allow asterisk_t self:unix_stream_socket { connectto create_stream_socket_perms };
# for /var/run/asterisk allow asterisk_t self:capability dac_override;
Quoted 7 lines · Russell Coker
I am having some problems with asterisk (the VOIP server).
According to strace it does the following:
sched_setscheduler(0, SCHED_OTHER, { 0 })= -1 EACCES (Permission denied)This failure happens in enforcing mode but not in permissive mode, however nothing is audited!
setschedluler denials are not audited by the kernel, as doing so causes a deadlock with printk (the kernel logging function). I believe this can be fixed with an asynchronous feature of the new audit framework, but am not sure if it's been looked into.
- James
Signature · 9 lines
James Morris <[email protected]> -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 4 lines · James Morris
setschedluler denials are not audited by the kernel, as doing so causes a deadlock with printk (the kernel logging function). I believe this can be fixed with an asynchronous feature of the new audit framework, but am not sure if it's been looked into.
I haven't looked into it. We could add a flag to the avc_audit_data to indicate that avc_audit() should call audit_log_end_irq() rather than audit_log_end().
Signature · 8 lines
Stephen Smalley <[email protected]> National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 9 lines · Stephen Smalley
Quoted 4 lines · James Morris
setschedluler denials are not audited by the kernel, as doing so causes a deadlock with printk (the kernel logging function). I believe this can be fixed with an asynchronous feature of the new audit framework, but am not sure if it's been looked into.
I haven't looked into it. We could add a flag to the
avc_audit_datato indicate thatavc_audit()should callaudit_log_end_irq()rather thanaudit_log_end().
Or a wrapper function, avc_audit_async().
- James
Signature · 9 lines
James Morris <[email protected]> -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.