Print this page
NEX-13644 File access audit logging
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/c2/audit_kernel.h
          +++ new/usr/src/uts/common/c2/audit_kernel.h
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
       23 + * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
  23   24   */
  24   25  
  25   26  #ifndef _BSM_AUDIT_KERNEL_H
  26   27  #define _BSM_AUDIT_KERNEL_H
  27   28  
  28   29  
  29   30  /*
  30   31   * This file contains the basic auditing control structure definitions.
  31   32   */
  32   33  
       34 +#include <c2/audit.h>
  33   35  #include <c2/audit_kevents.h>
  34   36  #include <sys/priv_impl.h>
  35   37  #include <sys/taskq.h>
  36   38  #include <sys/zone.h>
  37   39  
  38   40  #include <sys/tsol/label.h>
  39   41  
  40   42  #ifdef __cplusplus
  41   43  extern "C" {
  42   44  #endif
↓ open down ↓ 135 lines elided ↑ open up ↑
 178  180  #define TAD_MLD         0x00000020      /* system call involves MLD */
 179  181  #define TAD_NOATTRB     0x00000040      /* do not automatically add attribute */
 180  182  #define TAD_NOAUDIT     0x00000080      /* discard audit record */
 181  183  #define TAD_NOPATH      0x00000100      /* force no paths in audit record */
 182  184  #define TAD_PATHFND     0x00000200      /* found path, don't retry lookup */
 183  185  #define TAD_PUBLIC_EV   0x00000400      /* syscall is defined as a public op */
 184  186  #define TAD_SAVPATH     0x00000800      /* save path for further processing */
 185  187  #define TAD_TRUE_CREATE 0x00001000      /* true create, file not found */
 186  188  
 187  189  /*
      190 + * These types implement the interface between a consumer and FS for handling
      191 + * SACL-based File Access Auditing. A consumer zeroes out the appropriate
      192 + * t_audit_sacl_t in T2A(curthread), then sets tad_sacl_ctrl to one of
      193 + * sacl_audit_ctrl_t. The FS, when auditing of SACLs is enabled, checks to see
      194 + * if tad_sacl_ctrl is not NONE. If so, it collects information from the
      195 + * object's SACL (such as NFSv4 Audit and Alarm type ACEs), and stores
      196 + * representative Success and Failure masks in the t_audit_sacl_t structure.
      197 + * The consumer then compares the requested access to the appropriate mask in
      198 + * order to determine whether an audit record should be generated.
      199 + */
      200 +typedef struct t_audit_sacl {
      201 +        uint32_t tas_smask;
      202 +        uint32_t tas_fmask;
      203 +} t_audit_sacl_t;
      204 +
      205 +typedef enum sacl_audit_ctrl {
      206 +        SACL_AUDIT_NONE = 0,
      207 +        SACL_AUDIT_ON,
      208 +        SACL_AUDIT_ALL,
      209 +        SACL_AUDIT_NO_SRC
      210 +} sacl_audit_ctrl_t;
      211 +
      212 +/*
 188  213   * The structure t_audit_data hangs off of the thread structure. It contains
 189  214   * all of the audit information necessary to manage the audit record generation
 190  215   * for each thread.
 191  216   *
 192  217   */
 193  218  
 194  219  struct t_audit_data {
 195  220          kthread_id_t  tad_thread;       /* DEBUG pointer to parent thread */
 196  221          unsigned int  tad_scid;         /* system call ID for finish */
 197  222          au_event_t      tad_event;      /* event for audit record */
↓ open down ↓ 3 lines elided ↑ open up ↑
 201  226          int     tad_flag;       /* to audit or not to audit */
 202  227          uint32_t tad_audit;     /* auditing enabled/disabled */
 203  228          struct audit_path       *tad_aupath;    /* captured at vfs_lookup */
 204  229          struct audit_path       *tad_atpath;    /* openat prefix, path of fd */
 205  230          caddr_t tad_ad;         /* base of accumulated audit data */
 206  231          au_defer_info_t *tad_defer_head;        /* queue of records to defer */
 207  232                                                  /* until syscall end: */
 208  233          au_defer_info_t *tad_defer_tail;        /* tail of defer queue */
 209  234          priv_set_t tad_sprivs;  /* saved (success) used privs */
 210  235          priv_set_t tad_fprivs;  /* saved (failed) used privs */
      236 +        sacl_audit_ctrl_t tad_sacl_ctrl;
      237 +        sacl_audit_ctrl_t tad_sacl_backup;
      238 +        t_audit_sacl_t tad_sacl_mask;
      239 +        t_audit_sacl_t tad_sacl_mask_src;
      240 +        t_audit_sacl_t tad_sacl_mask_dest;
 211  241  };
 212  242  typedef struct t_audit_data t_audit_data_t;
 213  243  
 214  244  /*
 215  245   * The f_audit_data structure hangs off of the file structure. It contains
 216  246   * three fields of data. The audit ID, the audit state, and a path name.
 217  247   */
 218  248  
 219  249  struct f_audit_data {
 220  250          kthread_id_t    fad_thread;     /* DEBUG creating thread */
↓ open down ↓ 216 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX