2005-04-29 16:23:29 +01:00
|
|
|
/* audit.h -- Auditing support
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
|
|
|
|
* Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
|
|
|
|
|
* All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
*
|
|
|
|
|
* Written by Rickard E. (Rik) Faith <faith@redhat.com>
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
#ifndef _LINUX_AUDIT_H_
|
|
|
|
|
#define _LINUX_AUDIT_H_
|
|
|
|
|
|
2006-04-27 00:11:01 +01:00
|
|
|
#include <linux/sched.h>
|
2013-01-11 14:32:13 -08:00
|
|
|
#include <linux/ptrace.h>
|
2012-10-13 10:46:48 +01:00
|
|
|
#include <uapi/linux/audit.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2015-08-05 23:48:20 -04:00
|
|
|
#define AUDIT_INO_UNSET ((unsigned long)-1)
|
|
|
|
|
#define AUDIT_DEV_UNSET ((dev_t)-1)
|
|
|
|
|
|
2005-05-06 12:38:39 +01:00
|
|
|
struct audit_sig_info {
|
|
|
|
|
uid_t uid;
|
|
|
|
|
pid_t pid;
|
2006-05-25 10:19:47 -04:00
|
|
|
char ctx[0];
|
2005-05-06 12:38:39 +01:00
|
|
|
};
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
struct audit_buffer;
|
|
|
|
|
struct audit_context;
|
|
|
|
|
struct inode;
|
2005-06-24 14:14:05 +01:00
|
|
|
struct netlink_skb_parms;
|
2011-01-10 08:17:10 +02:00
|
|
|
struct path;
|
2006-04-26 14:04:08 -04:00
|
|
|
struct linux_binprm;
|
2006-05-24 16:09:55 -05:00
|
|
|
struct mq_attr;
|
|
|
|
|
struct mqstat;
|
2008-03-01 22:03:14 +02:00
|
|
|
struct audit_watch;
|
|
|
|
|
struct audit_tree;
|
2014-02-28 20:36:55 -08:00
|
|
|
struct sk_buff;
|
2008-03-01 22:03:14 +02:00
|
|
|
|
|
|
|
|
struct audit_krule {
|
2014-12-23 13:02:04 -05:00
|
|
|
u32 pflags;
|
2008-03-01 22:03:14 +02:00
|
|
|
u32 flags;
|
|
|
|
|
u32 listnr;
|
|
|
|
|
u32 action;
|
|
|
|
|
u32 mask[AUDIT_BITMASK_SIZE];
|
|
|
|
|
u32 buflen; /* for data alloc on list rules */
|
|
|
|
|
u32 field_count;
|
|
|
|
|
char *filterkey; /* ties events to rules */
|
|
|
|
|
struct audit_field *fields;
|
|
|
|
|
struct audit_field *arch_f; /* quick access to arch field */
|
|
|
|
|
struct audit_field *inode_f; /* quick access to an inode field */
|
|
|
|
|
struct audit_watch *watch; /* associated watch */
|
|
|
|
|
struct audit_tree *tree; /* associated watched tree */
|
2015-08-05 16:29:37 -04:00
|
|
|
struct audit_fsnotify_mark *exe;
|
2008-03-01 22:03:14 +02:00
|
|
|
struct list_head rlist; /* entry in audit_{watch,tree}.rules list */
|
2008-12-15 01:17:50 -05:00
|
|
|
struct list_head list; /* for AUDIT_LIST* purposes only */
|
2008-12-14 23:45:27 -05:00
|
|
|
u64 prio;
|
2008-03-01 22:03:14 +02:00
|
|
|
};
|
|
|
|
|
|
2014-12-23 13:02:04 -05:00
|
|
|
/* Flag to indicate legacy AUDIT_LOGINUID unset usage */
|
|
|
|
|
#define AUDIT_LOGINUID_LEGACY 0x1
|
|
|
|
|
|
2008-03-01 22:03:14 +02:00
|
|
|
struct audit_field {
|
|
|
|
|
u32 type;
|
2014-03-26 07:26:47 -04:00
|
|
|
union {
|
|
|
|
|
u32 val;
|
|
|
|
|
kuid_t uid;
|
|
|
|
|
kgid_t gid;
|
|
|
|
|
struct {
|
|
|
|
|
char *lsm_str;
|
|
|
|
|
void *lsm_rule;
|
|
|
|
|
};
|
|
|
|
|
};
|
2008-03-01 22:03:14 +02:00
|
|
|
u32 op;
|
|
|
|
|
};
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2013-05-22 12:54:49 -04:00
|
|
|
extern int is_audit_feature_set(int which);
|
|
|
|
|
|
2006-07-01 03:56:16 -04:00
|
|
|
extern int __init audit_register_class(int class, unsigned *list);
|
2006-08-31 19:26:40 -04:00
|
|
|
extern int audit_classify_syscall(int abi, unsigned syscall);
|
2007-03-29 18:01:04 -04:00
|
|
|
extern int audit_classify_arch(int arch);
|
2014-03-15 14:48:00 +09:00
|
|
|
/* only for compat system calls */
|
|
|
|
|
extern unsigned compat_write_class[];
|
|
|
|
|
extern unsigned compat_read_class[];
|
|
|
|
|
extern unsigned compat_dir_class[];
|
|
|
|
|
extern unsigned compat_chattr_class[];
|
|
|
|
|
extern unsigned compat_signal_class[];
|
|
|
|
|
|
2014-10-13 18:58:48 -06:00
|
|
|
extern int audit_classify_compat_syscall(int abi, unsigned syscall);
|
2012-10-10 15:25:22 -04:00
|
|
|
|
|
|
|
|
/* audit_names->type values */
|
|
|
|
|
#define AUDIT_TYPE_UNKNOWN 0 /* we don't know yet */
|
|
|
|
|
#define AUDIT_TYPE_NORMAL 1 /* a "normal" audit record */
|
2012-10-10 15:25:23 -04:00
|
|
|
#define AUDIT_TYPE_PARENT 2 /* a parent audit record */
|
2012-10-10 15:25:25 -04:00
|
|
|
#define AUDIT_TYPE_CHILD_DELETE 3 /* a child being deleted */
|
|
|
|
|
#define AUDIT_TYPE_CHILD_CREATE 4 /* a child being created */
|
2012-10-10 15:25:22 -04:00
|
|
|
|
2013-04-07 16:55:23 +08:00
|
|
|
/* maximized args number that audit_socketcall can process */
|
|
|
|
|
#define AUDITSC_ARGS 6
|
|
|
|
|
|
2016-01-09 22:55:33 -08:00
|
|
|
/* bit values for ->signal->audit_tty */
|
|
|
|
|
#define AUDIT_TTY_ENABLE BIT(0)
|
|
|
|
|
#define AUDIT_TTY_LOG_PASSWD BIT(1)
|
|
|
|
|
|
2012-10-10 15:25:28 -04:00
|
|
|
struct filename;
|
|
|
|
|
|
2013-04-30 09:53:34 -04:00
|
|
|
extern void audit_log_session_info(struct audit_buffer *ab);
|
|
|
|
|
|
2018-06-05 19:20:39 -04:00
|
|
|
#define AUDIT_OFF 0
|
|
|
|
|
#define AUDIT_ON 1
|
|
|
|
|
#define AUDIT_LOCKED 2
|
2016-01-13 09:18:55 -05:00
|
|
|
#ifdef CONFIG_AUDIT
|
|
|
|
|
/* These are defined in audit.c */
|
|
|
|
|
/* Public API */
|
|
|
|
|
extern __printf(4, 5)
|
|
|
|
|
void audit_log(struct audit_context *ctx, gfp_t gfp_mask, int type,
|
|
|
|
|
const char *fmt, ...);
|
|
|
|
|
|
|
|
|
|
extern struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, int type);
|
|
|
|
|
extern __printf(2, 3)
|
|
|
|
|
void audit_log_format(struct audit_buffer *ab, const char *fmt, ...);
|
|
|
|
|
extern void audit_log_end(struct audit_buffer *ab);
|
|
|
|
|
extern bool audit_string_contains_control(const char *string,
|
|
|
|
|
size_t len);
|
|
|
|
|
extern void audit_log_n_hex(struct audit_buffer *ab,
|
|
|
|
|
const unsigned char *buf,
|
|
|
|
|
size_t len);
|
|
|
|
|
extern void audit_log_n_string(struct audit_buffer *ab,
|
|
|
|
|
const char *buf,
|
|
|
|
|
size_t n);
|
|
|
|
|
extern void audit_log_n_untrustedstring(struct audit_buffer *ab,
|
|
|
|
|
const char *string,
|
|
|
|
|
size_t n);
|
|
|
|
|
extern void audit_log_untrustedstring(struct audit_buffer *ab,
|
|
|
|
|
const char *string);
|
|
|
|
|
extern void audit_log_d_path(struct audit_buffer *ab,
|
|
|
|
|
const char *prefix,
|
|
|
|
|
const struct path *path);
|
|
|
|
|
extern void audit_log_key(struct audit_buffer *ab,
|
|
|
|
|
char *key);
|
2018-03-21 04:42:20 -04:00
|
|
|
extern void audit_log_link_denied(const char *operation);
|
2016-01-13 09:18:55 -05:00
|
|
|
extern void audit_log_lost(const char *message);
|
|
|
|
|
|
|
|
|
|
extern int audit_log_task_context(struct audit_buffer *ab);
|
|
|
|
|
extern void audit_log_task_info(struct audit_buffer *ab,
|
|
|
|
|
struct task_struct *tsk);
|
|
|
|
|
|
|
|
|
|
extern int audit_update_lsm_rules(void);
|
|
|
|
|
|
|
|
|
|
/* Private API (for audit.c only) */
|
2017-05-02 10:16:05 -04:00
|
|
|
extern int audit_rule_change(int type, int seq, void *data, size_t datasz);
|
2016-01-13 09:18:55 -05:00
|
|
|
extern int audit_list_rules_send(struct sk_buff *request_skb, int seq);
|
|
|
|
|
|
|
|
|
|
extern u32 audit_enabled;
|
|
|
|
|
#else /* CONFIG_AUDIT */
|
|
|
|
|
static inline __printf(4, 5)
|
|
|
|
|
void audit_log(struct audit_context *ctx, gfp_t gfp_mask, int type,
|
|
|
|
|
const char *fmt, ...)
|
|
|
|
|
{ }
|
|
|
|
|
static inline struct audit_buffer *audit_log_start(struct audit_context *ctx,
|
|
|
|
|
gfp_t gfp_mask, int type)
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
static inline __printf(2, 3)
|
|
|
|
|
void audit_log_format(struct audit_buffer *ab, const char *fmt, ...)
|
|
|
|
|
{ }
|
|
|
|
|
static inline void audit_log_end(struct audit_buffer *ab)
|
|
|
|
|
{ }
|
|
|
|
|
static inline void audit_log_n_hex(struct audit_buffer *ab,
|
|
|
|
|
const unsigned char *buf, size_t len)
|
|
|
|
|
{ }
|
|
|
|
|
static inline void audit_log_n_string(struct audit_buffer *ab,
|
|
|
|
|
const char *buf, size_t n)
|
|
|
|
|
{ }
|
|
|
|
|
static inline void audit_log_n_untrustedstring(struct audit_buffer *ab,
|
|
|
|
|
const char *string, size_t n)
|
|
|
|
|
{ }
|
|
|
|
|
static inline void audit_log_untrustedstring(struct audit_buffer *ab,
|
|
|
|
|
const char *string)
|
|
|
|
|
{ }
|
|
|
|
|
static inline void audit_log_d_path(struct audit_buffer *ab,
|
|
|
|
|
const char *prefix,
|
|
|
|
|
const struct path *path)
|
|
|
|
|
{ }
|
|
|
|
|
static inline void audit_log_key(struct audit_buffer *ab, char *key)
|
|
|
|
|
{ }
|
2018-03-21 04:42:20 -04:00
|
|
|
static inline void audit_log_link_denied(const char *string)
|
2016-01-13 09:18:55 -05:00
|
|
|
{ }
|
|
|
|
|
static inline int audit_log_task_context(struct audit_buffer *ab)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
static inline void audit_log_task_info(struct audit_buffer *ab,
|
|
|
|
|
struct task_struct *tsk)
|
|
|
|
|
{ }
|
2018-06-05 19:20:39 -04:00
|
|
|
#define audit_enabled AUDIT_OFF
|
2016-01-13 09:18:55 -05:00
|
|
|
#endif /* CONFIG_AUDIT */
|
|
|
|
|
|
2014-03-25 09:25:41 -04:00
|
|
|
#ifdef CONFIG_AUDIT_COMPAT_GENERIC
|
2014-03-24 12:13:48 -04:00
|
|
|
#define audit_is_compat(arch) (!((arch) & __AUDIT_ARCH_64BIT))
|
|
|
|
|
#else
|
|
|
|
|
#define audit_is_compat(arch) false
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#ifdef CONFIG_AUDITSYSCALL
|
2014-04-22 11:46:16 -04:00
|
|
|
#include <asm/syscall.h> /* for syscall_get_arch() */
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/* These are defined in auditsc.c */
|
|
|
|
|
/* Public API */
|
|
|
|
|
extern int audit_alloc(struct task_struct *task);
|
2012-01-03 14:23:07 -05:00
|
|
|
extern void __audit_free(struct task_struct *task);
|
2014-03-04 10:38:06 -05:00
|
|
|
extern void __audit_syscall_entry(int major, unsigned long a0, unsigned long a1,
|
2012-01-03 14:23:06 -05:00
|
|
|
unsigned long a2, unsigned long a3);
|
2012-01-03 14:23:06 -05:00
|
|
|
extern void __audit_syscall_exit(int ret_success, long ret_value);
|
2012-10-10 15:25:28 -04:00
|
|
|
extern struct filename *__audit_reusename(const __user char *uptr);
|
2012-10-10 15:25:28 -04:00
|
|
|
extern void __audit_getname(struct filename *name);
|
2013-07-08 15:59:36 -07:00
|
|
|
|
|
|
|
|
#define AUDIT_INODE_PARENT 1 /* dentry represents the parent */
|
|
|
|
|
#define AUDIT_INODE_HIDDEN 2 /* audit record should be hidden */
|
2012-10-10 16:43:13 -04:00
|
|
|
extern void __audit_inode(struct filename *name, const struct dentry *dentry,
|
2013-07-08 15:59:36 -07:00
|
|
|
unsigned int flags);
|
2014-10-31 17:44:57 -04:00
|
|
|
extern void __audit_file(const struct file *);
|
2015-12-24 11:09:39 -05:00
|
|
|
extern void __audit_inode_child(struct inode *parent,
|
2012-10-10 15:25:25 -04:00
|
|
|
const struct dentry *dentry,
|
|
|
|
|
const unsigned char type);
|
2018-05-04 01:08:15 +00:00
|
|
|
extern void audit_seccomp(unsigned long syscall, long signr, int code);
|
2018-05-04 01:08:14 +00:00
|
|
|
extern void audit_seccomp_actions_logged(const char *names,
|
|
|
|
|
const char *old_names, int res);
|
2007-03-20 13:58:35 -04:00
|
|
|
extern void __audit_ptrace(struct task_struct *t);
|
|
|
|
|
|
2018-05-12 21:58:21 -04:00
|
|
|
static inline void audit_set_context(struct task_struct *task, struct audit_context *ctx)
|
|
|
|
|
{
|
|
|
|
|
task->audit_context = ctx;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-12 21:58:20 -04:00
|
|
|
static inline struct audit_context *audit_context(void)
|
|
|
|
|
{
|
|
|
|
|
return current->audit_context;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-04 08:23:51 -05:00
|
|
|
static inline bool audit_dummy_context(void)
|
2006-08-03 10:59:26 -04:00
|
|
|
{
|
2018-05-12 21:58:20 -04:00
|
|
|
void *p = audit_context();
|
2006-08-03 10:59:26 -04:00
|
|
|
return !p || *(int *)p;
|
|
|
|
|
}
|
2012-01-03 14:23:07 -05:00
|
|
|
static inline void audit_free(struct task_struct *task)
|
|
|
|
|
{
|
|
|
|
|
if (unlikely(task->audit_context))
|
|
|
|
|
__audit_free(task);
|
|
|
|
|
}
|
2014-03-11 13:29:28 -04:00
|
|
|
static inline void audit_syscall_entry(int major, unsigned long a0,
|
2012-01-03 14:23:06 -05:00
|
|
|
unsigned long a1, unsigned long a2,
|
|
|
|
|
unsigned long a3)
|
|
|
|
|
{
|
2018-05-12 21:58:20 -04:00
|
|
|
if (unlikely(audit_context()))
|
2014-03-04 10:38:06 -05:00
|
|
|
__audit_syscall_entry(major, a0, a1, a2, a3);
|
2012-01-03 14:23:06 -05:00
|
|
|
}
|
2012-01-03 14:23:06 -05:00
|
|
|
static inline void audit_syscall_exit(void *pt_regs)
|
|
|
|
|
{
|
2018-05-12 21:58:20 -04:00
|
|
|
if (unlikely(audit_context())) {
|
2012-01-03 14:23:06 -05:00
|
|
|
int success = is_syscall_success(pt_regs);
|
2014-01-13 13:33:09 -08:00
|
|
|
long return_code = regs_return_value(pt_regs);
|
2012-01-03 14:23:06 -05:00
|
|
|
|
|
|
|
|
__audit_syscall_exit(success, return_code);
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-10-10 15:25:28 -04:00
|
|
|
static inline struct filename *audit_reusename(const __user char *name)
|
|
|
|
|
{
|
|
|
|
|
if (unlikely(!audit_dummy_context()))
|
|
|
|
|
return __audit_reusename(name);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2012-10-10 15:25:28 -04:00
|
|
|
static inline void audit_getname(struct filename *name)
|
2006-05-18 16:01:30 -04:00
|
|
|
{
|
2006-07-16 06:38:45 -04:00
|
|
|
if (unlikely(!audit_dummy_context()))
|
2006-05-18 16:01:30 -04:00
|
|
|
__audit_getname(name);
|
|
|
|
|
}
|
2013-07-08 15:59:36 -07:00
|
|
|
static inline void audit_inode(struct filename *name,
|
|
|
|
|
const struct dentry *dentry,
|
2012-10-10 15:25:23 -04:00
|
|
|
unsigned int parent) {
|
2013-07-08 15:59:36 -07:00
|
|
|
if (unlikely(!audit_dummy_context())) {
|
|
|
|
|
unsigned int flags = 0;
|
|
|
|
|
if (parent)
|
|
|
|
|
flags |= AUDIT_INODE_PARENT;
|
|
|
|
|
__audit_inode(name, dentry, flags);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-10-31 17:44:57 -04:00
|
|
|
static inline void audit_file(struct file *file)
|
|
|
|
|
{
|
|
|
|
|
if (unlikely(!audit_dummy_context()))
|
|
|
|
|
__audit_file(file);
|
|
|
|
|
}
|
2013-07-08 15:59:36 -07:00
|
|
|
static inline void audit_inode_parent_hidden(struct filename *name,
|
|
|
|
|
const struct dentry *dentry)
|
|
|
|
|
{
|
2006-07-16 06:38:45 -04:00
|
|
|
if (unlikely(!audit_dummy_context()))
|
2013-07-08 15:59:36 -07:00
|
|
|
__audit_inode(name, dentry,
|
|
|
|
|
AUDIT_INODE_PARENT | AUDIT_INODE_HIDDEN);
|
2005-11-03 16:00:25 +00:00
|
|
|
}
|
2015-12-24 11:09:39 -05:00
|
|
|
static inline void audit_inode_child(struct inode *parent,
|
2012-10-10 15:25:25 -04:00
|
|
|
const struct dentry *dentry,
|
|
|
|
|
const unsigned char type) {
|
2006-07-16 06:38:45 -04:00
|
|
|
if (unlikely(!audit_dummy_context()))
|
2012-10-10 15:25:25 -04:00
|
|
|
__audit_inode_child(parent, dentry, type);
|
2005-11-03 16:00:25 +00:00
|
|
|
}
|
2007-04-19 10:28:21 -04:00
|
|
|
void audit_core_dumps(long signr);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-03-20 13:58:35 -04:00
|
|
|
static inline void audit_ptrace(struct task_struct *t)
|
|
|
|
|
{
|
|
|
|
|
if (unlikely(!audit_dummy_context()))
|
|
|
|
|
__audit_ptrace(t);
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/* Private API (for audit.c only) */
|
2005-05-21 21:08:09 +01:00
|
|
|
extern unsigned int audit_serial(void);
|
2008-12-06 01:05:50 -05:00
|
|
|
extern int auditsc_get_stamp(struct audit_context *ctx,
|
2017-05-02 10:16:05 -04:00
|
|
|
struct timespec64 *t, unsigned int *serial);
|
2012-10-04 17:11:11 -07:00
|
|
|
extern int audit_set_loginuid(kuid_t loginuid);
|
|
|
|
|
|
|
|
|
|
static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
|
|
|
|
|
{
|
|
|
|
|
return tsk->loginuid;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-26 18:01:36 -05:00
|
|
|
static inline unsigned int audit_get_sessionid(struct task_struct *tsk)
|
2012-10-04 17:11:11 -07:00
|
|
|
{
|
|
|
|
|
return tsk->sessionid;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-10 03:40:06 -05:00
|
|
|
extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp);
|
2011-07-27 14:03:22 -04:00
|
|
|
extern void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode);
|
2013-10-30 17:56:13 -04:00
|
|
|
extern void __audit_bprm(struct linux_binprm *bprm);
|
2013-04-07 16:55:23 +08:00
|
|
|
extern int __audit_socketcall(int nargs, unsigned long *args);
|
2012-01-03 14:23:07 -05:00
|
|
|
extern int __audit_sockaddr(int len, void *addr);
|
2008-12-14 04:57:47 -05:00
|
|
|
extern void __audit_fd_pair(int fd1, int fd2);
|
2011-07-26 05:26:10 -04:00
|
|
|
extern void __audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr);
|
2017-08-02 19:51:11 -07:00
|
|
|
extern void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec64 *abs_timeout);
|
2008-12-10 07:16:12 -05:00
|
|
|
extern void __audit_mq_notify(mqd_t mqdes, const struct sigevent *notification);
|
2008-12-10 06:58:59 -05:00
|
|
|
extern void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat);
|
2008-11-14 10:39:23 +11:00
|
|
|
extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm,
|
|
|
|
|
const struct cred *new,
|
|
|
|
|
const struct cred *old);
|
2013-03-19 00:02:25 -07:00
|
|
|
extern void __audit_log_capset(const struct cred *new, const struct cred *old);
|
2010-10-30 02:54:44 -04:00
|
|
|
extern void __audit_mmap_fd(int fd, int flags);
|
2017-02-04 13:10:38 -05:00
|
|
|
extern void __audit_log_kern_module(char *name);
|
2017-10-02 20:21:39 -04:00
|
|
|
extern void __audit_fanotify(unsigned int response);
|
2006-05-18 16:01:30 -04:00
|
|
|
|
2008-12-10 03:40:06 -05:00
|
|
|
static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp)
|
2006-05-18 16:01:30 -04:00
|
|
|
{
|
2006-07-16 06:38:45 -04:00
|
|
|
if (unlikely(!audit_dummy_context()))
|
2008-12-10 03:40:06 -05:00
|
|
|
__audit_ipc_obj(ipcp);
|
2006-05-18 16:01:30 -04:00
|
|
|
}
|
2008-12-14 04:57:47 -05:00
|
|
|
static inline void audit_fd_pair(int fd1, int fd2)
|
2007-02-07 01:48:00 -05:00
|
|
|
{
|
|
|
|
|
if (unlikely(!audit_dummy_context()))
|
2008-12-14 04:57:47 -05:00
|
|
|
__audit_fd_pair(fd1, fd2);
|
2007-02-07 01:48:00 -05:00
|
|
|
}
|
2011-07-27 14:03:22 -04:00
|
|
|
static inline void audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode)
|
2006-05-18 16:01:30 -04:00
|
|
|
{
|
2006-07-16 06:38:45 -04:00
|
|
|
if (unlikely(!audit_dummy_context()))
|
2008-12-10 03:47:15 -05:00
|
|
|
__audit_ipc_set_perm(qbytes, uid, gid, mode);
|
2006-05-18 16:01:30 -04:00
|
|
|
}
|
2013-10-30 18:05:24 -04:00
|
|
|
static inline void audit_bprm(struct linux_binprm *bprm)
|
2012-01-03 14:23:07 -05:00
|
|
|
{
|
|
|
|
|
if (unlikely(!audit_dummy_context()))
|
2013-10-30 17:56:13 -04:00
|
|
|
__audit_bprm(bprm);
|
2012-01-03 14:23:07 -05:00
|
|
|
}
|
2013-04-07 16:55:23 +08:00
|
|
|
static inline int audit_socketcall(int nargs, unsigned long *args)
|
2012-01-03 14:23:07 -05:00
|
|
|
{
|
|
|
|
|
if (unlikely(!audit_dummy_context()))
|
2013-04-07 16:55:23 +08:00
|
|
|
return __audit_socketcall(nargs, args);
|
|
|
|
|
return 0;
|
2012-01-03 14:23:07 -05:00
|
|
|
}
|
2017-01-17 11:07:15 -05:00
|
|
|
|
|
|
|
|
static inline int audit_socketcall_compat(int nargs, u32 *args)
|
|
|
|
|
{
|
|
|
|
|
unsigned long a[AUDITSC_ARGS];
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (audit_dummy_context())
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < nargs; i++)
|
|
|
|
|
a[i] = (unsigned long)args[i];
|
|
|
|
|
return __audit_socketcall(nargs, a);
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-03 14:23:07 -05:00
|
|
|
static inline int audit_sockaddr(int len, void *addr)
|
|
|
|
|
{
|
|
|
|
|
if (unlikely(!audit_dummy_context()))
|
|
|
|
|
return __audit_sockaddr(len, addr);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2011-07-26 05:26:10 -04:00
|
|
|
static inline void audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr)
|
2006-05-24 16:09:55 -05:00
|
|
|
{
|
2006-07-16 06:38:45 -04:00
|
|
|
if (unlikely(!audit_dummy_context()))
|
2008-12-14 04:02:26 -05:00
|
|
|
__audit_mq_open(oflag, mode, attr);
|
2006-05-24 16:09:55 -05:00
|
|
|
}
|
2017-08-02 19:51:11 -07:00
|
|
|
static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec64 *abs_timeout)
|
2006-05-24 16:09:55 -05:00
|
|
|
{
|
2006-07-16 06:38:45 -04:00
|
|
|
if (unlikely(!audit_dummy_context()))
|
2008-12-14 03:46:48 -05:00
|
|
|
__audit_mq_sendrecv(mqdes, msg_len, msg_prio, abs_timeout);
|
2006-05-24 16:09:55 -05:00
|
|
|
}
|
2008-12-10 07:16:12 -05:00
|
|
|
static inline void audit_mq_notify(mqd_t mqdes, const struct sigevent *notification)
|
2006-05-24 16:09:55 -05:00
|
|
|
{
|
2006-07-16 06:38:45 -04:00
|
|
|
if (unlikely(!audit_dummy_context()))
|
2008-12-10 07:16:12 -05:00
|
|
|
__audit_mq_notify(mqdes, notification);
|
2006-05-24 16:09:55 -05:00
|
|
|
}
|
2008-12-10 06:58:59 -05:00
|
|
|
static inline void audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat)
|
2006-05-24 16:09:55 -05:00
|
|
|
{
|
2006-07-16 06:38:45 -04:00
|
|
|
if (unlikely(!audit_dummy_context()))
|
2008-12-10 06:58:59 -05:00
|
|
|
__audit_mq_getsetattr(mqdes, mqstat);
|
2006-05-24 16:09:55 -05:00
|
|
|
}
|
2008-11-11 21:48:18 +11:00
|
|
|
|
2008-11-14 10:39:23 +11:00
|
|
|
static inline int audit_log_bprm_fcaps(struct linux_binprm *bprm,
|
|
|
|
|
const struct cred *new,
|
|
|
|
|
const struct cred *old)
|
2008-11-11 21:48:18 +11:00
|
|
|
{
|
|
|
|
|
if (unlikely(!audit_dummy_context()))
|
2008-11-14 10:39:23 +11:00
|
|
|
return __audit_log_bprm_fcaps(bprm, new, old);
|
|
|
|
|
return 0;
|
2008-11-11 21:48:18 +11:00
|
|
|
}
|
|
|
|
|
|
2013-03-19 00:02:25 -07:00
|
|
|
static inline void audit_log_capset(const struct cred *new,
|
2008-11-14 10:39:23 +11:00
|
|
|
const struct cred *old)
|
2008-11-11 21:48:22 +11:00
|
|
|
{
|
|
|
|
|
if (unlikely(!audit_dummy_context()))
|
2013-03-19 00:02:25 -07:00
|
|
|
__audit_log_capset(new, old);
|
2008-11-11 21:48:22 +11:00
|
|
|
}
|
|
|
|
|
|
2010-10-30 02:54:44 -04:00
|
|
|
static inline void audit_mmap_fd(int fd, int flags)
|
|
|
|
|
{
|
|
|
|
|
if (unlikely(!audit_dummy_context()))
|
|
|
|
|
__audit_mmap_fd(fd, flags);
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-04 13:10:38 -05:00
|
|
|
static inline void audit_log_kern_module(char *name)
|
|
|
|
|
{
|
|
|
|
|
if (!audit_dummy_context())
|
|
|
|
|
__audit_log_kern_module(name);
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-02 20:21:39 -04:00
|
|
|
static inline void audit_fanotify(unsigned int response)
|
|
|
|
|
{
|
|
|
|
|
if (!audit_dummy_context())
|
|
|
|
|
__audit_fanotify(response);
|
|
|
|
|
}
|
|
|
|
|
|
2006-07-10 08:29:24 -04:00
|
|
|
extern int audit_n_rules;
|
2007-03-29 18:01:04 -04:00
|
|
|
extern int audit_signals;
|
2012-01-03 14:23:06 -05:00
|
|
|
#else /* CONFIG_AUDITSYSCALL */
|
2012-10-04 17:11:11 -07:00
|
|
|
static inline int audit_alloc(struct task_struct *task)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
static inline void audit_free(struct task_struct *task)
|
|
|
|
|
{ }
|
2014-03-11 13:29:28 -04:00
|
|
|
static inline void audit_syscall_entry(int major, unsigned long a0,
|
2012-10-04 17:11:11 -07:00
|
|
|
unsigned long a1, unsigned long a2,
|
|
|
|
|
unsigned long a3)
|
|
|
|
|
{ }
|
|
|
|
|
static inline void audit_syscall_exit(void *pt_regs)
|
|
|
|
|
{ }
|
2015-11-04 08:23:51 -05:00
|
|
|
static inline bool audit_dummy_context(void)
|
2012-10-04 17:11:11 -07:00
|
|
|
{
|
2015-11-04 08:23:51 -05:00
|
|
|
return true;
|
2012-10-04 17:11:11 -07:00
|
|
|
}
|
2018-05-12 21:58:21 -04:00
|
|
|
static inline void audit_set_context(struct task_struct *task, struct audit_context *ctx)
|
|
|
|
|
{ }
|
2018-05-12 21:58:20 -04:00
|
|
|
static inline struct audit_context *audit_context(void)
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2012-10-10 15:25:28 -04:00
|
|
|
static inline struct filename *audit_reusename(const __user char *name)
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2012-10-10 15:25:28 -04:00
|
|
|
static inline void audit_getname(struct filename *name)
|
2012-10-04 17:11:11 -07:00
|
|
|
{ }
|
2012-10-10 16:43:13 -04:00
|
|
|
static inline void __audit_inode(struct filename *name,
|
|
|
|
|
const struct dentry *dentry,
|
2013-07-08 15:59:36 -07:00
|
|
|
unsigned int flags)
|
2012-10-04 17:11:11 -07:00
|
|
|
{ }
|
2015-12-24 11:09:39 -05:00
|
|
|
static inline void __audit_inode_child(struct inode *parent,
|
2012-10-10 15:25:25 -04:00
|
|
|
const struct dentry *dentry,
|
|
|
|
|
const unsigned char type)
|
2012-10-04 17:11:11 -07:00
|
|
|
{ }
|
2012-10-10 16:43:13 -04:00
|
|
|
static inline void audit_inode(struct filename *name,
|
|
|
|
|
const struct dentry *dentry,
|
2012-10-10 15:25:23 -04:00
|
|
|
unsigned int parent)
|
2012-10-04 17:11:11 -07:00
|
|
|
{ }
|
2014-10-31 17:44:57 -04:00
|
|
|
static inline void audit_file(struct file *file)
|
|
|
|
|
{
|
|
|
|
|
}
|
2013-07-08 15:59:36 -07:00
|
|
|
static inline void audit_inode_parent_hidden(struct filename *name,
|
|
|
|
|
const struct dentry *dentry)
|
|
|
|
|
{ }
|
2015-12-24 11:09:39 -05:00
|
|
|
static inline void audit_inode_child(struct inode *parent,
|
2012-10-10 15:25:25 -04:00
|
|
|
const struct dentry *dentry,
|
|
|
|
|
const unsigned char type)
|
2012-10-04 17:11:11 -07:00
|
|
|
{ }
|
|
|
|
|
static inline void audit_core_dumps(long signr)
|
|
|
|
|
{ }
|
|
|
|
|
static inline void audit_seccomp(unsigned long syscall, long signr, int code)
|
|
|
|
|
{ }
|
2018-05-04 01:08:14 +00:00
|
|
|
static inline void audit_seccomp_actions_logged(const char *names,
|
|
|
|
|
const char *old_names, int res)
|
|
|
|
|
{ }
|
2012-10-04 17:11:11 -07:00
|
|
|
static inline int auditsc_get_stamp(struct audit_context *ctx,
|
2017-05-02 10:16:05 -04:00
|
|
|
struct timespec64 *t, unsigned int *serial)
|
2012-10-04 17:11:11 -07:00
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
|
|
|
|
|
{
|
|
|
|
|
return INVALID_UID;
|
|
|
|
|
}
|
2013-11-26 18:01:36 -05:00
|
|
|
static inline unsigned int audit_get_sessionid(struct task_struct *tsk)
|
2012-10-04 17:11:11 -07:00
|
|
|
{
|
2018-05-12 21:58:19 -04:00
|
|
|
return AUDIT_SID_UNSET;
|
2012-10-04 17:11:11 -07:00
|
|
|
}
|
|
|
|
|
static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp)
|
|
|
|
|
{ }
|
|
|
|
|
static inline void audit_ipc_set_perm(unsigned long qbytes, uid_t uid,
|
|
|
|
|
gid_t gid, umode_t mode)
|
|
|
|
|
{ }
|
2013-10-30 18:05:24 -04:00
|
|
|
static inline void audit_bprm(struct linux_binprm *bprm)
|
|
|
|
|
{ }
|
2013-04-07 16:55:23 +08:00
|
|
|
static inline int audit_socketcall(int nargs, unsigned long *args)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2017-01-17 11:07:15 -05:00
|
|
|
|
|
|
|
|
static inline int audit_socketcall_compat(int nargs, u32 *args)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-04 17:11:11 -07:00
|
|
|
static inline void audit_fd_pair(int fd1, int fd2)
|
|
|
|
|
{ }
|
|
|
|
|
static inline int audit_sockaddr(int len, void *addr)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
static inline void audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr)
|
|
|
|
|
{ }
|
|
|
|
|
static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len,
|
|
|
|
|
unsigned int msg_prio,
|
2017-08-02 19:51:11 -07:00
|
|
|
const struct timespec64 *abs_timeout)
|
2012-10-04 17:11:11 -07:00
|
|
|
{ }
|
|
|
|
|
static inline void audit_mq_notify(mqd_t mqdes,
|
|
|
|
|
const struct sigevent *notification)
|
|
|
|
|
{ }
|
|
|
|
|
static inline void audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat)
|
|
|
|
|
{ }
|
|
|
|
|
static inline int audit_log_bprm_fcaps(struct linux_binprm *bprm,
|
|
|
|
|
const struct cred *new,
|
|
|
|
|
const struct cred *old)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2013-03-19 00:02:25 -07:00
|
|
|
static inline void audit_log_capset(const struct cred *new,
|
|
|
|
|
const struct cred *old)
|
2012-10-04 17:11:11 -07:00
|
|
|
{ }
|
|
|
|
|
static inline void audit_mmap_fd(int fd, int flags)
|
|
|
|
|
{ }
|
2017-02-04 13:10:38 -05:00
|
|
|
|
|
|
|
|
static inline void audit_log_kern_module(char *name)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-02 20:21:39 -04:00
|
|
|
static inline void audit_fanotify(unsigned int response)
|
|
|
|
|
{ }
|
|
|
|
|
|
2012-10-04 17:11:11 -07:00
|
|
|
static inline void audit_ptrace(struct task_struct *t)
|
|
|
|
|
{ }
|
2006-07-10 08:29:24 -04:00
|
|
|
#define audit_n_rules 0
|
2007-03-29 18:01:04 -04:00
|
|
|
#define audit_signals 0
|
2012-01-03 14:23:06 -05:00
|
|
|
#endif /* CONFIG_AUDITSYSCALL */
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2013-04-09 02:22:10 -07:00
|
|
|
static inline bool audit_loginuid_set(struct task_struct *tsk)
|
|
|
|
|
{
|
|
|
|
|
return uid_valid(audit_get_loginuid(tsk));
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-04 17:11:11 -07:00
|
|
|
static inline void audit_log_string(struct audit_buffer *ab, const char *buf)
|
|
|
|
|
{
|
|
|
|
|
audit_log_n_string(ab, buf, strlen(buf));
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#endif
|