Linux 2.6.26-rc8
[linux-3.10.git] / security / selinux / nlmsgtab.c
index fa7fa030e6ebaa5609bb5ce1baff3181350da0b3..ff59c0c4804bd0f872cdba331cd0d48d18f59d0b 100644 (file)
 #include <linux/rtnetlink.h>
 #include <linux/if.h>
 #include <linux/netfilter_ipv4/ip_queue.h>
 #include <linux/rtnetlink.h>
 #include <linux/if.h>
 #include <linux/netfilter_ipv4/ip_queue.h>
-#include <linux/tcp_diag.h>
+#include <linux/inet_diag.h>
 #include <linux/xfrm.h>
 #include <linux/audit.h>
 
 #include "flask.h"
 #include "av_permissions.h"
 
 #include <linux/xfrm.h>
 #include <linux/audit.h>
 
 #include "flask.h"
 #include "av_permissions.h"
 
-struct nlmsg_perm
-{
+struct nlmsg_perm {
        u16     nlmsg_type;
        u32     perm;
 };
        u16     nlmsg_type;
        u32     perm;
 };
@@ -60,9 +59,10 @@ static struct nlmsg_perm nlmsg_route_perms[] =
        { RTM_DELACTION,        NETLINK_ROUTE_SOCKET__NLMSG_WRITE },
        { RTM_GETACTION,        NETLINK_ROUTE_SOCKET__NLMSG_READ  },
        { RTM_NEWPREFIX,        NETLINK_ROUTE_SOCKET__NLMSG_WRITE },
        { RTM_DELACTION,        NETLINK_ROUTE_SOCKET__NLMSG_WRITE },
        { RTM_GETACTION,        NETLINK_ROUTE_SOCKET__NLMSG_READ  },
        { RTM_NEWPREFIX,        NETLINK_ROUTE_SOCKET__NLMSG_WRITE },
-       { RTM_GETPREFIX,        NETLINK_ROUTE_SOCKET__NLMSG_READ  },
        { RTM_GETMULTICAST,     NETLINK_ROUTE_SOCKET__NLMSG_READ  },
        { RTM_GETANYCAST,       NETLINK_ROUTE_SOCKET__NLMSG_READ  },
        { RTM_GETMULTICAST,     NETLINK_ROUTE_SOCKET__NLMSG_READ  },
        { RTM_GETANYCAST,       NETLINK_ROUTE_SOCKET__NLMSG_READ  },
+       { RTM_GETNEIGHTBL,      NETLINK_ROUTE_SOCKET__NLMSG_READ  },
+       { RTM_SETNEIGHTBL,      NETLINK_ROUTE_SOCKET__NLMSG_WRITE },
 };
 
 static struct nlmsg_perm nlmsg_firewall_perms[] =
 };
 
 static struct nlmsg_perm nlmsg_firewall_perms[] =
@@ -74,6 +74,7 @@ static struct nlmsg_perm nlmsg_firewall_perms[] =
 static struct nlmsg_perm nlmsg_tcpdiag_perms[] =
 {
        { TCPDIAG_GETSOCK,      NETLINK_TCPDIAG_SOCKET__NLMSG_READ },
 static struct nlmsg_perm nlmsg_tcpdiag_perms[] =
 {
        { TCPDIAG_GETSOCK,      NETLINK_TCPDIAG_SOCKET__NLMSG_READ },
+       { DCCPDIAG_GETSOCK,     NETLINK_TCPDIAG_SOCKET__NLMSG_READ },
 };
 
 static struct nlmsg_perm nlmsg_xfrm_perms[] =
 };
 
 static struct nlmsg_perm nlmsg_xfrm_perms[] =
@@ -85,19 +86,31 @@ static struct nlmsg_perm nlmsg_xfrm_perms[] =
        { XFRM_MSG_DELPOLICY,   NETLINK_XFRM_SOCKET__NLMSG_WRITE },
        { XFRM_MSG_GETPOLICY,   NETLINK_XFRM_SOCKET__NLMSG_READ  },
        { XFRM_MSG_ALLOCSPI,    NETLINK_XFRM_SOCKET__NLMSG_WRITE },
        { XFRM_MSG_DELPOLICY,   NETLINK_XFRM_SOCKET__NLMSG_WRITE },
        { XFRM_MSG_GETPOLICY,   NETLINK_XFRM_SOCKET__NLMSG_READ  },
        { XFRM_MSG_ALLOCSPI,    NETLINK_XFRM_SOCKET__NLMSG_WRITE },
+       { XFRM_MSG_ACQUIRE,     NETLINK_XFRM_SOCKET__NLMSG_WRITE },
+       { XFRM_MSG_EXPIRE,      NETLINK_XFRM_SOCKET__NLMSG_WRITE },
        { XFRM_MSG_UPDPOLICY,   NETLINK_XFRM_SOCKET__NLMSG_WRITE },
        { XFRM_MSG_UPDSA,       NETLINK_XFRM_SOCKET__NLMSG_WRITE },
        { XFRM_MSG_UPDPOLICY,   NETLINK_XFRM_SOCKET__NLMSG_WRITE },
        { XFRM_MSG_UPDSA,       NETLINK_XFRM_SOCKET__NLMSG_WRITE },
+       { XFRM_MSG_POLEXPIRE,   NETLINK_XFRM_SOCKET__NLMSG_WRITE },
+       { XFRM_MSG_FLUSHSA,     NETLINK_XFRM_SOCKET__NLMSG_WRITE },
+       { XFRM_MSG_FLUSHPOLICY, NETLINK_XFRM_SOCKET__NLMSG_WRITE },
+       { XFRM_MSG_NEWAE,       NETLINK_XFRM_SOCKET__NLMSG_WRITE },
+       { XFRM_MSG_GETAE,       NETLINK_XFRM_SOCKET__NLMSG_READ  },
 };
 
 static struct nlmsg_perm nlmsg_audit_perms[] =
 {
 };
 
 static struct nlmsg_perm nlmsg_audit_perms[] =
 {
-       { AUDIT_GET,            NETLINK_AUDIT_SOCKET__NLMSG_READ  },
-       { AUDIT_SET,            NETLINK_AUDIT_SOCKET__NLMSG_WRITE },
-       { AUDIT_LIST,           NETLINK_AUDIT_SOCKET__NLMSG_READ  },
-       { AUDIT_ADD,            NETLINK_AUDIT_SOCKET__NLMSG_WRITE },
-       { AUDIT_DEL,            NETLINK_AUDIT_SOCKET__NLMSG_WRITE },
-       { AUDIT_USER,           NETLINK_AUDIT_SOCKET__NLMSG_WRITE },
-       { AUDIT_LOGIN,          NETLINK_AUDIT_SOCKET__NLMSG_WRITE },
+       { AUDIT_GET,            NETLINK_AUDIT_SOCKET__NLMSG_READ     },
+       { AUDIT_SET,            NETLINK_AUDIT_SOCKET__NLMSG_WRITE    },
+       { AUDIT_LIST,           NETLINK_AUDIT_SOCKET__NLMSG_READPRIV },
+       { AUDIT_ADD,            NETLINK_AUDIT_SOCKET__NLMSG_WRITE    },
+       { AUDIT_DEL,            NETLINK_AUDIT_SOCKET__NLMSG_WRITE    },
+       { AUDIT_LIST_RULES,     NETLINK_AUDIT_SOCKET__NLMSG_READPRIV },
+       { AUDIT_ADD_RULE,       NETLINK_AUDIT_SOCKET__NLMSG_WRITE    },
+       { AUDIT_DEL_RULE,       NETLINK_AUDIT_SOCKET__NLMSG_WRITE    },
+       { AUDIT_USER,           NETLINK_AUDIT_SOCKET__NLMSG_RELAY    },
+       { AUDIT_SIGNAL_INFO,    NETLINK_AUDIT_SOCKET__NLMSG_READ     },
+       { AUDIT_TTY_GET,        NETLINK_AUDIT_SOCKET__NLMSG_READ     },
+       { AUDIT_TTY_SET,        NETLINK_AUDIT_SOCKET__NLMSG_WRITE    },
 };
 
 
 };
 
 
@@ -126,7 +139,7 @@ int selinux_nlmsg_lookup(u16 sclass, u16 nlmsg_type, u32 *perm)
                break;
 
        case SECCLASS_NETLINK_FIREWALL_SOCKET:
                break;
 
        case SECCLASS_NETLINK_FIREWALL_SOCKET:
-       case NETLINK_IP6_FW:
+       case SECCLASS_NETLINK_IP6FW_SOCKET:
                err = nlmsg_perm(nlmsg_type, perm, nlmsg_firewall_perms,
                                 sizeof(nlmsg_firewall_perms));
                break;
                err = nlmsg_perm(nlmsg_type, perm, nlmsg_firewall_perms,
                                 sizeof(nlmsg_firewall_perms));
                break;
@@ -142,8 +155,15 @@ int selinux_nlmsg_lookup(u16 sclass, u16 nlmsg_type, u32 *perm)
                break;
 
        case SECCLASS_NETLINK_AUDIT_SOCKET:
                break;
 
        case SECCLASS_NETLINK_AUDIT_SOCKET:
-               err = nlmsg_perm(nlmsg_type, perm, nlmsg_audit_perms,
-                                sizeof(nlmsg_audit_perms));
+               if ((nlmsg_type >= AUDIT_FIRST_USER_MSG &&
+                    nlmsg_type <= AUDIT_LAST_USER_MSG) ||
+                   (nlmsg_type >= AUDIT_FIRST_USER_MSG2 &&
+                    nlmsg_type <= AUDIT_LAST_USER_MSG2)) {
+                       *perm = NETLINK_AUDIT_SOCKET__NLMSG_RELAY;
+               } else {
+                       err = nlmsg_perm(nlmsg_type, perm, nlmsg_audit_perms,
+                                        sizeof(nlmsg_audit_perms));
+               }
                break;
 
        /* No messaging from userspace, or class unknown/unhandled */
                break;
 
        /* No messaging from userspace, or class unknown/unhandled */