Skip to content

Commit 3a101b8

Browse files
rgbriggsdavem330
authored andcommitted
audit: add netlink audit protocol bind to check capabilities on multicast join
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>
1 parent 7774d5e commit 3a101b8

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎include/uapi/linux/capability.h‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,12 @@ struct vfs_cap_data {
347347

348348
#define CAP_BLOCK_SUSPEND 36
349349

350-
#define CAP_LAST_CAP CAP_BLOCK_SUSPEND
350+
/* Allow reading the audit log via multicast netlink socket */
351+
352+
#define CAP_AUDIT_READ 37
353+
354+
355+
#define CAP_LAST_CAP CAP_AUDIT_READ
351356

352357
#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
353358

‎kernel/audit.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,10 +1076,20 @@ static void audit_receive(struct sk_buff *skb)
10761076
mutex_unlock(&audit_cmd_mutex);
10771077
}
10781078

1079+
/* Run custom bind function on netlink socket group connect or bind requests. */
1080+
static int audit_bind(int group)
1081+
{
1082+
if (!capable(CAP_AUDIT_READ))
1083+
return -EPERM;
1084+
1085+
return 0;
1086+
}
1087+
10791088
static int __net_init audit_net_init(struct net *net)
10801089
{
10811090
struct netlink_kernel_cfg cfg = {
10821091
.input = audit_receive,
1092+
.bind = audit_bind,
10831093
};
10841094

10851095
struct audit_net *aunet = net_generic(net, audit_net_id);

‎security/selinux/include/classmap.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ struct security_class_mapping secclass_map[] = {
147147
{ "peer", { "recv", NULL } },
148148
{ "capability2",
149149
{ "mac_override", "mac_admin", "syslog", "wake_alarm", "block_suspend",
150-
NULL } },
150+
"audit_read", NULL } },
151151
{ "kernel_service", { "use_as_override", "create_files_as", NULL } },
152152
{ "tun_socket",
153153
{ COMMON_SOCK_PERMS, "attach_queue", NULL } },

0 commit comments

Comments
 (0)