Skip to contentSkip to conversation

hal - create netlink socket

PATCH In review Ivan Gyurdiev 3 participants 11 messages Mar 27, 2005 – Apr 4, 2005 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hal - create netlink socket

Makes hal work again on my system....sort of

/usr/libexec/hald-probe-input denied { read } on mouse_device_t:chr_file /usr/libexec/hald-addon-acpi denied { write } on acpid.socket (apmd_var_run_t)
/usr/libexec/hald-add-selinux-mount-option denied { search } on /selinux (security_t)
/usr/sbin/hald denied { getattr } on /dev/mapper/control (lvm_control_t) /usr/sbin/dmidecode denied { read } on /dev/mem (memory_device_t)

Signature · 2 lines
Ivan Gyurdiev <[email protected]>
Cornell University
domains/program/hald.te +1 -0
diff -aur policy.old/domains/program/hald.te policy/domains/program/hald.te
@@ -31,6 +31,7 @@
 allow hald_t usr_t:file { getattr read };
 
 allow hald_t bin_t:file getattr;
+allow hald_t self:netlink_socket create_socket_perms;
 allow hald_t self:netlink_route_socket r_netlink_socket_perms;
 allow hald_t self:capability { net_admin sys_admin dac_override dac_read_search mknod };
 can_network_server(hald_t)
#1 lore raw
Quoted 9 lines · Ivan Gyurdiev

Makes hal work again on my system....sort of

/usr/libexec/hald-probe-input denied { read } on mouse_device_t:chr_file /usr/libexec/hald-addon-acpi denied { write } on acpid.socket (apmd_var_run_t)
/usr/libexec/hald-add-selinux-mount-option denied { search } on /selinux (security_t)
/usr/sbin/hald denied { getattr } on /dev/mapper/control (lvm_control_t) /usr/sbin/dmidecode denied { read } on /dev/mem (memory_device_t)

Class 'netlink_socket' is the catch-all for netlink protocols that have no individual security class. Can you remove this permission from your policy and enable syscall auditing via auditctl (or boot with audit=1) and try again so we can see the actual netlink protocol value that was used?

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.
#2 lore raw
Quoted 11 lines · Stephen Smalley
Quoted 9 lines · Ivan Gyurdiev

Makes hal work again on my system....sort of

/usr/libexec/hald-probe-input denied { read } on mouse_device_t:chr_file /usr/libexec/hald-addon-acpi denied { write } on acpid.socket (apmd_var_run_t)
/usr/libexec/hald-add-selinux-mount-option denied { search } on /selinux (security_t)
/usr/sbin/hald denied { getattr } on /dev/mapper/control (lvm_control_t) /usr/sbin/dmidecode denied { read } on /dev/mem (memory_device_t)

Quoted 5 lines

Class 'netlink_socket' is the catch-all for netlink protocols that have no individual security class. Can you remove this permission from your policy and enable syscall auditing via auditctl (or boot with audit=1) and try again so we can see the actual netlink protocol value that was used?

Interesting, I hadn't actually used auditd until now. Is the daemon supposed to be on or off by default?

type=DAEMON msg=auditd(1112025664) auditd start, ver=0.6.9, format=raw, pid=2130, uid=0
type=KERNEL msg=audit(1112025664.871:799895): syscall=102 exit=48 a0=b a1=bfeb0150 a2=8050248 a3=0 items=0 pid=2130 loginuid=-1 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0
type=KERNEL msg=audit(1112025664.871:799895): audit_enabled=1 old=1 type=KERNEL msg=audit(1112025664.667:799550): syscall=102 exit=48 a0=b a1=bfeafc60 a2=8050248 a3=0 items=0 pid=2130 loginuid=-1 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0
type=KERNEL msg=audit(1112025683.444:848288): syscall=125 exit=-13 a0=bfb76000 a1=1000 a2=1000007 a3=f8c000 items=0 pid=2355 loginuid=-1 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 type=KERNEL msg=audit(1112025683.444:848288): avc: denied { execmem } for pid=2355 comm=httpd scontext=system_u:system_r:httpd_t tcontext=system_u:system_r:httpd_t tclass=process type=KERNEL msg=audit(1112025688.522:863505): syscall=102 exit=-13 a0=1 a1=bfa3acf0 a2=80712ac a3=8075a60 items=0 pid=2512 loginuid=-1 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 type=KERNEL msg=audit(1112025688.522:863505): avc: denied { create } for pid=2512 exe=/usr/sbin/hald scontext=system_u:system_r:hald_t tcontext=system_u:system_r:hald_t tclass=netlink_socket

Signature · 8 lines
Ivan Gyurdiev <[email protected]>
Cornell University


--
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.
#3 lore raw
Quoted 2 lines · Ivan Gyurdiev

Interesting, I hadn't actually used auditd until now. Is the daemon supposed to be on or off by default?

If the daemon is disabled, then the audit messages just get handled by klogd (-> syslogd -> /var/log/messages) by default. The important thing is to enable syscall auditing via the audit=1 kernel boot parameter or /sbin/auditctl -e 1. BTW we need policy for auditctl. Similar to auditd, but should be able to access the tty (and auditd shouldn't be allowed to do that).

Quoted 6 lines

type=KERNEL msg=audit(1112025688.522:863505): syscall=102 exit=-13 a0=1 a1=bfa3acf0 a2=80712ac a3=8075a60 items=0 pid=2512 loginuid=-1 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 type=KERNEL msg=audit(1112025688.522:863505): avc: denied { create } for pid=2512 exe=/usr/sbin/hald scontext=system_u:system_r:hald_t tcontext=system_u:system_r:hald_t tclass=netlink_socket

Ah, we don't get the desired information because it is being passed by address for the socketcall multiplexer. Maybe run hald under strace (in permissive mode, of course).

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.
#4 lore raw
Quoted 4 lines

Ah, we don't get the desired information because it is being passed by address for the socketcall multiplexer. Maybe run hald under strace (in permissive mode, of course).

Does this help?

socket(PF_NETLINK, SOCK_DGRAM, 15) = 7
getpid() = 4076
bind(7, {sa_family=AF_NETLINK, pid=4076, groups=ffffffff}, 12) = -1 EPERM (Operation not permitted)
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb7fd1000
write(1, "*** [DIE] osspec.c:osspec_init()"..., 72) = 72
munmap(0xb7fd1000, 4096) = 0
exit_group(1) =

Signature · 8 lines
Ivan Gyurdiev <[email protected]>
Cornell University


--
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.
#5 lore raw
Quoted 7 lines · Ivan Gyurdiev
Quoted 3 lines

Ah, we don't get the desired information because it is being passed by address for the socketcall multiplexer. Maybe run hald under strace (in permissive mode, of course).

Does this help?

socket(PF_NETLINK, SOCK_DGRAM, 15) = 7

Yes. Per include/linux/netlink.h, protocol 15 is NETLINK_KOBJECT_UEVENT, which is used by lib/kobject_uevent.c. Looks like it is purely a kernel-to-userspace notification mechanism, so we might want a separate class for it to allow access to such notifications but we don't need any nlmsg_read/write checking for it. James, what do you think? In the meantime, you can allow hald access to netlink_socket in the policy, but we'll ultimately want to replace that with a finer- grained rule once the new class is in place.

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.
#6 lore raw
Quoted 9 lines · Stephen Smalley
Quoted 7 lines · Ivan Gyurdiev
Quoted 3 lines

Ah, we don't get the desired information because it is being passed by address for the socketcall multiplexer. Maybe run hald under strace (in permissive mode, of course).

Does this help?

socket(PF_NETLINK, SOCK_DGRAM, 15) = 7

Quoted 8 lines

Yes. Per include/linux/netlink.h, protocol 15 is NETLINK_KOBJECT_UEVENT, which is used by lib/kobject_uevent.c. Looks like it is purely a kernel-to-userspace notification mechanism, so we might want a separate class for it to allow access to such notifications but we don't need any nlmsg_read/write checking for it. James, what do you think? In the meantime, you can allow hald access to netlink_socket in the policy, but we'll ultimately want to replace that with a finer- grained rule once the new class is in place.

What about all the other denials?

That last one violates an assertion if allowed.

/usr/libexec/hald-probe-input denied { read } on mouse_device_t:chr_file /usr/libexec/hald-addon-acpi denied { write } on acpid.socket (apmd_var_run_t)
/usr/libexec/hald-add-selinux-mount-option denied { search } on /selinux (security_t)
/usr/sbin/hald denied { getattr } on /dev/mapper/control (lvm_control_t) /usr/sbin/dmidecode denied { read } on /dev/mem (memory_device_t)

Signature · 8 lines
Ivan Gyurdiev <[email protected]>
Cornell University


--
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.
#7 lore raw
Quoted 9 lines · Ivan Gyurdiev

What about all the other denials?

That last one violates an assertion if allowed.

/usr/libexec/hald-probe-input denied { read } on mouse_device_t:chr_file /usr/libexec/hald-addon-acpi denied { write } on acpid.socket (apmd_var_run_t)
/usr/libexec/hald-add-selinux-mount-option denied { search } on /selinux (security_t)

These look reasonable to allow, given the assumed purpose of the corresponding hald helper. I'd expect that you'll also get other denials once you allow these permissions, e.g. to allow the Unix domain connection or send, and to allow checking for a specific file under /selinux.

Quoted 2 lines

/usr/sbin/hald denied { getattr } on /dev/mapper/control (lvm_control_t) /usr/sbin/dmidecode denied { read } on /dev/mem (memory_device_t)

I don't know about these, and the last one is of course a definite concern.

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.
#8 lore raw

hal - denials

Ok, here is what hald required to stop complaining. Which ones should be dontaudit? I take it you won't like allowing hald to write to /selinux, and read /dev/mem.

re: dmidecode -
dmidecode decodes the DMI data present in x86 and IA64 BIOS's.

Can't that be made to run in its own domain?

diff -aur policy.old/domains/program/hald.te policy/domains/program/hald.te
--- policy.old/domains/program/hald.te 2005-04-02 17:37:37.000000000 -0500
+++ policy/domains/program/hald.te 2005-04-02 18:06:02.000000000
-0500
@@ -43,6 +43,7 @@
allow hald_t event_device_t:chr_file { getattr read ioctl }; allow hald_t printer_device_t:chr_file rw_file_perms; allow hald_t urandom_device_t:chr_file read;
+allow hald_t mouse_device_t:chr_file { read ioctl };

ifdef(updfstab.te',
domain_auto_trans(hald_t, updfstab_exec_t, updfstab_t)
@@ -73,3 +74,20 @@
tmp_domain(hald)
allow hald_t mnt_t:dir search;
r_dir_file(hald_t, proc_net_t)
+
+# For /usr/libexec/hald-add-selinux-mount-option
+allow hald_t security_t:dir search;
+allow hald_t security_t:file { read write };
+allow hald_t security_t:security check_context;
+
+# For /usr/libxexc/hald-addon-acpi - writes to /var/run/acpid.socket +allow hald_t apmd_var_run_t:sock_file write;
+allow hald_t apmd_t:unix_stream_socket connectto;
+
+# For /usr/sbin/dmidecode
+# Violates assertion
+#allow hald_t memory_device_t:chr_file read;
+allow hald_t self:capability sys_rawio;
+
+# ??
+allow hald_t lvm_control_t:chr_file getattr;

Signature · 8 lines
Ivan Gyurdiev <[email protected]>
Cornell University


--
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.
#9 lore raw

Re: hal - denials

Quoted 3 lines · Ivan Gyurdiev

Ok, here is what hald required to stop complaining. Which ones should be dontaudit? I take it you won't like allowing hald to write to /selinux, and read /dev/mem.

Writing to /selinux/context to check the validity of a context is ok, and necessary for checking the context it is going to use for the mount option. Note that each node under /selinux has its own finer-grained permission check in the security class to allow distinctions to be made among the operations separate from the inode-based permission check. See the can_getsecurity() macro for an example of allowing the ability to get any kind of security decision from selinuxfs (as distinct from being able to set things like the enforcing status, booleans, or loading policy, which have their own macros).

Quoted 5 lines

re: dmidecode -
dmidecode decodes the DMI data present in x86 and IA64 BIOS's.

Can't that be made to run in its own domain?

Likely should be.

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.
#10 lore raw
In reply to Stephen Smalley
Quoted 5 lines · Stephen Smalley

NETLINK_KOBJECT_UEVENT, which is used by lib/kobject_uevent.c. Looks like it is purely a kernel-to-userspace notification mechanism, so we might want a separate class for it to allow access to such notifications but we don't need any nlmsg_read/write checking for it. James, what do you think?

Agreed, add a new class but we don't need to look inside the messages.

- 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.