2009-04-08 18:39:40 +00:00
|
|
|
/*
|
|
|
|
* Common LSM logging functions
|
|
|
|
* Heavily borrowed from selinux/avc.h
|
|
|
|
*
|
|
|
|
* Author : Etienne BASSET <etienne.basset@ensta.org>
|
|
|
|
*
|
2017-08-17 17:32:37 +00:00
|
|
|
* All credits to : Stephen Smalley, <sds@tycho.nsa.gov>
|
2009-04-08 18:39:40 +00:00
|
|
|
* All BUGS to : Etienne BASSET <etienne.basset@ensta.org>
|
|
|
|
*/
|
|
|
|
#ifndef _LSM_COMMON_LOGGING_
|
|
|
|
#define _LSM_COMMON_LOGGING_
|
|
|
|
|
|
|
|
#include <linux/stddef.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/kdev_t.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/audit.h>
|
|
|
|
#include <linux/in6.h>
|
|
|
|
#include <linux/path.h>
|
|
|
|
#include <linux/key.h>
|
|
|
|
#include <linux/skbuff.h>
|
2017-05-19 12:48:58 +00:00
|
|
|
#include <rdma/ib_verbs.h>
|
2009-04-08 18:39:40 +00:00
|
|
|
|
2012-04-02 17:15:44 +00:00
|
|
|
struct lsm_network_audit {
|
|
|
|
int netif;
|
|
|
|
struct sock *sk;
|
|
|
|
u16 family;
|
|
|
|
__be16 dport;
|
|
|
|
__be16 sport;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
__be32 daddr;
|
|
|
|
__be32 saddr;
|
|
|
|
} v4;
|
|
|
|
struct {
|
|
|
|
struct in6_addr daddr;
|
|
|
|
struct in6_addr saddr;
|
|
|
|
} v6;
|
|
|
|
} fam;
|
|
|
|
};
|
2009-04-08 18:39:40 +00:00
|
|
|
|
2015-07-10 21:19:55 +00:00
|
|
|
struct lsm_ioctlop_audit {
|
|
|
|
struct path path;
|
|
|
|
u16 cmd;
|
|
|
|
};
|
|
|
|
|
2017-05-19 12:48:57 +00:00
|
|
|
struct lsm_ibpkey_audit {
|
|
|
|
u64 subnet_prefix;
|
|
|
|
u16 pkey;
|
|
|
|
};
|
|
|
|
|
2017-05-19 12:48:58 +00:00
|
|
|
struct lsm_ibendport_audit {
|
|
|
|
char dev_name[IB_DEVICE_NAME_MAX];
|
|
|
|
u8 port;
|
|
|
|
};
|
|
|
|
|
2009-04-08 18:39:40 +00:00
|
|
|
/* Auxiliary data to use in generating the audit record. */
|
|
|
|
struct common_audit_data {
|
2009-11-03 05:35:32 +00:00
|
|
|
char type;
|
2011-04-25 16:54:27 +00:00
|
|
|
#define LSM_AUDIT_DATA_PATH 1
|
2009-11-03 05:35:32 +00:00
|
|
|
#define LSM_AUDIT_DATA_NET 2
|
|
|
|
#define LSM_AUDIT_DATA_CAP 3
|
|
|
|
#define LSM_AUDIT_DATA_IPC 4
|
|
|
|
#define LSM_AUDIT_DATA_TASK 5
|
|
|
|
#define LSM_AUDIT_DATA_KEY 6
|
2010-04-27 21:20:38 +00:00
|
|
|
#define LSM_AUDIT_DATA_NONE 7
|
2009-11-03 05:35:32 +00:00
|
|
|
#define LSM_AUDIT_DATA_KMOD 8
|
2011-04-25 16:54:27 +00:00
|
|
|
#define LSM_AUDIT_DATA_INODE 9
|
2011-04-25 17:10:27 +00:00
|
|
|
#define LSM_AUDIT_DATA_DENTRY 10
|
2015-07-10 21:19:55 +00:00
|
|
|
#define LSM_AUDIT_DATA_IOCTL_OP 11
|
2016-09-09 15:37:49 +00:00
|
|
|
#define LSM_AUDIT_DATA_FILE 12
|
2017-05-19 12:48:57 +00:00
|
|
|
#define LSM_AUDIT_DATA_IBPKEY 13
|
2017-05-19 12:48:58 +00:00
|
|
|
#define LSM_AUDIT_DATA_IBENDPORT 14
|
2009-04-08 18:39:40 +00:00
|
|
|
union {
|
2011-04-25 16:54:27 +00:00
|
|
|
struct path path;
|
2011-04-25 17:10:27 +00:00
|
|
|
struct dentry *dentry;
|
2011-04-25 16:54:27 +00:00
|
|
|
struct inode *inode;
|
2012-04-02 17:15:44 +00:00
|
|
|
struct lsm_network_audit *net;
|
2009-04-08 18:39:40 +00:00
|
|
|
int cap;
|
|
|
|
int ipc_id;
|
|
|
|
struct task_struct *tsk;
|
|
|
|
#ifdef CONFIG_KEYS
|
|
|
|
struct {
|
|
|
|
key_serial_t key;
|
|
|
|
char *key_desc;
|
|
|
|
} key_struct;
|
|
|
|
#endif
|
2009-11-03 05:35:32 +00:00
|
|
|
char *kmod_name;
|
2015-07-10 21:19:55 +00:00
|
|
|
struct lsm_ioctlop_audit *op;
|
2016-09-09 15:37:49 +00:00
|
|
|
struct file *file;
|
2017-05-19 12:48:57 +00:00
|
|
|
struct lsm_ibpkey_audit *ibpkey;
|
2017-05-19 12:48:58 +00:00
|
|
|
struct lsm_ibendport_audit *ibendport;
|
2009-04-08 18:39:40 +00:00
|
|
|
} u;
|
|
|
|
/* this union contains LSM specific data */
|
|
|
|
union {
|
2009-07-09 14:00:31 +00:00
|
|
|
#ifdef CONFIG_SECURITY_SMACK
|
2012-04-03 16:37:02 +00:00
|
|
|
struct smack_audit_data *smack_audit_data;
|
2009-07-09 14:00:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_SECURITY_SELINUX
|
2012-04-03 16:37:02 +00:00
|
|
|
struct selinux_audit_data *selinux_audit_data;
|
2010-07-29 21:47:58 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_SECURITY_APPARMOR
|
2012-04-03 16:37:02 +00:00
|
|
|
struct apparmor_audit_data *apparmor_audit_data;
|
2009-07-09 14:00:31 +00:00
|
|
|
#endif
|
2012-04-03 16:37:02 +00:00
|
|
|
}; /* per LSM data pointer union */
|
2009-04-08 18:39:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define v4info fam.v4
|
|
|
|
#define v6info fam.v6
|
|
|
|
|
|
|
|
int ipv4_skb_to_auditdata(struct sk_buff *skb,
|
|
|
|
struct common_audit_data *ad, u8 *proto);
|
|
|
|
|
|
|
|
int ipv6_skb_to_auditdata(struct sk_buff *skb,
|
|
|
|
struct common_audit_data *ad, u8 *proto);
|
|
|
|
|
2012-04-02 22:48:12 +00:00
|
|
|
void common_lsm_audit(struct common_audit_data *a,
|
|
|
|
void (*pre_audit)(struct audit_buffer *, void *),
|
|
|
|
void (*post_audit)(struct audit_buffer *, void *));
|
2009-04-08 18:39:40 +00:00
|
|
|
|
|
|
|
#endif
|