2019-05-27 06:55:05 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2005-04-29 15:23:29 +00:00
|
|
|
/* audit.h -- Auditing support
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Written by Rickard E. (Rik) Faith <faith@redhat.com>
|
|
|
|
*/
|
|
|
|
#ifndef _LINUX_AUDIT_H_
|
|
|
|
#define _LINUX_AUDIT_H_
|
|
|
|
|
2006-04-26 23:11:01 +00:00
|
|
|
#include <linux/sched.h>
|
2013-01-11 22:32:13 +00:00
|
|
|
#include <linux/ptrace.h>
|
2012-10-13 09:46:48 +00:00
|
|
|
#include <uapi/linux/audit.h>
|
2020-06-04 13:20:49 +00:00
|
|
|
#include <uapi/linux/netfilter/nf_tables.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2015-08-06 03:48:20 +00:00
|
|
|
#define AUDIT_INO_UNSET ((unsigned long)-1)
|
|
|
|
#define AUDIT_DEV_UNSET ((dev_t)-1)
|
|
|
|
|
2005-05-06 11:38:39 +00:00
|
|
|
struct audit_sig_info {
|
|
|
|
uid_t uid;
|
|
|
|
pid_t pid;
|
2020-05-07 18:50:41 +00:00
|
|
|
char ctx[];
|
2005-05-06 11:38:39 +00:00
|
|
|
};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
struct audit_buffer;
|
|
|
|
struct audit_context;
|
|
|
|
struct inode;
|
2005-06-24 13:14:05 +00:00
|
|
|
struct netlink_skb_parms;
|
2011-01-10 06:17:10 +00:00
|
|
|
struct path;
|
2006-04-26 18:04:08 +00:00
|
|
|
struct linux_binprm;
|
2006-05-24 21:09:55 +00:00
|
|
|
struct mq_attr;
|
|
|
|
struct mqstat;
|
2008-03-01 20:03:14 +00:00
|
|
|
struct audit_watch;
|
|
|
|
struct audit_tree;
|
2014-03-01 04:36:55 +00:00
|
|
|
struct sk_buff;
|
2008-03-01 20:03:14 +00:00
|
|
|
|
|
|
|
struct audit_krule {
|
2014-12-23 18:02:04 +00:00
|
|
|
u32 pflags;
|
2008-03-01 20:03:14 +00: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 20:29:37 +00:00
|
|
|
struct audit_fsnotify_mark *exe;
|
2008-03-01 20:03:14 +00:00
|
|
|
struct list_head rlist; /* entry in audit_{watch,tree}.rules list */
|
2008-12-15 06:17:50 +00:00
|
|
|
struct list_head list; /* for AUDIT_LIST* purposes only */
|
2008-12-15 04:45:27 +00:00
|
|
|
u64 prio;
|
2008-03-01 20:03:14 +00:00
|
|
|
};
|
|
|
|
|
2014-12-23 18:02:04 +00:00
|
|
|
/* Flag to indicate legacy AUDIT_LOGINUID unset usage */
|
|
|
|
#define AUDIT_LOGINUID_LEGACY 0x1
|
|
|
|
|
2008-03-01 20:03:14 +00:00
|
|
|
struct audit_field {
|
|
|
|
u32 type;
|
2014-03-26 11:26:47 +00:00
|
|
|
union {
|
|
|
|
u32 val;
|
|
|
|
kuid_t uid;
|
|
|
|
kgid_t gid;
|
|
|
|
struct {
|
|
|
|
char *lsm_str;
|
|
|
|
void *lsm_rule;
|
|
|
|
};
|
|
|
|
};
|
2008-03-01 20:03:14 +00:00
|
|
|
u32 op;
|
|
|
|
};
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2019-04-10 09:14:20 +00:00
|
|
|
enum audit_ntp_type {
|
|
|
|
AUDIT_NTP_OFFSET,
|
|
|
|
AUDIT_NTP_FREQ,
|
|
|
|
AUDIT_NTP_STATUS,
|
|
|
|
AUDIT_NTP_TAI,
|
|
|
|
AUDIT_NTP_TICK,
|
|
|
|
AUDIT_NTP_ADJUST,
|
|
|
|
|
|
|
|
AUDIT_NTP_NVALS /* count */
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef CONFIG_AUDITSYSCALL
|
|
|
|
struct audit_ntp_val {
|
|
|
|
long long oldval, newval;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct audit_ntp_data {
|
|
|
|
struct audit_ntp_val vals[AUDIT_NTP_NVALS];
|
|
|
|
};
|
|
|
|
#else
|
|
|
|
struct audit_ntp_data {};
|
|
|
|
#endif
|
|
|
|
|
2020-04-22 21:39:28 +00:00
|
|
|
enum audit_nfcfgop {
|
|
|
|
AUDIT_XT_OP_REGISTER,
|
|
|
|
AUDIT_XT_OP_REPLACE,
|
2020-04-22 21:39:29 +00:00
|
|
|
AUDIT_XT_OP_UNREGISTER,
|
2020-06-04 13:20:49 +00:00
|
|
|
AUDIT_NFT_OP_TABLE_REGISTER,
|
|
|
|
AUDIT_NFT_OP_TABLE_UNREGISTER,
|
|
|
|
AUDIT_NFT_OP_CHAIN_REGISTER,
|
|
|
|
AUDIT_NFT_OP_CHAIN_UNREGISTER,
|
|
|
|
AUDIT_NFT_OP_RULE_REGISTER,
|
|
|
|
AUDIT_NFT_OP_RULE_UNREGISTER,
|
|
|
|
AUDIT_NFT_OP_SET_REGISTER,
|
|
|
|
AUDIT_NFT_OP_SET_UNREGISTER,
|
|
|
|
AUDIT_NFT_OP_SETELEM_REGISTER,
|
|
|
|
AUDIT_NFT_OP_SETELEM_UNREGISTER,
|
|
|
|
AUDIT_NFT_OP_GEN_REGISTER,
|
|
|
|
AUDIT_NFT_OP_OBJ_REGISTER,
|
|
|
|
AUDIT_NFT_OP_OBJ_UNREGISTER,
|
|
|
|
AUDIT_NFT_OP_OBJ_RESET,
|
|
|
|
AUDIT_NFT_OP_FLOWTABLE_REGISTER,
|
|
|
|
AUDIT_NFT_OP_FLOWTABLE_UNREGISTER,
|
|
|
|
AUDIT_NFT_OP_INVALID,
|
2020-04-22 21:39:28 +00:00
|
|
|
};
|
|
|
|
|
2013-05-22 16:54:49 +00:00
|
|
|
extern int is_audit_feature_set(int which);
|
|
|
|
|
2006-07-01 07:56:16 +00:00
|
|
|
extern int __init audit_register_class(int class, unsigned *list);
|
2006-08-31 23:26:40 +00:00
|
|
|
extern int audit_classify_syscall(int abi, unsigned syscall);
|
2007-03-29 22:01:04 +00:00
|
|
|
extern int audit_classify_arch(int arch);
|
2014-03-15 05:48:00 +00: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-14 00:58:48 +00:00
|
|
|
extern int audit_classify_compat_syscall(int abi, unsigned syscall);
|
2012-10-10 19:25:22 +00: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 19:25:23 +00:00
|
|
|
#define AUDIT_TYPE_PARENT 2 /* a parent audit record */
|
2012-10-10 19:25:25 +00:00
|
|
|
#define AUDIT_TYPE_CHILD_DELETE 3 /* a child being deleted */
|
|
|
|
#define AUDIT_TYPE_CHILD_CREATE 4 /* a child being created */
|
2012-10-10 19:25:22 +00:00
|
|
|
|
2013-04-07 08:55:23 +00:00
|
|
|
/* maximized args number that audit_socketcall can process */
|
|
|
|
#define AUDITSC_ARGS 6
|
|
|
|
|
2016-01-10 06:55:33 +00:00
|
|
|
/* bit values for ->signal->audit_tty */
|
|
|
|
#define AUDIT_TTY_ENABLE BIT(0)
|
|
|
|
#define AUDIT_TTY_LOG_PASSWD BIT(1)
|
|
|
|
|
2012-10-10 19:25:28 +00:00
|
|
|
struct filename;
|
|
|
|
|
2018-06-05 23:20:39 +00:00
|
|
|
#define AUDIT_OFF 0
|
|
|
|
#define AUDIT_ON 1
|
|
|
|
#define AUDIT_LOCKED 2
|
2016-01-13 14:18:55 +00: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);
|
2019-10-02 23:41:58 +00:00
|
|
|
extern void audit_log_path_denied(int type,
|
|
|
|
const char *operation);
|
2016-01-13 14:18:55 +00:00
|
|
|
extern void audit_log_lost(const char *message);
|
|
|
|
|
|
|
|
extern int audit_log_task_context(struct audit_buffer *ab);
|
2018-11-26 23:40:07 +00:00
|
|
|
extern void audit_log_task_info(struct audit_buffer *ab);
|
2016-01-13 14:18:55 +00:00
|
|
|
|
|
|
|
extern int audit_update_lsm_rules(void);
|
|
|
|
|
|
|
|
/* Private API (for audit.c only) */
|
2017-05-02 14:16:05 +00:00
|
|
|
extern int audit_rule_change(int type, int seq, void *data, size_t datasz);
|
2016-01-13 14:18:55 +00:00
|
|
|
extern int audit_list_rules_send(struct sk_buff *request_skb, int seq);
|
|
|
|
|
2019-01-22 22:06:39 +00:00
|
|
|
extern int audit_set_loginuid(kuid_t loginuid);
|
|
|
|
|
|
|
|
static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
|
|
|
|
{
|
|
|
|
return tsk->loginuid;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned int audit_get_sessionid(struct task_struct *tsk)
|
|
|
|
{
|
|
|
|
return tsk->sessionid;
|
|
|
|
}
|
|
|
|
|
2016-01-13 14:18:55 +00:00
|
|
|
extern u32 audit_enabled;
|
2019-05-10 16:21:49 +00:00
|
|
|
|
|
|
|
extern int audit_signal_info(int sig, struct task_struct *t);
|
|
|
|
|
2016-01-13 14:18:55 +00:00
|
|
|
#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)
|
|
|
|
{ }
|
2019-10-02 23:41:58 +00:00
|
|
|
static inline void audit_log_path_denied(int type, const char *operation)
|
2016-01-13 14:18:55 +00:00
|
|
|
{ }
|
|
|
|
static inline int audit_log_task_context(struct audit_buffer *ab)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2018-11-26 23:40:07 +00:00
|
|
|
static inline void audit_log_task_info(struct audit_buffer *ab)
|
2016-01-13 14:18:55 +00:00
|
|
|
{ }
|
2019-01-22 22:06:39 +00:00
|
|
|
|
|
|
|
static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
|
|
|
|
{
|
|
|
|
return INVALID_UID;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned int audit_get_sessionid(struct task_struct *tsk)
|
|
|
|
{
|
|
|
|
return AUDIT_SID_UNSET;
|
|
|
|
}
|
|
|
|
|
2018-06-05 23:20:39 +00:00
|
|
|
#define audit_enabled AUDIT_OFF
|
2019-05-10 16:21:49 +00:00
|
|
|
|
|
|
|
static inline int audit_signal_info(int sig, struct task_struct *t)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-01-13 14:18:55 +00:00
|
|
|
#endif /* CONFIG_AUDIT */
|
|
|
|
|
2014-03-25 13:25:41 +00:00
|
|
|
#ifdef CONFIG_AUDIT_COMPAT_GENERIC
|
2014-03-24 16:13:48 +00:00
|
|
|
#define audit_is_compat(arch) (!((arch) & __AUDIT_ARCH_64BIT))
|
|
|
|
#else
|
|
|
|
#define audit_is_compat(arch) false
|
|
|
|
#endif
|
|
|
|
|
2019-07-14 17:22:27 +00:00
|
|
|
#define AUDIT_INODE_PARENT 1 /* dentry represents the parent */
|
|
|
|
#define AUDIT_INODE_HIDDEN 2 /* audit record should be hidden */
|
|
|
|
#define AUDIT_INODE_NOEVAL 4 /* audit record incomplete */
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifdef CONFIG_AUDITSYSCALL
|
2014-04-22 15:46:16 +00:00
|
|
|
#include <asm/syscall.h> /* for syscall_get_arch() */
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* These are defined in auditsc.c */
|
|
|
|
/* Public API */
|
|
|
|
extern int audit_alloc(struct task_struct *task);
|
2012-01-03 19:23:07 +00:00
|
|
|
extern void __audit_free(struct task_struct *task);
|
2014-03-04 15:38:06 +00:00
|
|
|
extern void __audit_syscall_entry(int major, unsigned long a0, unsigned long a1,
|
2012-01-03 19:23:06 +00:00
|
|
|
unsigned long a2, unsigned long a3);
|
2012-01-03 19:23:06 +00:00
|
|
|
extern void __audit_syscall_exit(int ret_success, long ret_value);
|
2012-10-10 19:25:28 +00:00
|
|
|
extern struct filename *__audit_reusename(const __user char *uptr);
|
2012-10-10 19:25:28 +00:00
|
|
|
extern void __audit_getname(struct filename *name);
|
2020-07-03 16:56:19 +00:00
|
|
|
extern void __audit_getcwd(void);
|
2012-10-10 20:43:13 +00:00
|
|
|
extern void __audit_inode(struct filename *name, const struct dentry *dentry,
|
2013-07-08 22:59:36 +00:00
|
|
|
unsigned int flags);
|
2014-10-31 21:44:57 +00:00
|
|
|
extern void __audit_file(const struct file *);
|
2015-12-24 16:09:39 +00:00
|
|
|
extern void __audit_inode_child(struct inode *parent,
|
2012-10-10 19:25:25 +00: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);
|
seccomp: Audit attempts to modify the actions_logged sysctl
The decision to log a seccomp action will always be subject to the
value of the kernel.seccomp.actions_logged sysctl, even for processes
that are being inspected via the audit subsystem, in an upcoming patch.
Therefore, we need to emit an audit record on attempts at writing to the
actions_logged sysctl when auditing is enabled.
This patch updates the write handler for the actions_logged sysctl to
emit an audit record on attempts to write to the sysctl. Successful
writes to the sysctl will result in a record that includes a normalized
list of logged actions in the "actions" field and a "res" field equal to
1. Unsuccessful writes to the sysctl will result in a record that
doesn't include the "actions" field and has a "res" field equal to 0.
Not all unsuccessful writes to the sysctl are audited. For example, an
audit record will not be emitted if an unprivileged process attempts to
open the sysctl file for reading since that access control check is not
part of the sysctl's write handler.
Below are some example audit records when writing various strings to the
actions_logged sysctl.
Writing "not-a-real-action", when the kernel.seccomp.actions_logged
sysctl previously was "kill_process kill_thread trap errno trace log",
emits this audit record:
type=CONFIG_CHANGE msg=audit(1525392371.454:120): op=seccomp-logging
actions=? old-actions=kill_process,kill_thread,trap,errno,trace,log
res=0
If you then write "kill_process kill_thread errno trace log", this audit
record is emitted:
type=CONFIG_CHANGE msg=audit(1525392401.645:126): op=seccomp-logging
actions=kill_process,kill_thread,errno,trace,log
old-actions=kill_process,kill_thread,trap,errno,trace,log res=1
If you then write "log log errno trace kill_process kill_thread", which
is unordered and contains the log action twice, it results in the same
actions value as the previous record:
type=CONFIG_CHANGE msg=audit(1525392436.354:132): op=seccomp-logging
actions=kill_process,kill_thread,errno,trace,log
old-actions=kill_process,kill_thread,errno,trace,log res=1
If you then write an empty string to the sysctl, this audit record is
emitted:
type=CONFIG_CHANGE msg=audit(1525392494.413:138): op=seccomp-logging
actions=(none) old-actions=kill_process,kill_thread,errno,trace,log
res=1
No audit records are generated when reading the actions_logged sysctl.
Suggested-by: Steve Grubb <sgrubb@redhat.com>
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Paul Moore <paul@paul-moore.com>
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 17:58:35 +00:00
|
|
|
extern void __audit_ptrace(struct task_struct *t);
|
|
|
|
|
2018-05-13 01:58:21 +00:00
|
|
|
static inline void audit_set_context(struct task_struct *task, struct audit_context *ctx)
|
|
|
|
{
|
|
|
|
task->audit_context = ctx;
|
|
|
|
}
|
|
|
|
|
2018-05-13 01:58:20 +00:00
|
|
|
static inline struct audit_context *audit_context(void)
|
|
|
|
{
|
|
|
|
return current->audit_context;
|
|
|
|
}
|
|
|
|
|
2015-11-04 13:23:51 +00:00
|
|
|
static inline bool audit_dummy_context(void)
|
2006-08-03 14:59:26 +00:00
|
|
|
{
|
2018-05-13 01:58:20 +00:00
|
|
|
void *p = audit_context();
|
2006-08-03 14:59:26 +00:00
|
|
|
return !p || *(int *)p;
|
|
|
|
}
|
2012-01-03 19:23:07 +00:00
|
|
|
static inline void audit_free(struct task_struct *task)
|
|
|
|
{
|
|
|
|
if (unlikely(task->audit_context))
|
|
|
|
__audit_free(task);
|
|
|
|
}
|
2014-03-11 17:29:28 +00:00
|
|
|
static inline void audit_syscall_entry(int major, unsigned long a0,
|
2012-01-03 19:23:06 +00:00
|
|
|
unsigned long a1, unsigned long a2,
|
|
|
|
unsigned long a3)
|
|
|
|
{
|
2018-05-13 01:58:20 +00:00
|
|
|
if (unlikely(audit_context()))
|
2014-03-04 15:38:06 +00:00
|
|
|
__audit_syscall_entry(major, a0, a1, a2, a3);
|
2012-01-03 19:23:06 +00:00
|
|
|
}
|
2012-01-03 19:23:06 +00:00
|
|
|
static inline void audit_syscall_exit(void *pt_regs)
|
|
|
|
{
|
2018-05-13 01:58:20 +00:00
|
|
|
if (unlikely(audit_context())) {
|
2012-01-03 19:23:06 +00:00
|
|
|
int success = is_syscall_success(pt_regs);
|
2014-01-13 21:33:09 +00:00
|
|
|
long return_code = regs_return_value(pt_regs);
|
2012-01-03 19:23:06 +00:00
|
|
|
|
|
|
|
__audit_syscall_exit(success, return_code);
|
|
|
|
}
|
|
|
|
}
|
2012-10-10 19:25:28 +00: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 19:25:28 +00:00
|
|
|
static inline void audit_getname(struct filename *name)
|
2006-05-18 20:01:30 +00:00
|
|
|
{
|
2006-07-16 10:38:45 +00:00
|
|
|
if (unlikely(!audit_dummy_context()))
|
2006-05-18 20:01:30 +00:00
|
|
|
__audit_getname(name);
|
|
|
|
}
|
2020-07-03 16:56:19 +00:00
|
|
|
static inline void audit_getcwd(void)
|
|
|
|
{
|
|
|
|
if (unlikely(audit_context()))
|
|
|
|
__audit_getcwd();
|
|
|
|
}
|
2013-07-08 22:59:36 +00:00
|
|
|
static inline void audit_inode(struct filename *name,
|
|
|
|
const struct dentry *dentry,
|
2019-07-14 17:22:27 +00:00
|
|
|
unsigned int aflags) {
|
|
|
|
if (unlikely(!audit_dummy_context()))
|
2019-01-23 18:35:00 +00:00
|
|
|
__audit_inode(name, dentry, aflags);
|
2013-07-08 22:59:36 +00:00
|
|
|
}
|
2014-10-31 21:44:57 +00:00
|
|
|
static inline void audit_file(struct file *file)
|
|
|
|
{
|
|
|
|
if (unlikely(!audit_dummy_context()))
|
|
|
|
__audit_file(file);
|
|
|
|
}
|
2013-07-08 22:59:36 +00:00
|
|
|
static inline void audit_inode_parent_hidden(struct filename *name,
|
|
|
|
const struct dentry *dentry)
|
|
|
|
{
|
2006-07-16 10:38:45 +00:00
|
|
|
if (unlikely(!audit_dummy_context()))
|
2013-07-08 22:59:36 +00:00
|
|
|
__audit_inode(name, dentry,
|
|
|
|
AUDIT_INODE_PARENT | AUDIT_INODE_HIDDEN);
|
2005-11-03 16:00:25 +00:00
|
|
|
}
|
2015-12-24 16:09:39 +00:00
|
|
|
static inline void audit_inode_child(struct inode *parent,
|
2012-10-10 19:25:25 +00:00
|
|
|
const struct dentry *dentry,
|
|
|
|
const unsigned char type) {
|
2006-07-16 10:38:45 +00:00
|
|
|
if (unlikely(!audit_dummy_context()))
|
2012-10-10 19:25:25 +00:00
|
|
|
__audit_inode_child(parent, dentry, type);
|
2005-11-03 16:00:25 +00:00
|
|
|
}
|
2007-04-19 14:28:21 +00:00
|
|
|
void audit_core_dumps(long signr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-03-20 17:58:35 +00:00
|
|
|
static inline void audit_ptrace(struct task_struct *t)
|
|
|
|
{
|
|
|
|
if (unlikely(!audit_dummy_context()))
|
|
|
|
__audit_ptrace(t);
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Private API (for audit.c only) */
|
2008-12-10 08:40:06 +00:00
|
|
|
extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp);
|
2011-07-27 18:03:22 +00:00
|
|
|
extern void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode);
|
2013-10-30 21:56:13 +00:00
|
|
|
extern void __audit_bprm(struct linux_binprm *bprm);
|
2013-04-07 08:55:23 +00:00
|
|
|
extern int __audit_socketcall(int nargs, unsigned long *args);
|
2012-01-03 19:23:07 +00:00
|
|
|
extern int __audit_sockaddr(int len, void *addr);
|
2008-12-14 09:57:47 +00:00
|
|
|
extern void __audit_fd_pair(int fd1, int fd2);
|
2011-07-26 09:26:10 +00:00
|
|
|
extern void __audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr);
|
2017-08-03 02:51:11 +00: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 12:16:12 +00:00
|
|
|
extern void __audit_mq_notify(mqd_t mqdes, const struct sigevent *notification);
|
2008-12-10 11:58:59 +00:00
|
|
|
extern void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat);
|
CRED: Inaugurate COW credentials
Inaugurate copy-on-write credentials management. This uses RCU to manage the
credentials pointer in the task_struct with respect to accesses by other tasks.
A process may only modify its own credentials, and so does not need locking to
access or modify its own credentials.
A mutex (cred_replace_mutex) is added to the task_struct to control the effect
of PTRACE_ATTACHED on credential calculations, particularly with respect to
execve().
With this patch, the contents of an active credentials struct may not be
changed directly; rather a new set of credentials must be prepared, modified
and committed using something like the following sequence of events:
struct cred *new = prepare_creds();
int ret = blah(new);
if (ret < 0) {
abort_creds(new);
return ret;
}
return commit_creds(new);
There are some exceptions to this rule: the keyrings pointed to by the active
credentials may be instantiated - keyrings violate the COW rule as managing
COW keyrings is tricky, given that it is possible for a task to directly alter
the keys in a keyring in use by another task.
To help enforce this, various pointers to sets of credentials, such as those in
the task_struct, are declared const. The purpose of this is compile-time
discouragement of altering credentials through those pointers. Once a set of
credentials has been made public through one of these pointers, it may not be
modified, except under special circumstances:
(1) Its reference count may incremented and decremented.
(2) The keyrings to which it points may be modified, but not replaced.
The only safe way to modify anything else is to create a replacement and commit
using the functions described in Documentation/credentials.txt (which will be
added by a later patch).
This patch and the preceding patches have been tested with the LTP SELinux
testsuite.
This patch makes several logical sets of alteration:
(1) execve().
This now prepares and commits credentials in various places in the
security code rather than altering the current creds directly.
(2) Temporary credential overrides.
do_coredump() and sys_faccessat() now prepare their own credentials and
temporarily override the ones currently on the acting thread, whilst
preventing interference from other threads by holding cred_replace_mutex
on the thread being dumped.
This will be replaced in a future patch by something that hands down the
credentials directly to the functions being called, rather than altering
the task's objective credentials.
(3) LSM interface.
A number of functions have been changed, added or removed:
(*) security_capset_check(), ->capset_check()
(*) security_capset_set(), ->capset_set()
Removed in favour of security_capset().
(*) security_capset(), ->capset()
New. This is passed a pointer to the new creds, a pointer to the old
creds and the proposed capability sets. It should fill in the new
creds or return an error. All pointers, barring the pointer to the
new creds, are now const.
(*) security_bprm_apply_creds(), ->bprm_apply_creds()
Changed; now returns a value, which will cause the process to be
killed if it's an error.
(*) security_task_alloc(), ->task_alloc_security()
Removed in favour of security_prepare_creds().
(*) security_cred_free(), ->cred_free()
New. Free security data attached to cred->security.
(*) security_prepare_creds(), ->cred_prepare()
New. Duplicate any security data attached to cred->security.
(*) security_commit_creds(), ->cred_commit()
New. Apply any security effects for the upcoming installation of new
security by commit_creds().
(*) security_task_post_setuid(), ->task_post_setuid()
Removed in favour of security_task_fix_setuid().
(*) security_task_fix_setuid(), ->task_fix_setuid()
Fix up the proposed new credentials for setuid(). This is used by
cap_set_fix_setuid() to implicitly adjust capabilities in line with
setuid() changes. Changes are made to the new credentials, rather
than the task itself as in security_task_post_setuid().
(*) security_task_reparent_to_init(), ->task_reparent_to_init()
Removed. Instead the task being reparented to init is referred
directly to init's credentials.
NOTE! This results in the loss of some state: SELinux's osid no
longer records the sid of the thread that forked it.
(*) security_key_alloc(), ->key_alloc()
(*) security_key_permission(), ->key_permission()
Changed. These now take cred pointers rather than task pointers to
refer to the security context.
(4) sys_capset().
This has been simplified and uses less locking. The LSM functions it
calls have been merged.
(5) reparent_to_kthreadd().
This gives the current thread the same credentials as init by simply using
commit_thread() to point that way.
(6) __sigqueue_alloc() and switch_uid()
__sigqueue_alloc() can't stop the target task from changing its creds
beneath it, so this function gets a reference to the currently applicable
user_struct which it then passes into the sigqueue struct it returns if
successful.
switch_uid() is now called from commit_creds(), and possibly should be
folded into that. commit_creds() should take care of protecting
__sigqueue_alloc().
(7) [sg]et[ug]id() and co and [sg]et_current_groups.
The set functions now all use prepare_creds(), commit_creds() and
abort_creds() to build and check a new set of credentials before applying
it.
security_task_set[ug]id() is called inside the prepared section. This
guarantees that nothing else will affect the creds until we've finished.
The calling of set_dumpable() has been moved into commit_creds().
Much of the functionality of set_user() has been moved into
commit_creds().
The get functions all simply access the data directly.
(8) security_task_prctl() and cap_task_prctl().
security_task_prctl() has been modified to return -ENOSYS if it doesn't
want to handle a function, or otherwise return the return value directly
rather than through an argument.
Additionally, cap_task_prctl() now prepares a new set of credentials, even
if it doesn't end up using it.
(9) Keyrings.
A number of changes have been made to the keyrings code:
(a) switch_uid_keyring(), copy_keys(), exit_keys() and suid_keys() have
all been dropped and built in to the credentials functions directly.
They may want separating out again later.
(b) key_alloc() and search_process_keyrings() now take a cred pointer
rather than a task pointer to specify the security context.
(c) copy_creds() gives a new thread within the same thread group a new
thread keyring if its parent had one, otherwise it discards the thread
keyring.
(d) The authorisation key now points directly to the credentials to extend
the search into rather pointing to the task that carries them.
(e) Installing thread, process or session keyrings causes a new set of
credentials to be created, even though it's not strictly necessary for
process or session keyrings (they're shared).
(10) Usermode helper.
The usermode helper code now carries a cred struct pointer in its
subprocess_info struct instead of a new session keyring pointer. This set
of credentials is derived from init_cred and installed on the new process
after it has been cloned.
call_usermodehelper_setup() allocates the new credentials and
call_usermodehelper_freeinfo() discards them if they haven't been used. A
special cred function (prepare_usermodeinfo_creds()) is provided
specifically for call_usermodehelper_setup() to call.
call_usermodehelper_setkeys() adjusts the credentials to sport the
supplied keyring as the new session keyring.
(11) SELinux.
SELinux has a number of changes, in addition to those to support the LSM
interface changes mentioned above:
(a) selinux_setprocattr() no longer does its check for whether the
current ptracer can access processes with the new SID inside the lock
that covers getting the ptracer's SID. Whilst this lock ensures that
the check is done with the ptracer pinned, the result is only valid
until the lock is released, so there's no point doing it inside the
lock.
(12) is_single_threaded().
This function has been extracted from selinux_setprocattr() and put into
a file of its own in the lib/ directory as join_session_keyring() now
wants to use it too.
The code in SELinux just checked to see whether a task shared mm_structs
with other tasks (CLONE_VM), but that isn't good enough. We really want
to know if they're part of the same thread group (CLONE_THREAD).
(13) nfsd.
The NFS server daemon now has to use the COW credentials to set the
credentials it is going to use. It really needs to pass the credentials
down to the functions it calls, but it can't do that until other patches
in this series have been applied.
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: James Morris <jmorris@namei.org>
Signed-off-by: James Morris <jmorris@namei.org>
2008-11-13 23:39:23 +00:00
|
|
|
extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm,
|
|
|
|
const struct cred *new,
|
|
|
|
const struct cred *old);
|
2013-03-19 07:02:25 +00:00
|
|
|
extern void __audit_log_capset(const struct cred *new, const struct cred *old);
|
2010-10-30 06:54:44 +00:00
|
|
|
extern void __audit_mmap_fd(int fd, int flags);
|
2017-02-04 18:10:38 +00:00
|
|
|
extern void __audit_log_kern_module(char *name);
|
2017-10-03 00:21:39 +00:00
|
|
|
extern void __audit_fanotify(unsigned int response);
|
2019-04-10 09:14:19 +00:00
|
|
|
extern void __audit_tk_injoffset(struct timespec64 offset);
|
2019-04-10 09:14:20 +00:00
|
|
|
extern void __audit_ntp_log(const struct audit_ntp_data *ad);
|
2020-04-22 21:39:28 +00:00
|
|
|
extern void __audit_log_nfcfg(const char *name, u8 af, unsigned int nentries,
|
2020-06-28 03:24:19 +00:00
|
|
|
enum audit_nfcfgop op, gfp_t gfp);
|
2006-05-18 20:01:30 +00:00
|
|
|
|
2008-12-10 08:40:06 +00:00
|
|
|
static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp)
|
2006-05-18 20:01:30 +00:00
|
|
|
{
|
2006-07-16 10:38:45 +00:00
|
|
|
if (unlikely(!audit_dummy_context()))
|
2008-12-10 08:40:06 +00:00
|
|
|
__audit_ipc_obj(ipcp);
|
2007-02-07 06:48:00 +00:00
|
|
|
}
|
2008-12-14 09:57:47 +00:00
|
|
|
static inline void audit_fd_pair(int fd1, int fd2)
|
2006-05-18 20:01:30 +00:00
|
|
|
{
|
2006-07-16 10:38:45 +00:00
|
|
|
if (unlikely(!audit_dummy_context()))
|
2008-12-14 09:57:47 +00:00
|
|
|
__audit_fd_pair(fd1, fd2);
|
2006-05-18 20:01:30 +00:00
|
|
|
}
|
2011-07-27 18:03:22 +00:00
|
|
|
static inline void audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode)
|
2006-05-24 21:09:55 +00:00
|
|
|
{
|
2006-07-16 10:38:45 +00:00
|
|
|
if (unlikely(!audit_dummy_context()))
|
2008-12-10 08:47:15 +00:00
|
|
|
__audit_ipc_set_perm(qbytes, uid, gid, mode);
|
2006-05-24 21:09:55 +00:00
|
|
|
}
|
2013-10-30 22:05:24 +00:00
|
|
|
static inline void audit_bprm(struct linux_binprm *bprm)
|
2012-01-03 19:23:07 +00:00
|
|
|
{
|
|
|
|
if (unlikely(!audit_dummy_context()))
|
2013-10-30 21:56:13 +00:00
|
|
|
__audit_bprm(bprm);
|
2012-01-03 19:23:07 +00:00
|
|
|
}
|
2013-04-07 08:55:23 +00:00
|
|
|
static inline int audit_socketcall(int nargs, unsigned long *args)
|
2012-01-03 19:23:07 +00:00
|
|
|
{
|
|
|
|
if (unlikely(!audit_dummy_context()))
|
2013-04-07 08:55:23 +00:00
|
|
|
return __audit_socketcall(nargs, args);
|
|
|
|
return 0;
|
2012-01-03 19:23:07 +00:00
|
|
|
}
|
2017-01-17 16:07:15 +00: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 19:23:07 +00: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 09:26:10 +00:00
|
|
|
static inline void audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr)
|
2006-05-24 21:09:55 +00:00
|
|
|
{
|
2006-07-16 10:38:45 +00:00
|
|
|
if (unlikely(!audit_dummy_context()))
|
2008-12-14 09:02:26 +00:00
|
|
|
__audit_mq_open(oflag, mode, attr);
|
2006-05-24 21:09:55 +00:00
|
|
|
}
|
2017-08-03 02:51:11 +00: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 21:09:55 +00:00
|
|
|
{
|
2006-07-16 10:38:45 +00:00
|
|
|
if (unlikely(!audit_dummy_context()))
|
2008-12-14 08:46:48 +00:00
|
|
|
__audit_mq_sendrecv(mqdes, msg_len, msg_prio, abs_timeout);
|
2006-05-24 21:09:55 +00:00
|
|
|
}
|
2008-12-10 12:16:12 +00:00
|
|
|
static inline void audit_mq_notify(mqd_t mqdes, const struct sigevent *notification)
|
2006-05-24 21:09:55 +00:00
|
|
|
{
|
2006-07-16 10:38:45 +00:00
|
|
|
if (unlikely(!audit_dummy_context()))
|
2008-12-10 12:16:12 +00:00
|
|
|
__audit_mq_notify(mqdes, notification);
|
2006-05-24 21:09:55 +00:00
|
|
|
}
|
2008-12-10 11:58:59 +00:00
|
|
|
static inline void audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat)
|
2006-05-24 21:09:55 +00:00
|
|
|
{
|
2006-07-16 10:38:45 +00:00
|
|
|
if (unlikely(!audit_dummy_context()))
|
2008-12-10 11:58:59 +00:00
|
|
|
__audit_mq_getsetattr(mqdes, mqstat);
|
2006-05-24 21:09:55 +00:00
|
|
|
}
|
2008-11-11 10:48:18 +00:00
|
|
|
|
CRED: Inaugurate COW credentials
Inaugurate copy-on-write credentials management. This uses RCU to manage the
credentials pointer in the task_struct with respect to accesses by other tasks.
A process may only modify its own credentials, and so does not need locking to
access or modify its own credentials.
A mutex (cred_replace_mutex) is added to the task_struct to control the effect
of PTRACE_ATTACHED on credential calculations, particularly with respect to
execve().
With this patch, the contents of an active credentials struct may not be
changed directly; rather a new set of credentials must be prepared, modified
and committed using something like the following sequence of events:
struct cred *new = prepare_creds();
int ret = blah(new);
if (ret < 0) {
abort_creds(new);
return ret;
}
return commit_creds(new);
There are some exceptions to this rule: the keyrings pointed to by the active
credentials may be instantiated - keyrings violate the COW rule as managing
COW keyrings is tricky, given that it is possible for a task to directly alter
the keys in a keyring in use by another task.
To help enforce this, various pointers to sets of credentials, such as those in
the task_struct, are declared const. The purpose of this is compile-time
discouragement of altering credentials through those pointers. Once a set of
credentials has been made public through one of these pointers, it may not be
modified, except under special circumstances:
(1) Its reference count may incremented and decremented.
(2) The keyrings to which it points may be modified, but not replaced.
The only safe way to modify anything else is to create a replacement and commit
using the functions described in Documentation/credentials.txt (which will be
added by a later patch).
This patch and the preceding patches have been tested with the LTP SELinux
testsuite.
This patch makes several logical sets of alteration:
(1) execve().
This now prepares and commits credentials in various places in the
security code rather than altering the current creds directly.
(2) Temporary credential overrides.
do_coredump() and sys_faccessat() now prepare their own credentials and
temporarily override the ones currently on the acting thread, whilst
preventing interference from other threads by holding cred_replace_mutex
on the thread being dumped.
This will be replaced in a future patch by something that hands down the
credentials directly to the functions being called, rather than altering
the task's objective credentials.
(3) LSM interface.
A number of functions have been changed, added or removed:
(*) security_capset_check(), ->capset_check()
(*) security_capset_set(), ->capset_set()
Removed in favour of security_capset().
(*) security_capset(), ->capset()
New. This is passed a pointer to the new creds, a pointer to the old
creds and the proposed capability sets. It should fill in the new
creds or return an error. All pointers, barring the pointer to the
new creds, are now const.
(*) security_bprm_apply_creds(), ->bprm_apply_creds()
Changed; now returns a value, which will cause the process to be
killed if it's an error.
(*) security_task_alloc(), ->task_alloc_security()
Removed in favour of security_prepare_creds().
(*) security_cred_free(), ->cred_free()
New. Free security data attached to cred->security.
(*) security_prepare_creds(), ->cred_prepare()
New. Duplicate any security data attached to cred->security.
(*) security_commit_creds(), ->cred_commit()
New. Apply any security effects for the upcoming installation of new
security by commit_creds().
(*) security_task_post_setuid(), ->task_post_setuid()
Removed in favour of security_task_fix_setuid().
(*) security_task_fix_setuid(), ->task_fix_setuid()
Fix up the proposed new credentials for setuid(). This is used by
cap_set_fix_setuid() to implicitly adjust capabilities in line with
setuid() changes. Changes are made to the new credentials, rather
than the task itself as in security_task_post_setuid().
(*) security_task_reparent_to_init(), ->task_reparent_to_init()
Removed. Instead the task being reparented to init is referred
directly to init's credentials.
NOTE! This results in the loss of some state: SELinux's osid no
longer records the sid of the thread that forked it.
(*) security_key_alloc(), ->key_alloc()
(*) security_key_permission(), ->key_permission()
Changed. These now take cred pointers rather than task pointers to
refer to the security context.
(4) sys_capset().
This has been simplified and uses less locking. The LSM functions it
calls have been merged.
(5) reparent_to_kthreadd().
This gives the current thread the same credentials as init by simply using
commit_thread() to point that way.
(6) __sigqueue_alloc() and switch_uid()
__sigqueue_alloc() can't stop the target task from changing its creds
beneath it, so this function gets a reference to the currently applicable
user_struct which it then passes into the sigqueue struct it returns if
successful.
switch_uid() is now called from commit_creds(), and possibly should be
folded into that. commit_creds() should take care of protecting
__sigqueue_alloc().
(7) [sg]et[ug]id() and co and [sg]et_current_groups.
The set functions now all use prepare_creds(), commit_creds() and
abort_creds() to build and check a new set of credentials before applying
it.
security_task_set[ug]id() is called inside the prepared section. This
guarantees that nothing else will affect the creds until we've finished.
The calling of set_dumpable() has been moved into commit_creds().
Much of the functionality of set_user() has been moved into
commit_creds().
The get functions all simply access the data directly.
(8) security_task_prctl() and cap_task_prctl().
security_task_prctl() has been modified to return -ENOSYS if it doesn't
want to handle a function, or otherwise return the return value directly
rather than through an argument.
Additionally, cap_task_prctl() now prepares a new set of credentials, even
if it doesn't end up using it.
(9) Keyrings.
A number of changes have been made to the keyrings code:
(a) switch_uid_keyring(), copy_keys(), exit_keys() and suid_keys() have
all been dropped and built in to the credentials functions directly.
They may want separating out again later.
(b) key_alloc() and search_process_keyrings() now take a cred pointer
rather than a task pointer to specify the security context.
(c) copy_creds() gives a new thread within the same thread group a new
thread keyring if its parent had one, otherwise it discards the thread
keyring.
(d) The authorisation key now points directly to the credentials to extend
the search into rather pointing to the task that carries them.
(e) Installing thread, process or session keyrings causes a new set of
credentials to be created, even though it's not strictly necessary for
process or session keyrings (they're shared).
(10) Usermode helper.
The usermode helper code now carries a cred struct pointer in its
subprocess_info struct instead of a new session keyring pointer. This set
of credentials is derived from init_cred and installed on the new process
after it has been cloned.
call_usermodehelper_setup() allocates the new credentials and
call_usermodehelper_freeinfo() discards them if they haven't been used. A
special cred function (prepare_usermodeinfo_creds()) is provided
specifically for call_usermodehelper_setup() to call.
call_usermodehelper_setkeys() adjusts the credentials to sport the
supplied keyring as the new session keyring.
(11) SELinux.
SELinux has a number of changes, in addition to those to support the LSM
interface changes mentioned above:
(a) selinux_setprocattr() no longer does its check for whether the
current ptracer can access processes with the new SID inside the lock
that covers getting the ptracer's SID. Whilst this lock ensures that
the check is done with the ptracer pinned, the result is only valid
until the lock is released, so there's no point doing it inside the
lock.
(12) is_single_threaded().
This function has been extracted from selinux_setprocattr() and put into
a file of its own in the lib/ directory as join_session_keyring() now
wants to use it too.
The code in SELinux just checked to see whether a task shared mm_structs
with other tasks (CLONE_VM), but that isn't good enough. We really want
to know if they're part of the same thread group (CLONE_THREAD).
(13) nfsd.
The NFS server daemon now has to use the COW credentials to set the
credentials it is going to use. It really needs to pass the credentials
down to the functions it calls, but it can't do that until other patches
in this series have been applied.
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: James Morris <jmorris@namei.org>
Signed-off-by: James Morris <jmorris@namei.org>
2008-11-13 23:39:23 +00:00
|
|
|
static inline int audit_log_bprm_fcaps(struct linux_binprm *bprm,
|
|
|
|
const struct cred *new,
|
|
|
|
const struct cred *old)
|
2008-11-11 10:48:18 +00:00
|
|
|
{
|
|
|
|
if (unlikely(!audit_dummy_context()))
|
CRED: Inaugurate COW credentials
Inaugurate copy-on-write credentials management. This uses RCU to manage the
credentials pointer in the task_struct with respect to accesses by other tasks.
A process may only modify its own credentials, and so does not need locking to
access or modify its own credentials.
A mutex (cred_replace_mutex) is added to the task_struct to control the effect
of PTRACE_ATTACHED on credential calculations, particularly with respect to
execve().
With this patch, the contents of an active credentials struct may not be
changed directly; rather a new set of credentials must be prepared, modified
and committed using something like the following sequence of events:
struct cred *new = prepare_creds();
int ret = blah(new);
if (ret < 0) {
abort_creds(new);
return ret;
}
return commit_creds(new);
There are some exceptions to this rule: the keyrings pointed to by the active
credentials may be instantiated - keyrings violate the COW rule as managing
COW keyrings is tricky, given that it is possible for a task to directly alter
the keys in a keyring in use by another task.
To help enforce this, various pointers to sets of credentials, such as those in
the task_struct, are declared const. The purpose of this is compile-time
discouragement of altering credentials through those pointers. Once a set of
credentials has been made public through one of these pointers, it may not be
modified, except under special circumstances:
(1) Its reference count may incremented and decremented.
(2) The keyrings to which it points may be modified, but not replaced.
The only safe way to modify anything else is to create a replacement and commit
using the functions described in Documentation/credentials.txt (which will be
added by a later patch).
This patch and the preceding patches have been tested with the LTP SELinux
testsuite.
This patch makes several logical sets of alteration:
(1) execve().
This now prepares and commits credentials in various places in the
security code rather than altering the current creds directly.
(2) Temporary credential overrides.
do_coredump() and sys_faccessat() now prepare their own credentials and
temporarily override the ones currently on the acting thread, whilst
preventing interference from other threads by holding cred_replace_mutex
on the thread being dumped.
This will be replaced in a future patch by something that hands down the
credentials directly to the functions being called, rather than altering
the task's objective credentials.
(3) LSM interface.
A number of functions have been changed, added or removed:
(*) security_capset_check(), ->capset_check()
(*) security_capset_set(), ->capset_set()
Removed in favour of security_capset().
(*) security_capset(), ->capset()
New. This is passed a pointer to the new creds, a pointer to the old
creds and the proposed capability sets. It should fill in the new
creds or return an error. All pointers, barring the pointer to the
new creds, are now const.
(*) security_bprm_apply_creds(), ->bprm_apply_creds()
Changed; now returns a value, which will cause the process to be
killed if it's an error.
(*) security_task_alloc(), ->task_alloc_security()
Removed in favour of security_prepare_creds().
(*) security_cred_free(), ->cred_free()
New. Free security data attached to cred->security.
(*) security_prepare_creds(), ->cred_prepare()
New. Duplicate any security data attached to cred->security.
(*) security_commit_creds(), ->cred_commit()
New. Apply any security effects for the upcoming installation of new
security by commit_creds().
(*) security_task_post_setuid(), ->task_post_setuid()
Removed in favour of security_task_fix_setuid().
(*) security_task_fix_setuid(), ->task_fix_setuid()
Fix up the proposed new credentials for setuid(). This is used by
cap_set_fix_setuid() to implicitly adjust capabilities in line with
setuid() changes. Changes are made to the new credentials, rather
than the task itself as in security_task_post_setuid().
(*) security_task_reparent_to_init(), ->task_reparent_to_init()
Removed. Instead the task being reparented to init is referred
directly to init's credentials.
NOTE! This results in the loss of some state: SELinux's osid no
longer records the sid of the thread that forked it.
(*) security_key_alloc(), ->key_alloc()
(*) security_key_permission(), ->key_permission()
Changed. These now take cred pointers rather than task pointers to
refer to the security context.
(4) sys_capset().
This has been simplified and uses less locking. The LSM functions it
calls have been merged.
(5) reparent_to_kthreadd().
This gives the current thread the same credentials as init by simply using
commit_thread() to point that way.
(6) __sigqueue_alloc() and switch_uid()
__sigqueue_alloc() can't stop the target task from changing its creds
beneath it, so this function gets a reference to the currently applicable
user_struct which it then passes into the sigqueue struct it returns if
successful.
switch_uid() is now called from commit_creds(), and possibly should be
folded into that. commit_creds() should take care of protecting
__sigqueue_alloc().
(7) [sg]et[ug]id() and co and [sg]et_current_groups.
The set functions now all use prepare_creds(), commit_creds() and
abort_creds() to build and check a new set of credentials before applying
it.
security_task_set[ug]id() is called inside the prepared section. This
guarantees that nothing else will affect the creds until we've finished.
The calling of set_dumpable() has been moved into commit_creds().
Much of the functionality of set_user() has been moved into
commit_creds().
The get functions all simply access the data directly.
(8) security_task_prctl() and cap_task_prctl().
security_task_prctl() has been modified to return -ENOSYS if it doesn't
want to handle a function, or otherwise return the return value directly
rather than through an argument.
Additionally, cap_task_prctl() now prepares a new set of credentials, even
if it doesn't end up using it.
(9) Keyrings.
A number of changes have been made to the keyrings code:
(a) switch_uid_keyring(), copy_keys(), exit_keys() and suid_keys() have
all been dropped and built in to the credentials functions directly.
They may want separating out again later.
(b) key_alloc() and search_process_keyrings() now take a cred pointer
rather than a task pointer to specify the security context.
(c) copy_creds() gives a new thread within the same thread group a new
thread keyring if its parent had one, otherwise it discards the thread
keyring.
(d) The authorisation key now points directly to the credentials to extend
the search into rather pointing to the task that carries them.
(e) Installing thread, process or session keyrings causes a new set of
credentials to be created, even though it's not strictly necessary for
process or session keyrings (they're shared).
(10) Usermode helper.
The usermode helper code now carries a cred struct pointer in its
subprocess_info struct instead of a new session keyring pointer. This set
of credentials is derived from init_cred and installed on the new process
after it has been cloned.
call_usermodehelper_setup() allocates the new credentials and
call_usermodehelper_freeinfo() discards them if they haven't been used. A
special cred function (prepare_usermodeinfo_creds()) is provided
specifically for call_usermodehelper_setup() to call.
call_usermodehelper_setkeys() adjusts the credentials to sport the
supplied keyring as the new session keyring.
(11) SELinux.
SELinux has a number of changes, in addition to those to support the LSM
interface changes mentioned above:
(a) selinux_setprocattr() no longer does its check for whether the
current ptracer can access processes with the new SID inside the lock
that covers getting the ptracer's SID. Whilst this lock ensures that
the check is done with the ptracer pinned, the result is only valid
until the lock is released, so there's no point doing it inside the
lock.
(12) is_single_threaded().
This function has been extracted from selinux_setprocattr() and put into
a file of its own in the lib/ directory as join_session_keyring() now
wants to use it too.
The code in SELinux just checked to see whether a task shared mm_structs
with other tasks (CLONE_VM), but that isn't good enough. We really want
to know if they're part of the same thread group (CLONE_THREAD).
(13) nfsd.
The NFS server daemon now has to use the COW credentials to set the
credentials it is going to use. It really needs to pass the credentials
down to the functions it calls, but it can't do that until other patches
in this series have been applied.
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: James Morris <jmorris@namei.org>
Signed-off-by: James Morris <jmorris@namei.org>
2008-11-13 23:39:23 +00:00
|
|
|
return __audit_log_bprm_fcaps(bprm, new, old);
|
|
|
|
return 0;
|
2008-11-11 10:48:18 +00:00
|
|
|
}
|
|
|
|
|
2013-03-19 07:02:25 +00:00
|
|
|
static inline void audit_log_capset(const struct cred *new,
|
CRED: Inaugurate COW credentials
Inaugurate copy-on-write credentials management. This uses RCU to manage the
credentials pointer in the task_struct with respect to accesses by other tasks.
A process may only modify its own credentials, and so does not need locking to
access or modify its own credentials.
A mutex (cred_replace_mutex) is added to the task_struct to control the effect
of PTRACE_ATTACHED on credential calculations, particularly with respect to
execve().
With this patch, the contents of an active credentials struct may not be
changed directly; rather a new set of credentials must be prepared, modified
and committed using something like the following sequence of events:
struct cred *new = prepare_creds();
int ret = blah(new);
if (ret < 0) {
abort_creds(new);
return ret;
}
return commit_creds(new);
There are some exceptions to this rule: the keyrings pointed to by the active
credentials may be instantiated - keyrings violate the COW rule as managing
COW keyrings is tricky, given that it is possible for a task to directly alter
the keys in a keyring in use by another task.
To help enforce this, various pointers to sets of credentials, such as those in
the task_struct, are declared const. The purpose of this is compile-time
discouragement of altering credentials through those pointers. Once a set of
credentials has been made public through one of these pointers, it may not be
modified, except under special circumstances:
(1) Its reference count may incremented and decremented.
(2) The keyrings to which it points may be modified, but not replaced.
The only safe way to modify anything else is to create a replacement and commit
using the functions described in Documentation/credentials.txt (which will be
added by a later patch).
This patch and the preceding patches have been tested with the LTP SELinux
testsuite.
This patch makes several logical sets of alteration:
(1) execve().
This now prepares and commits credentials in various places in the
security code rather than altering the current creds directly.
(2) Temporary credential overrides.
do_coredump() and sys_faccessat() now prepare their own credentials and
temporarily override the ones currently on the acting thread, whilst
preventing interference from other threads by holding cred_replace_mutex
on the thread being dumped.
This will be replaced in a future patch by something that hands down the
credentials directly to the functions being called, rather than altering
the task's objective credentials.
(3) LSM interface.
A number of functions have been changed, added or removed:
(*) security_capset_check(), ->capset_check()
(*) security_capset_set(), ->capset_set()
Removed in favour of security_capset().
(*) security_capset(), ->capset()
New. This is passed a pointer to the new creds, a pointer to the old
creds and the proposed capability sets. It should fill in the new
creds or return an error. All pointers, barring the pointer to the
new creds, are now const.
(*) security_bprm_apply_creds(), ->bprm_apply_creds()
Changed; now returns a value, which will cause the process to be
killed if it's an error.
(*) security_task_alloc(), ->task_alloc_security()
Removed in favour of security_prepare_creds().
(*) security_cred_free(), ->cred_free()
New. Free security data attached to cred->security.
(*) security_prepare_creds(), ->cred_prepare()
New. Duplicate any security data attached to cred->security.
(*) security_commit_creds(), ->cred_commit()
New. Apply any security effects for the upcoming installation of new
security by commit_creds().
(*) security_task_post_setuid(), ->task_post_setuid()
Removed in favour of security_task_fix_setuid().
(*) security_task_fix_setuid(), ->task_fix_setuid()
Fix up the proposed new credentials for setuid(). This is used by
cap_set_fix_setuid() to implicitly adjust capabilities in line with
setuid() changes. Changes are made to the new credentials, rather
than the task itself as in security_task_post_setuid().
(*) security_task_reparent_to_init(), ->task_reparent_to_init()
Removed. Instead the task being reparented to init is referred
directly to init's credentials.
NOTE! This results in the loss of some state: SELinux's osid no
longer records the sid of the thread that forked it.
(*) security_key_alloc(), ->key_alloc()
(*) security_key_permission(), ->key_permission()
Changed. These now take cred pointers rather than task pointers to
refer to the security context.
(4) sys_capset().
This has been simplified and uses less locking. The LSM functions it
calls have been merged.
(5) reparent_to_kthreadd().
This gives the current thread the same credentials as init by simply using
commit_thread() to point that way.
(6) __sigqueue_alloc() and switch_uid()
__sigqueue_alloc() can't stop the target task from changing its creds
beneath it, so this function gets a reference to the currently applicable
user_struct which it then passes into the sigqueue struct it returns if
successful.
switch_uid() is now called from commit_creds(), and possibly should be
folded into that. commit_creds() should take care of protecting
__sigqueue_alloc().
(7) [sg]et[ug]id() and co and [sg]et_current_groups.
The set functions now all use prepare_creds(), commit_creds() and
abort_creds() to build and check a new set of credentials before applying
it.
security_task_set[ug]id() is called inside the prepared section. This
guarantees that nothing else will affect the creds until we've finished.
The calling of set_dumpable() has been moved into commit_creds().
Much of the functionality of set_user() has been moved into
commit_creds().
The get functions all simply access the data directly.
(8) security_task_prctl() and cap_task_prctl().
security_task_prctl() has been modified to return -ENOSYS if it doesn't
want to handle a function, or otherwise return the return value directly
rather than through an argument.
Additionally, cap_task_prctl() now prepares a new set of credentials, even
if it doesn't end up using it.
(9) Keyrings.
A number of changes have been made to the keyrings code:
(a) switch_uid_keyring(), copy_keys(), exit_keys() and suid_keys() have
all been dropped and built in to the credentials functions directly.
They may want separating out again later.
(b) key_alloc() and search_process_keyrings() now take a cred pointer
rather than a task pointer to specify the security context.
(c) copy_creds() gives a new thread within the same thread group a new
thread keyring if its parent had one, otherwise it discards the thread
keyring.
(d) The authorisation key now points directly to the credentials to extend
the search into rather pointing to the task that carries them.
(e) Installing thread, process or session keyrings causes a new set of
credentials to be created, even though it's not strictly necessary for
process or session keyrings (they're shared).
(10) Usermode helper.
The usermode helper code now carries a cred struct pointer in its
subprocess_info struct instead of a new session keyring pointer. This set
of credentials is derived from init_cred and installed on the new process
after it has been cloned.
call_usermodehelper_setup() allocates the new credentials and
call_usermodehelper_freeinfo() discards them if they haven't been used. A
special cred function (prepare_usermodeinfo_creds()) is provided
specifically for call_usermodehelper_setup() to call.
call_usermodehelper_setkeys() adjusts the credentials to sport the
supplied keyring as the new session keyring.
(11) SELinux.
SELinux has a number of changes, in addition to those to support the LSM
interface changes mentioned above:
(a) selinux_setprocattr() no longer does its check for whether the
current ptracer can access processes with the new SID inside the lock
that covers getting the ptracer's SID. Whilst this lock ensures that
the check is done with the ptracer pinned, the result is only valid
until the lock is released, so there's no point doing it inside the
lock.
(12) is_single_threaded().
This function has been extracted from selinux_setprocattr() and put into
a file of its own in the lib/ directory as join_session_keyring() now
wants to use it too.
The code in SELinux just checked to see whether a task shared mm_structs
with other tasks (CLONE_VM), but that isn't good enough. We really want
to know if they're part of the same thread group (CLONE_THREAD).
(13) nfsd.
The NFS server daemon now has to use the COW credentials to set the
credentials it is going to use. It really needs to pass the credentials
down to the functions it calls, but it can't do that until other patches
in this series have been applied.
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: James Morris <jmorris@namei.org>
Signed-off-by: James Morris <jmorris@namei.org>
2008-11-13 23:39:23 +00:00
|
|
|
const struct cred *old)
|
2008-11-11 10:48:22 +00:00
|
|
|
{
|
|
|
|
if (unlikely(!audit_dummy_context()))
|
2013-03-19 07:02:25 +00:00
|
|
|
__audit_log_capset(new, old);
|
2008-11-11 10:48:22 +00:00
|
|
|
}
|
|
|
|
|
2010-10-30 06:54:44 +00:00
|
|
|
static inline void audit_mmap_fd(int fd, int flags)
|
|
|
|
{
|
|
|
|
if (unlikely(!audit_dummy_context()))
|
|
|
|
__audit_mmap_fd(fd, flags);
|
|
|
|
}
|
|
|
|
|
2017-02-04 18:10:38 +00:00
|
|
|
static inline void audit_log_kern_module(char *name)
|
|
|
|
{
|
|
|
|
if (!audit_dummy_context())
|
|
|
|
__audit_log_kern_module(name);
|
|
|
|
}
|
|
|
|
|
2017-10-03 00:21:39 +00:00
|
|
|
static inline void audit_fanotify(unsigned int response)
|
|
|
|
{
|
|
|
|
if (!audit_dummy_context())
|
|
|
|
__audit_fanotify(response);
|
|
|
|
}
|
|
|
|
|
2019-04-10 09:14:19 +00:00
|
|
|
static inline void audit_tk_injoffset(struct timespec64 offset)
|
|
|
|
{
|
|
|
|
/* ignore no-op events */
|
|
|
|
if (offset.tv_sec == 0 && offset.tv_nsec == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!audit_dummy_context())
|
|
|
|
__audit_tk_injoffset(offset);
|
|
|
|
}
|
|
|
|
|
2019-04-10 09:14:20 +00:00
|
|
|
static inline void audit_ntp_init(struct audit_ntp_data *ad)
|
|
|
|
{
|
|
|
|
memset(ad, 0, sizeof(*ad));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void audit_ntp_set_old(struct audit_ntp_data *ad,
|
|
|
|
enum audit_ntp_type type, long long val)
|
|
|
|
{
|
|
|
|
ad->vals[type].oldval = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void audit_ntp_set_new(struct audit_ntp_data *ad,
|
|
|
|
enum audit_ntp_type type, long long val)
|
|
|
|
{
|
|
|
|
ad->vals[type].newval = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void audit_ntp_log(const struct audit_ntp_data *ad)
|
|
|
|
{
|
|
|
|
if (!audit_dummy_context())
|
|
|
|
__audit_ntp_log(ad);
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:39:28 +00:00
|
|
|
static inline void audit_log_nfcfg(const char *name, u8 af,
|
|
|
|
unsigned int nentries,
|
2020-06-28 03:24:19 +00:00
|
|
|
enum audit_nfcfgop op, gfp_t gfp)
|
2020-04-22 21:39:28 +00:00
|
|
|
{
|
|
|
|
if (audit_enabled)
|
2020-06-28 03:24:19 +00:00
|
|
|
__audit_log_nfcfg(name, af, nentries, op, gfp);
|
2020-04-22 21:39:28 +00:00
|
|
|
}
|
|
|
|
|
2006-07-10 12:29:24 +00:00
|
|
|
extern int audit_n_rules;
|
2007-03-29 22:01:04 +00:00
|
|
|
extern int audit_signals;
|
2012-01-03 19:23:06 +00:00
|
|
|
#else /* CONFIG_AUDITSYSCALL */
|
2012-10-05 00:11:11 +00:00
|
|
|
static inline int audit_alloc(struct task_struct *task)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline void audit_free(struct task_struct *task)
|
|
|
|
{ }
|
2014-03-11 17:29:28 +00:00
|
|
|
static inline void audit_syscall_entry(int major, unsigned long a0,
|
2012-10-05 00:11:11 +00:00
|
|
|
unsigned long a1, unsigned long a2,
|
|
|
|
unsigned long a3)
|
|
|
|
{ }
|
|
|
|
static inline void audit_syscall_exit(void *pt_regs)
|
|
|
|
{ }
|
2015-11-04 13:23:51 +00:00
|
|
|
static inline bool audit_dummy_context(void)
|
2012-10-05 00:11:11 +00:00
|
|
|
{
|
2015-11-04 13:23:51 +00:00
|
|
|
return true;
|
2012-10-05 00:11:11 +00:00
|
|
|
}
|
2018-05-13 01:58:21 +00:00
|
|
|
static inline void audit_set_context(struct task_struct *task, struct audit_context *ctx)
|
|
|
|
{ }
|
2018-05-13 01:58:20 +00:00
|
|
|
static inline struct audit_context *audit_context(void)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-10-10 19:25:28 +00:00
|
|
|
static inline struct filename *audit_reusename(const __user char *name)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-10-10 19:25:28 +00:00
|
|
|
static inline void audit_getname(struct filename *name)
|
2012-10-05 00:11:11 +00:00
|
|
|
{ }
|
2020-07-03 16:56:19 +00:00
|
|
|
static inline void audit_getcwd(void)
|
|
|
|
{ }
|
2012-10-10 20:43:13 +00:00
|
|
|
static inline void audit_inode(struct filename *name,
|
|
|
|
const struct dentry *dentry,
|
2019-07-14 17:22:27 +00:00
|
|
|
unsigned int aflags)
|
2012-10-05 00:11:11 +00:00
|
|
|
{ }
|
2014-10-31 21:44:57 +00:00
|
|
|
static inline void audit_file(struct file *file)
|
|
|
|
{
|
|
|
|
}
|
2013-07-08 22:59:36 +00:00
|
|
|
static inline void audit_inode_parent_hidden(struct filename *name,
|
|
|
|
const struct dentry *dentry)
|
|
|
|
{ }
|
2015-12-24 16:09:39 +00:00
|
|
|
static inline void audit_inode_child(struct inode *parent,
|
2012-10-10 19:25:25 +00:00
|
|
|
const struct dentry *dentry,
|
|
|
|
const unsigned char type)
|
2012-10-05 00:11:11 +00:00
|
|
|
{ }
|
|
|
|
static inline void audit_core_dumps(long signr)
|
|
|
|
{ }
|
|
|
|
static inline void audit_seccomp(unsigned long syscall, long signr, int code)
|
|
|
|
{ }
|
seccomp: Audit attempts to modify the actions_logged sysctl
The decision to log a seccomp action will always be subject to the
value of the kernel.seccomp.actions_logged sysctl, even for processes
that are being inspected via the audit subsystem, in an upcoming patch.
Therefore, we need to emit an audit record on attempts at writing to the
actions_logged sysctl when auditing is enabled.
This patch updates the write handler for the actions_logged sysctl to
emit an audit record on attempts to write to the sysctl. Successful
writes to the sysctl will result in a record that includes a normalized
list of logged actions in the "actions" field and a "res" field equal to
1. Unsuccessful writes to the sysctl will result in a record that
doesn't include the "actions" field and has a "res" field equal to 0.
Not all unsuccessful writes to the sysctl are audited. For example, an
audit record will not be emitted if an unprivileged process attempts to
open the sysctl file for reading since that access control check is not
part of the sysctl's write handler.
Below are some example audit records when writing various strings to the
actions_logged sysctl.
Writing "not-a-real-action", when the kernel.seccomp.actions_logged
sysctl previously was "kill_process kill_thread trap errno trace log",
emits this audit record:
type=CONFIG_CHANGE msg=audit(1525392371.454:120): op=seccomp-logging
actions=? old-actions=kill_process,kill_thread,trap,errno,trace,log
res=0
If you then write "kill_process kill_thread errno trace log", this audit
record is emitted:
type=CONFIG_CHANGE msg=audit(1525392401.645:126): op=seccomp-logging
actions=kill_process,kill_thread,errno,trace,log
old-actions=kill_process,kill_thread,trap,errno,trace,log res=1
If you then write "log log errno trace kill_process kill_thread", which
is unordered and contains the log action twice, it results in the same
actions value as the previous record:
type=CONFIG_CHANGE msg=audit(1525392436.354:132): op=seccomp-logging
actions=kill_process,kill_thread,errno,trace,log
old-actions=kill_process,kill_thread,errno,trace,log res=1
If you then write an empty string to the sysctl, this audit record is
emitted:
type=CONFIG_CHANGE msg=audit(1525392494.413:138): op=seccomp-logging
actions=(none) old-actions=kill_process,kill_thread,errno,trace,log
res=1
No audit records are generated when reading the actions_logged sysctl.
Suggested-by: Steve Grubb <sgrubb@redhat.com>
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Paul Moore <paul@paul-moore.com>
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-05 00:11:11 +00: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 22:05:24 +00:00
|
|
|
static inline void audit_bprm(struct linux_binprm *bprm)
|
|
|
|
{ }
|
2013-04-07 08:55:23 +00:00
|
|
|
static inline int audit_socketcall(int nargs, unsigned long *args)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2017-01-17 16:07:15 +00:00
|
|
|
|
|
|
|
static inline int audit_socketcall_compat(int nargs, u32 *args)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-10-05 00:11:11 +00: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-03 02:51:11 +00:00
|
|
|
const struct timespec64 *abs_timeout)
|
2012-10-05 00:11:11 +00: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 07:02:25 +00:00
|
|
|
static inline void audit_log_capset(const struct cred *new,
|
|
|
|
const struct cred *old)
|
2012-10-05 00:11:11 +00:00
|
|
|
{ }
|
|
|
|
static inline void audit_mmap_fd(int fd, int flags)
|
|
|
|
{ }
|
2017-02-04 18:10:38 +00:00
|
|
|
|
|
|
|
static inline void audit_log_kern_module(char *name)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-03 00:21:39 +00:00
|
|
|
static inline void audit_fanotify(unsigned int response)
|
|
|
|
{ }
|
|
|
|
|
2019-04-10 09:14:19 +00:00
|
|
|
static inline void audit_tk_injoffset(struct timespec64 offset)
|
|
|
|
{ }
|
|
|
|
|
2019-04-10 09:14:20 +00:00
|
|
|
static inline void audit_ntp_init(struct audit_ntp_data *ad)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
static inline void audit_ntp_set_old(struct audit_ntp_data *ad,
|
|
|
|
enum audit_ntp_type type, long long val)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
static inline void audit_ntp_set_new(struct audit_ntp_data *ad,
|
|
|
|
enum audit_ntp_type type, long long val)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
static inline void audit_ntp_log(const struct audit_ntp_data *ad)
|
|
|
|
{ }
|
|
|
|
|
2012-10-05 00:11:11 +00:00
|
|
|
static inline void audit_ptrace(struct task_struct *t)
|
|
|
|
{ }
|
2020-04-22 21:39:28 +00:00
|
|
|
|
|
|
|
static inline void audit_log_nfcfg(const char *name, u8 af,
|
|
|
|
unsigned int nentries,
|
2020-06-28 03:24:19 +00:00
|
|
|
enum audit_nfcfgop op, gfp_t gfp)
|
2020-04-22 21:39:28 +00:00
|
|
|
{ }
|
|
|
|
|
2006-07-10 12:29:24 +00:00
|
|
|
#define audit_n_rules 0
|
2007-03-29 22:01:04 +00:00
|
|
|
#define audit_signals 0
|
2012-01-03 19:23:06 +00:00
|
|
|
#endif /* CONFIG_AUDITSYSCALL */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2013-04-09 09:22:10 +00:00
|
|
|
static inline bool audit_loginuid_set(struct task_struct *tsk)
|
|
|
|
{
|
|
|
|
return uid_valid(audit_get_loginuid(tsk));
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|