]> git.karo-electronics.de Git - linux-beck.git/commitdiff
audit: add netlink audit protocol bind to check capabilities on multicast join
authorRichard Guy Briggs <rgb@redhat.com>
Wed, 23 Apr 2014 01:31:56 +0000 (21:31 -0400)
committerDavid S. Miller <davem@davemloft.net>
Wed, 23 Apr 2014 01:42:27 +0000 (21:42 -0400)
Register a netlink per-protocol bind fuction for audit to check userspace
process capabilities before allowing a multicast group connection.

Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/uapi/linux/capability.h
kernel/audit.c
security/selinux/include/classmap.h

index 154dd6d3c8fedaa54a04817567580b11727f2807..12c37a197d247ca980fef9c6e81ed0c067f27987 100644 (file)
@@ -347,7 +347,12 @@ struct vfs_cap_data {
 
 #define CAP_BLOCK_SUSPEND    36
 
-#define CAP_LAST_CAP         CAP_BLOCK_SUSPEND
+/* Allow reading the audit log via multicast netlink socket */
+
+#define CAP_AUDIT_READ         37
+
+
+#define CAP_LAST_CAP         CAP_AUDIT_READ
 
 #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
 
index 7c2893602d0651f767e1a177dbfd6214e66e8d9c..223cb746f141fe7d19381e34d07cf1b92dae14f2 100644 (file)
@@ -1076,10 +1076,20 @@ static void audit_receive(struct sk_buff  *skb)
        mutex_unlock(&audit_cmd_mutex);
 }
 
+/* Run custom bind function on netlink socket group connect or bind requests. */
+static int audit_bind(int group)
+{
+       if (!capable(CAP_AUDIT_READ))
+               return -EPERM;
+
+       return 0;
+}
+
 static int __net_init audit_net_init(struct net *net)
 {
        struct netlink_kernel_cfg cfg = {
                .input  = audit_receive,
+               .bind   = audit_bind,
        };
 
        struct audit_net *aunet = net_generic(net, audit_net_id);
index 14d04e63b1f0e09ef15b4cf64057bd7cc861ed1d..be491a74c1edc4a279f76121dab615305c3a47f2 100644 (file)
@@ -147,7 +147,7 @@ struct security_class_mapping secclass_map[] = {
        { "peer", { "recv", NULL } },
        { "capability2",
          { "mac_override", "mac_admin", "syslog", "wake_alarm", "block_suspend",
-           NULL } },
+           "audit_read", NULL } },
        { "kernel_service", { "use_as_override", "create_files_as", NULL } },
        { "tun_socket",
          { COMMON_SOCK_PERMS, "attach_queue", NULL } },