aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/audit.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/linux/audit.h
Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/linux/audit.h')
-rw-r--r--include/linux/audit.h196
1 files changed, 196 insertions, 0 deletions
diff --git a/include/linux/audit.h b/include/linux/audit.h
new file mode 100644
index 00000000000..3628f7cfb17
--- /dev/null
+++ b/include/linux/audit.h
@@ -0,0 +1,196 @@
1/* audit.h -- Auditing support -*- linux-c -*-
2 *
3 * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
4 * All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * Written by Rickard E. (Rik) Faith <faith@redhat.com>
21 *
22 */
23
24#ifndef _LINUX_AUDIT_H_
25#define _LINUX_AUDIT_H_
26
27/* Request and reply types */
28#define AUDIT_GET 1000 /* Get status */
29#define AUDIT_SET 1001 /* Set status (enable/disable/auditd) */
30#define AUDIT_LIST 1002 /* List filtering rules */
31#define AUDIT_ADD 1003 /* Add filtering rule */
32#define AUDIT_DEL 1004 /* Delete filtering rule */
33#define AUDIT_USER 1005 /* Send a message from user-space */
34#define AUDIT_LOGIN 1006 /* Define the login id and informaiton */
35#define AUDIT_KERNEL 2000 /* Asynchronous audit record. NOT A REQUEST. */
36
37/* Rule flags */
38#define AUDIT_PER_TASK 0x01 /* Apply rule at task creation (not syscall) */
39#define AUDIT_AT_ENTRY 0x02 /* Apply rule at syscall entry */
40#define AUDIT_AT_EXIT 0x04 /* Apply rule at syscall exit */
41#define AUDIT_PREPEND 0x10 /* Prepend to front of list */
42
43/* Rule actions */
44#define AUDIT_NEVER 0 /* Do not build context if rule matches */
45#define AUDIT_POSSIBLE 1 /* Build context if rule matches */
46#define AUDIT_ALWAYS 2 /* Generate audit record if rule matches */
47
48/* Rule structure sizes -- if these change, different AUDIT_ADD and
49 * AUDIT_LIST commands must be implemented. */
50#define AUDIT_MAX_FIELDS 64
51#define AUDIT_BITMASK_SIZE 64
52#define AUDIT_WORD(nr) ((__u32)((nr)/32))
53#define AUDIT_BIT(nr) (1 << ((nr) - AUDIT_WORD(nr)*32))
54
55/* Rule fields */
56 /* These are useful when checking the
57 * task structure at task creation time
58 * (AUDIT_PER_TASK). */
59#define AUDIT_PID 0
60#define AUDIT_UID 1
61#define AUDIT_EUID 2
62#define AUDIT_SUID 3
63#define AUDIT_FSUID 4
64#define AUDIT_GID 5
65#define AUDIT_EGID 6
66#define AUDIT_SGID 7
67#define AUDIT_FSGID 8
68#define AUDIT_LOGINUID 9
69#define AUDIT_PERS 10
70
71 /* These are ONLY useful when checking
72 * at syscall exit time (AUDIT_AT_EXIT). */
73#define AUDIT_DEVMAJOR 100
74#define AUDIT_DEVMINOR 101
75#define AUDIT_INODE 102
76#define AUDIT_EXIT 103
77#define AUDIT_SUCCESS 104 /* exit >= 0; value ignored */
78
79#define AUDIT_ARG0 200
80#define AUDIT_ARG1 (AUDIT_ARG0+1)
81#define AUDIT_ARG2 (AUDIT_ARG0+2)
82#define AUDIT_ARG3 (AUDIT_ARG0+3)
83
84#define AUDIT_NEGATE 0x80000000
85
86
87/* Status symbols */
88 /* Mask values */
89#define AUDIT_STATUS_ENABLED 0x0001
90#define AUDIT_STATUS_FAILURE 0x0002
91#define AUDIT_STATUS_PID 0x0004
92#define AUDIT_STATUS_RATE_LIMIT 0x0008
93#define AUDIT_STATUS_BACKLOG_LIMIT 0x0010
94 /* Failure-to-log actions */
95#define AUDIT_FAIL_SILENT 0
96#define AUDIT_FAIL_PRINTK 1
97#define AUDIT_FAIL_PANIC 2
98
99#ifndef __KERNEL__
100struct audit_message {
101 struct nlmsghdr nlh;
102 char data[1200];
103};
104#endif
105
106struct audit_status {
107 __u32 mask; /* Bit mask for valid entries */
108 __u32 enabled; /* 1 = enabled, 0 = disbaled */
109 __u32 failure; /* Failure-to-log action */
110 __u32 pid; /* pid of auditd process */
111 __u32 rate_limit; /* messages rate limit (per second) */
112 __u32 backlog_limit; /* waiting messages limit */
113 __u32 lost; /* messages lost */
114 __u32 backlog; /* messages waiting in queue */
115};
116
117struct audit_rule { /* for AUDIT_LIST, AUDIT_ADD, and AUDIT_DEL */
118 __u32 flags; /* AUDIT_PER_{TASK,CALL}, AUDIT_PREPEND */
119 __u32 action; /* AUDIT_NEVER, AUDIT_POSSIBLE, AUDIT_ALWAYS */
120 __u32 field_count;
121 __u32 mask[AUDIT_BITMASK_SIZE];
122 __u32 fields[AUDIT_MAX_FIELDS];
123 __u32 values[AUDIT_MAX_FIELDS];
124};
125
126#ifdef __KERNEL__
127
128struct audit_buffer;
129struct audit_context;
130struct inode;
131
132#ifdef CONFIG_AUDITSYSCALL
133/* These are defined in auditsc.c */
134 /* Public API */
135extern int audit_alloc(struct task_struct *task);
136extern void audit_free(struct task_struct *task);
137extern void audit_syscall_entry(struct task_struct *task,
138 int major, unsigned long a0, unsigned long a1,
139 unsigned long a2, unsigned long a3);
140extern void audit_syscall_exit(struct task_struct *task, int return_code);
141extern void audit_getname(const char *name);
142extern void audit_putname(const char *name);
143extern void audit_inode(const char *name, const struct inode *inode);
144
145 /* Private API (for audit.c only) */
146extern int audit_receive_filter(int type, int pid, int uid, int seq,
147 void *data);
148extern void audit_get_stamp(struct audit_context *ctx,
149 struct timespec *t, int *serial);
150extern int audit_set_loginuid(struct audit_context *ctx, uid_t loginuid);
151extern uid_t audit_get_loginuid(struct audit_context *ctx);
152extern int audit_ipc_perms(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode);
153#else
154#define audit_alloc(t) ({ 0; })
155#define audit_free(t) do { ; } while (0)
156#define audit_syscall_entry(t,a,b,c,d,e) do { ; } while (0)
157#define audit_syscall_exit(t,r) do { ; } while (0)
158#define audit_getname(n) do { ; } while (0)
159#define audit_putname(n) do { ; } while (0)
160#define audit_inode(n,i) do { ; } while (0)
161#define audit_get_loginuid(c) ({ -1; })
162#define audit_ipc_perms(q,u,g,m) ({ 0; })
163#endif
164
165#ifdef CONFIG_AUDIT
166/* These are defined in audit.c */
167 /* Public API */
168extern void audit_log(struct audit_context *ctx,
169 const char *fmt, ...)
170 __attribute__((format(printf,2,3)));
171
172extern struct audit_buffer *audit_log_start(struct audit_context *ctx);
173extern void audit_log_format(struct audit_buffer *ab,
174 const char *fmt, ...)
175 __attribute__((format(printf,2,3)));
176extern void audit_log_end(struct audit_buffer *ab);
177extern void audit_log_d_path(struct audit_buffer *ab,
178 const char *prefix,
179 struct dentry *dentry,
180 struct vfsmount *vfsmnt);
181
182 /* Private API (for auditsc.c only) */
183extern void audit_send_reply(int pid, int seq, int type,
184 int done, int multi,
185 void *payload, int size);
186extern void audit_log_lost(const char *message);
187#else
188#define audit_log(t,f,...) do { ; } while (0)
189#define audit_log_start(t) ({ NULL; })
190#define audit_log_vformat(b,f,a) do { ; } while (0)
191#define audit_log_format(b,f,...) do { ; } while (0)
192#define audit_log_end(b) do { ; } while (0)
193#define audit_log_d_path(b,p,d,v) do { ; } while (0)
194#endif
195#endif
196#endif