Skip to content

Commit 2ef6fc9

Browse files
tweksteenpcmoore
authored andcommitted
selinux: add netlink nlmsg_type audit message
Add a new audit message type to capture nlmsg-related information. This is similar to LSM_AUDIT_DATA_IOCTL_OP which was added for the other SELinux extended permission (ioctl). Adding a new type is preferred to adding to the existing lsm_network_audit structure which contains irrelevant information for the netlink sockets (i.e., dport, sport). Signed-off-by: Thiébaud Weksteen <[email protected]> [PM: change "nlnk-msgtype" to "nl-msgtype" as discussed] Signed-off-by: Paul Moore <[email protected]>
1 parent 4aa1761 commit 2ef6fc9

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

include/linux/lsm_audit.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ struct common_audit_data {
7777
#define LSM_AUDIT_DATA_LOCKDOWN 15
7878
#define LSM_AUDIT_DATA_NOTIFICATION 16
7979
#define LSM_AUDIT_DATA_ANONINODE 17
80+
#define LSM_AUDIT_DATA_NLMSGTYPE 18
8081
union {
8182
struct path path;
8283
struct dentry *dentry;
@@ -98,6 +99,7 @@ struct common_audit_data {
9899
struct lsm_ibendport_audit *ibendport;
99100
int reason;
100101
const char *anonclass;
102+
u16 nlmsg_type;
101103
} u;
102104
/* this union contains LSM specific data */
103105
union {

security/lsm_audit.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,9 @@ static void dump_common_audit_data(struct audit_buffer *ab,
425425
case LSM_AUDIT_DATA_ANONINODE:
426426
audit_log_format(ab, " anonclass=%s", a->u.anonclass);
427427
break;
428+
case LSM_AUDIT_DATA_NLMSGTYPE:
429+
audit_log_format(ab, " nl-msgtype=%hu", a->u.nlmsg_type);
430+
break;
428431
} /* switch (a->type) */
429432
}
430433

security/selinux/hooks.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5939,14 +5939,14 @@ static int nlmsg_sock_has_extended_perms(struct sock *sk, u32 perms, u16 nlmsg_t
59395939
{
59405940
struct sk_security_struct *sksec = sk->sk_security;
59415941
struct common_audit_data ad;
5942-
struct lsm_network_audit net;
59435942
u8 driver;
59445943
u8 xperm;
59455944

59465945
if (sock_skip_has_perm(sksec->sid))
59475946
return 0;
59485947

5949-
ad_net_init_from_sk(&ad, &net, sk);
5948+
ad.type = LSM_AUDIT_DATA_NLMSGTYPE;
5949+
ad.u.nlmsg_type = nlmsg_type;
59505950

59515951
driver = nlmsg_type >> 8;
59525952
xperm = nlmsg_type & 0xff;

0 commit comments

Comments
 (0)