Check sys_tty_config for KDSKB(S)?ENT ioctls (e.g. loadkeys)
PATCH 1/1 Check sys_tty_config for KDSKB(S)?ENT ioctls (e.g. loadkeys)
The attached patch, also committed to the sourceforge CVS tree, changes the SELinux file_ioctl hook function to check the CAP_SYS_TTY_CONFIG capability and the corresponding sys_tty_config capability permission when the KDSKBENT or KDSKBSENT ioctls are used. In combination with an appropriate policy (e.g. removing sys_tty_config permission from policy/macros/user_macros.te), this change addresses the concern raised by an earlier message by Russell Coker, see
http://marc.theaimsgroup.com/?l=selinux&m=103122430232003&w=2. It may be desirable to also place some of the other console ioctls under similar control.
--
Stephen D. Smalley, NAI Labs
[email protected]
Index: lsm-2.4/security/selinux/hooks.c
===================================================================
RCS file: /cvsroot/selinux/nsa/lsm-2.4/security/selinux/hooks.c,v retrieving revision 1.18
security/selinux/hooks.c +7 -0
@@ -37,6 +37,7 @@#include <linux/file.h> #include <linux/ext2_fs.h> #include <linux/proc_fs.h> +#include <linux/kd.h> #include <net/icmp.h> #include <net/ip.h> /* for sysctl_local_port_range[] */ #include <net/tcp.h> /* struct or_callable used in sock_rcv_skb */
@@ -2313,6 +2314,12 @@/* fall through */ case FIOASYNC : error =file_has_perm (current, file,0 ); +break ; + +case KDSKBENT : +case KDSKBSENT : +if (!capable (CAP_SYS_TTY_CONFIG )) + error = -EPERM ;break ;/* default case assumes that the command will go