linux-bk/include/linux/audit.h
<<
>>
Prefs
   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_login {
 118        __u32           loginuid;
 119        int             msglen;
 120        char            msg[1024];
 121};
 122
 123struct audit_rule {             /* for AUDIT_LIST, AUDIT_ADD, and AUDIT_DEL */
 124        __u32           flags;  /* AUDIT_PER_{TASK,CALL}, AUDIT_PREPEND */
 125        __u32           action; /* AUDIT_NEVER, AUDIT_POSSIBLE, AUDIT_ALWAYS */
 126        __u32           field_count;
 127        __u32           mask[AUDIT_BITMASK_SIZE];
 128        __u32           fields[AUDIT_MAX_FIELDS];
 129        __u32           values[AUDIT_MAX_FIELDS];
 130};
 131
 132#ifdef __KERNEL__
 133
 134#ifdef CONFIG_AUDIT
 135struct audit_buffer;
 136struct audit_context;
 137#endif
 138
 139#ifdef CONFIG_AUDITSYSCALL
 140/* These are defined in auditsc.c */
 141                                /* Public API */
 142extern int  audit_alloc(struct task_struct *task);
 143extern void audit_free(struct task_struct *task);
 144extern void audit_syscall_entry(struct task_struct *task,
 145                                int major, unsigned long a0, unsigned long a1,
 146                                unsigned long a2, unsigned long a3);
 147extern void audit_syscall_exit(struct task_struct *task, int return_code);
 148extern void audit_getname(const char *name);
 149extern void audit_putname(const char *name);
 150extern void audit_inode(const char *name, unsigned long ino, dev_t rdev);
 151
 152                                /* Private API (for audit.c only) */
 153extern int  audit_receive_filter(int type, int pid, int uid, int seq,
 154                                 void *data);
 155extern void audit_get_stamp(struct audit_context *ctx,
 156                            struct timespec *t, int *serial);
 157extern int  audit_set_loginuid(struct audit_context *ctx, uid_t loginuid);
 158#else
 159#define audit_alloc(t) ({ 0; })
 160#define audit_free(t) do { ; } while (0)
 161#define audit_syscall_entry(t,a,b,c,d,e) do { ; } while (0)
 162#define audit_syscall_exit(t,r) do { ; } while (0)
 163#define audit_getname(n) do { ; } while (0)
 164#define audit_putname(n) do { ; } while (0)
 165#define audit_inode(n,i,d) do { ; } while (0)
 166#endif
 167
 168#ifdef CONFIG_AUDIT
 169/* These are defined in audit.c */
 170                                /* Public API */
 171extern void                 audit_log(struct audit_context *ctx,
 172                                      const char *fmt, ...)
 173                            __attribute__((format(printf,2,3)));
 174
 175extern struct audit_buffer *audit_log_start(struct audit_context *ctx);
 176extern void                 audit_log_format(struct audit_buffer *ab,
 177                                             const char *fmt, ...)
 178                            __attribute__((format(printf,2,3)));
 179extern void                 audit_log_end(struct audit_buffer *ab);
 180extern void                 audit_log_end_fast(struct audit_buffer *ab);
 181extern void                 audit_log_end_irq(struct audit_buffer *ab);
 182extern void                 audit_log_d_path(struct audit_buffer *ab,
 183                                             const char *prefix,
 184                                             struct dentry *dentry,
 185                                             struct vfsmount *vfsmnt);
 186extern int                  audit_set_rate_limit(int limit);
 187extern int                  audit_set_backlog_limit(int limit);
 188extern int                  audit_set_enabled(int state);
 189extern int                  audit_set_failure(int state);
 190
 191                                /* Private API (for auditsc.c only) */
 192extern void                 audit_send_reply(int pid, int seq, int type,
 193                                             int done, int multi,
 194                                             void *payload, int size);
 195extern void                 audit_log_lost(const char *message);
 196#else
 197#define audit_log(t,f,...) do { ; } while (0)
 198#define audit_log_start(t) ({ NULL; })
 199#define audit_log_vformat(b,f,a) do { ; } while (0)
 200#define audit_log_format(b,f,...) do { ; } while (0)
 201#define audit_log_end(b) do { ; } while (0)
 202#define audit_log_end_fast(b) do { ; } while (0)
 203#define audit_log_end_irq(b) do { ; } while (0)
 204#define audit_log_d_path(b,p,d,v) do { ; } while (0)
 205#define audit_set_rate_limit(l) do { ; } while (0)
 206#define audit_set_backlog_limit(l) do { ; } while (0)
 207#define audit_set_enabled(s) do { ; } while (0)
 208#define audit_set_failure(s) do { ; } while (0)
 209#endif
 210#endif
 211#endif
 212
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.