diff options
Diffstat (limited to 'include/linux/audit.h')
| -rw-r--r-- | include/linux/audit.h | 84 |
1 files changed, 65 insertions, 19 deletions
diff --git a/include/linux/audit.h b/include/linux/audit.h index e051ff9c5b50..c3aa09751814 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h | |||
| @@ -95,6 +95,11 @@ | |||
| 95 | #define AUDIT_MAC_POLICY_LOAD 1403 /* Policy file load */ | 95 | #define AUDIT_MAC_POLICY_LOAD 1403 /* Policy file load */ |
| 96 | #define AUDIT_MAC_STATUS 1404 /* Changed enforcing,permissive,off */ | 96 | #define AUDIT_MAC_STATUS 1404 /* Changed enforcing,permissive,off */ |
| 97 | #define AUDIT_MAC_CONFIG_CHANGE 1405 /* Changes to booleans */ | 97 | #define AUDIT_MAC_CONFIG_CHANGE 1405 /* Changes to booleans */ |
| 98 | #define AUDIT_MAC_UNLBL_ALLOW 1406 /* NetLabel: allow unlabeled traffic */ | ||
| 99 | #define AUDIT_MAC_CIPSOV4_ADD 1407 /* NetLabel: add CIPSOv4 DOI entry */ | ||
| 100 | #define AUDIT_MAC_CIPSOV4_DEL 1408 /* NetLabel: del CIPSOv4 DOI entry */ | ||
| 101 | #define AUDIT_MAC_MAP_ADD 1409 /* NetLabel: add LSM domain mapping */ | ||
| 102 | #define AUDIT_MAC_MAP_DEL 1410 /* NetLabel: del LSM domain mapping */ | ||
| 98 | 103 | ||
| 99 | #define AUDIT_FIRST_KERN_ANOM_MSG 1700 | 104 | #define AUDIT_FIRST_KERN_ANOM_MSG 1700 |
| 100 | #define AUDIT_LAST_KERN_ANOM_MSG 1799 | 105 | #define AUDIT_LAST_KERN_ANOM_MSG 1799 |
| @@ -122,10 +127,21 @@ | |||
| 122 | /* Rule structure sizes -- if these change, different AUDIT_ADD and | 127 | /* Rule structure sizes -- if these change, different AUDIT_ADD and |
| 123 | * AUDIT_LIST commands must be implemented. */ | 128 | * AUDIT_LIST commands must be implemented. */ |
| 124 | #define AUDIT_MAX_FIELDS 64 | 129 | #define AUDIT_MAX_FIELDS 64 |
| 130 | #define AUDIT_MAX_KEY_LEN 32 | ||
| 125 | #define AUDIT_BITMASK_SIZE 64 | 131 | #define AUDIT_BITMASK_SIZE 64 |
| 126 | #define AUDIT_WORD(nr) ((__u32)((nr)/32)) | 132 | #define AUDIT_WORD(nr) ((__u32)((nr)/32)) |
| 127 | #define AUDIT_BIT(nr) (1 << ((nr) - AUDIT_WORD(nr)*32)) | 133 | #define AUDIT_BIT(nr) (1 << ((nr) - AUDIT_WORD(nr)*32)) |
| 128 | 134 | ||
| 135 | #define AUDIT_SYSCALL_CLASSES 16 | ||
| 136 | #define AUDIT_CLASS_DIR_WRITE 0 | ||
| 137 | #define AUDIT_CLASS_DIR_WRITE_32 1 | ||
| 138 | #define AUDIT_CLASS_CHATTR 2 | ||
| 139 | #define AUDIT_CLASS_CHATTR_32 3 | ||
| 140 | #define AUDIT_CLASS_READ 4 | ||
| 141 | #define AUDIT_CLASS_READ_32 5 | ||
| 142 | #define AUDIT_CLASS_WRITE 6 | ||
| 143 | #define AUDIT_CLASS_WRITE_32 7 | ||
| 144 | |||
| 129 | /* This bitmask is used to validate user input. It represents all bits that | 145 | /* This bitmask is used to validate user input. It represents all bits that |
| 130 | * are currently used in an audit field constant understood by the kernel. | 146 | * are currently used in an audit field constant understood by the kernel. |
| 131 | * If you are adding a new #define AUDIT_<whatever>, please ensure that | 147 | * If you are adding a new #define AUDIT_<whatever>, please ensure that |
| @@ -150,12 +166,17 @@ | |||
| 150 | #define AUDIT_PERS 10 | 166 | #define AUDIT_PERS 10 |
| 151 | #define AUDIT_ARCH 11 | 167 | #define AUDIT_ARCH 11 |
| 152 | #define AUDIT_MSGTYPE 12 | 168 | #define AUDIT_MSGTYPE 12 |
| 153 | #define AUDIT_SE_USER 13 /* security label user */ | 169 | #define AUDIT_SUBJ_USER 13 /* security label user */ |
| 154 | #define AUDIT_SE_ROLE 14 /* security label role */ | 170 | #define AUDIT_SUBJ_ROLE 14 /* security label role */ |
| 155 | #define AUDIT_SE_TYPE 15 /* security label type */ | 171 | #define AUDIT_SUBJ_TYPE 15 /* security label type */ |
| 156 | #define AUDIT_SE_SEN 16 /* security label sensitivity label */ | 172 | #define AUDIT_SUBJ_SEN 16 /* security label sensitivity label */ |
| 157 | #define AUDIT_SE_CLR 17 /* security label clearance label */ | 173 | #define AUDIT_SUBJ_CLR 17 /* security label clearance label */ |
| 158 | #define AUDIT_PPID 18 | 174 | #define AUDIT_PPID 18 |
| 175 | #define AUDIT_OBJ_USER 19 | ||
| 176 | #define AUDIT_OBJ_ROLE 20 | ||
| 177 | #define AUDIT_OBJ_TYPE 21 | ||
| 178 | #define AUDIT_OBJ_LEV_LOW 22 | ||
| 179 | #define AUDIT_OBJ_LEV_HIGH 23 | ||
| 159 | 180 | ||
| 160 | /* These are ONLY useful when checking | 181 | /* These are ONLY useful when checking |
| 161 | * at syscall exit time (AUDIT_AT_EXIT). */ | 182 | * at syscall exit time (AUDIT_AT_EXIT). */ |
| @@ -165,12 +186,15 @@ | |||
| 165 | #define AUDIT_EXIT 103 | 186 | #define AUDIT_EXIT 103 |
| 166 | #define AUDIT_SUCCESS 104 /* exit >= 0; value ignored */ | 187 | #define AUDIT_SUCCESS 104 /* exit >= 0; value ignored */ |
| 167 | #define AUDIT_WATCH 105 | 188 | #define AUDIT_WATCH 105 |
| 189 | #define AUDIT_PERM 106 | ||
| 168 | 190 | ||
| 169 | #define AUDIT_ARG0 200 | 191 | #define AUDIT_ARG0 200 |
| 170 | #define AUDIT_ARG1 (AUDIT_ARG0+1) | 192 | #define AUDIT_ARG1 (AUDIT_ARG0+1) |
| 171 | #define AUDIT_ARG2 (AUDIT_ARG0+2) | 193 | #define AUDIT_ARG2 (AUDIT_ARG0+2) |
| 172 | #define AUDIT_ARG3 (AUDIT_ARG0+3) | 194 | #define AUDIT_ARG3 (AUDIT_ARG0+3) |
| 173 | 195 | ||
| 196 | #define AUDIT_FILTERKEY 210 | ||
| 197 | |||
| 174 | #define AUDIT_NEGATE 0x80000000 | 198 | #define AUDIT_NEGATE 0x80000000 |
| 175 | 199 | ||
| 176 | /* These are the supported operators. | 200 | /* These are the supported operators. |
| @@ -238,6 +262,11 @@ | |||
| 238 | #define AUDIT_ARCH_V850 (EM_V850|__AUDIT_ARCH_LE) | 262 | #define AUDIT_ARCH_V850 (EM_V850|__AUDIT_ARCH_LE) |
| 239 | #define AUDIT_ARCH_X86_64 (EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) | 263 | #define AUDIT_ARCH_X86_64 (EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) |
| 240 | 264 | ||
| 265 | #define AUDIT_PERM_EXEC 1 | ||
| 266 | #define AUDIT_PERM_WRITE 2 | ||
| 267 | #define AUDIT_PERM_READ 4 | ||
| 268 | #define AUDIT_PERM_ATTR 8 | ||
| 269 | |||
| 241 | struct audit_status { | 270 | struct audit_status { |
| 242 | __u32 mask; /* Bit mask for valid entries */ | 271 | __u32 mask; /* Bit mask for valid entries */ |
| 243 | __u32 enabled; /* 1 = enabled, 0 = disabled */ | 272 | __u32 enabled; /* 1 = enabled, 0 = disabled */ |
| @@ -299,6 +328,8 @@ struct mqstat; | |||
| 299 | #define AUDITSC_SUCCESS 1 | 328 | #define AUDITSC_SUCCESS 1 |
| 300 | #define AUDITSC_FAILURE 2 | 329 | #define AUDITSC_FAILURE 2 |
| 301 | #define AUDITSC_RESULT(x) ( ((long)(x))<0?AUDITSC_FAILURE:AUDITSC_SUCCESS ) | 330 | #define AUDITSC_RESULT(x) ( ((long)(x))<0?AUDITSC_FAILURE:AUDITSC_SUCCESS ) |
| 331 | extern int __init audit_register_class(int class, unsigned *list); | ||
| 332 | extern int audit_classify_syscall(int abi, unsigned syscall); | ||
| 302 | #ifdef CONFIG_AUDITSYSCALL | 333 | #ifdef CONFIG_AUDITSYSCALL |
| 303 | /* These are defined in auditsc.c */ | 334 | /* These are defined in auditsc.c */ |
| 304 | /* Public API */ | 335 | /* Public API */ |
| @@ -312,21 +343,31 @@ extern void __audit_getname(const char *name); | |||
| 312 | extern void audit_putname(const char *name); | 343 | extern void audit_putname(const char *name); |
| 313 | extern void __audit_inode(const char *name, const struct inode *inode); | 344 | extern void __audit_inode(const char *name, const struct inode *inode); |
| 314 | extern void __audit_inode_child(const char *dname, const struct inode *inode, | 345 | extern void __audit_inode_child(const char *dname, const struct inode *inode, |
| 315 | unsigned long pino); | 346 | const struct inode *parent); |
| 347 | extern void __audit_inode_update(const struct inode *inode); | ||
| 348 | static inline int audit_dummy_context(void) | ||
| 349 | { | ||
| 350 | void *p = current->audit_context; | ||
| 351 | return !p || *(int *)p; | ||
| 352 | } | ||
| 316 | static inline void audit_getname(const char *name) | 353 | static inline void audit_getname(const char *name) |
| 317 | { | 354 | { |
| 318 | if (unlikely(current->audit_context)) | 355 | if (unlikely(!audit_dummy_context())) |
| 319 | __audit_getname(name); | 356 | __audit_getname(name); |
| 320 | } | 357 | } |
| 321 | static inline void audit_inode(const char *name, const struct inode *inode) { | 358 | static inline void audit_inode(const char *name, const struct inode *inode) { |
| 322 | if (unlikely(current->audit_context)) | 359 | if (unlikely(!audit_dummy_context())) |
| 323 | __audit_inode(name, inode); | 360 | __audit_inode(name, inode); |
| 324 | } | 361 | } |
| 325 | static inline void audit_inode_child(const char *dname, | 362 | static inline void audit_inode_child(const char *dname, |
| 326 | const struct inode *inode, | 363 | const struct inode *inode, |
| 327 | unsigned long pino) { | 364 | const struct inode *parent) { |
| 328 | if (unlikely(current->audit_context)) | 365 | if (unlikely(!audit_dummy_context())) |
| 329 | __audit_inode_child(dname, inode, pino); | 366 | __audit_inode_child(dname, inode, parent); |
| 367 | } | ||
| 368 | static inline void audit_inode_update(const struct inode *inode) { | ||
| 369 | if (unlikely(!audit_dummy_context())) | ||
| 370 | __audit_inode_update(inode); | ||
| 330 | } | 371 | } |
| 331 | 372 | ||
| 332 | /* Private API (for audit.c only) */ | 373 | /* Private API (for audit.c only) */ |
| @@ -350,57 +391,61 @@ extern int __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat); | |||
| 350 | 391 | ||
| 351 | static inline int audit_ipc_obj(struct kern_ipc_perm *ipcp) | 392 | static inline int audit_ipc_obj(struct kern_ipc_perm *ipcp) |
| 352 | { | 393 | { |
| 353 | if (unlikely(current->audit_context)) | 394 | if (unlikely(!audit_dummy_context())) |
| 354 | return __audit_ipc_obj(ipcp); | 395 | return __audit_ipc_obj(ipcp); |
| 355 | return 0; | 396 | return 0; |
| 356 | } | 397 | } |
| 357 | static inline int audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode) | 398 | static inline int audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode) |
| 358 | { | 399 | { |
| 359 | if (unlikely(current->audit_context)) | 400 | if (unlikely(!audit_dummy_context())) |
| 360 | return __audit_ipc_set_perm(qbytes, uid, gid, mode); | 401 | return __audit_ipc_set_perm(qbytes, uid, gid, mode); |
| 361 | return 0; | 402 | return 0; |
| 362 | } | 403 | } |
| 363 | static inline int audit_mq_open(int oflag, mode_t mode, struct mq_attr __user *u_attr) | 404 | static inline int audit_mq_open(int oflag, mode_t mode, struct mq_attr __user *u_attr) |
| 364 | { | 405 | { |
| 365 | if (unlikely(current->audit_context)) | 406 | if (unlikely(!audit_dummy_context())) |
| 366 | return __audit_mq_open(oflag, mode, u_attr); | 407 | return __audit_mq_open(oflag, mode, u_attr); |
| 367 | return 0; | 408 | return 0; |
| 368 | } | 409 | } |
| 369 | static inline int audit_mq_timedsend(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec __user *u_abs_timeout) | 410 | static inline int audit_mq_timedsend(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec __user *u_abs_timeout) |
| 370 | { | 411 | { |
| 371 | if (unlikely(current->audit_context)) | 412 | if (unlikely(!audit_dummy_context())) |
| 372 | return __audit_mq_timedsend(mqdes, msg_len, msg_prio, u_abs_timeout); | 413 | return __audit_mq_timedsend(mqdes, msg_len, msg_prio, u_abs_timeout); |
| 373 | return 0; | 414 | return 0; |
| 374 | } | 415 | } |
| 375 | static inline int audit_mq_timedreceive(mqd_t mqdes, size_t msg_len, unsigned int __user *u_msg_prio, const struct timespec __user *u_abs_timeout) | 416 | static inline int audit_mq_timedreceive(mqd_t mqdes, size_t msg_len, unsigned int __user *u_msg_prio, const struct timespec __user *u_abs_timeout) |
| 376 | { | 417 | { |
| 377 | if (unlikely(current->audit_context)) | 418 | if (unlikely(!audit_dummy_context())) |
| 378 | return __audit_mq_timedreceive(mqdes, msg_len, u_msg_prio, u_abs_timeout); | 419 | return __audit_mq_timedreceive(mqdes, msg_len, u_msg_prio, u_abs_timeout); |
| 379 | return 0; | 420 | return 0; |
| 380 | } | 421 | } |
| 381 | static inline int audit_mq_notify(mqd_t mqdes, const struct sigevent __user *u_notification) | 422 | static inline int audit_mq_notify(mqd_t mqdes, const struct sigevent __user *u_notification) |
| 382 | { | 423 | { |
| 383 | if (unlikely(current->audit_context)) | 424 | if (unlikely(!audit_dummy_context())) |
| 384 | return __audit_mq_notify(mqdes, u_notification); | 425 | return __audit_mq_notify(mqdes, u_notification); |
| 385 | return 0; | 426 | return 0; |
| 386 | } | 427 | } |
| 387 | static inline int audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) | 428 | static inline int audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) |
| 388 | { | 429 | { |
| 389 | if (unlikely(current->audit_context)) | 430 | if (unlikely(!audit_dummy_context())) |
| 390 | return __audit_mq_getsetattr(mqdes, mqstat); | 431 | return __audit_mq_getsetattr(mqdes, mqstat); |
| 391 | return 0; | 432 | return 0; |
| 392 | } | 433 | } |
| 434 | extern int audit_n_rules; | ||
| 393 | #else | 435 | #else |
| 394 | #define audit_alloc(t) ({ 0; }) | 436 | #define audit_alloc(t) ({ 0; }) |
| 395 | #define audit_free(t) do { ; } while (0) | 437 | #define audit_free(t) do { ; } while (0) |
| 396 | #define audit_syscall_entry(ta,a,b,c,d,e) do { ; } while (0) | 438 | #define audit_syscall_entry(ta,a,b,c,d,e) do { ; } while (0) |
| 397 | #define audit_syscall_exit(f,r) do { ; } while (0) | 439 | #define audit_syscall_exit(f,r) do { ; } while (0) |
| 440 | #define audit_dummy_context() 1 | ||
| 398 | #define audit_getname(n) do { ; } while (0) | 441 | #define audit_getname(n) do { ; } while (0) |
| 399 | #define audit_putname(n) do { ; } while (0) | 442 | #define audit_putname(n) do { ; } while (0) |
| 400 | #define __audit_inode(n,i) do { ; } while (0) | 443 | #define __audit_inode(n,i) do { ; } while (0) |
| 401 | #define __audit_inode_child(d,i,p) do { ; } while (0) | 444 | #define __audit_inode_child(d,i,p) do { ; } while (0) |
| 445 | #define __audit_inode_update(i) do { ; } while (0) | ||
| 402 | #define audit_inode(n,i) do { ; } while (0) | 446 | #define audit_inode(n,i) do { ; } while (0) |
| 403 | #define audit_inode_child(d,i,p) do { ; } while (0) | 447 | #define audit_inode_child(d,i,p) do { ; } while (0) |
| 448 | #define audit_inode_update(i) do { ; } while (0) | ||
| 404 | #define auditsc_get_stamp(c,t,s) do { BUG(); } while (0) | 449 | #define auditsc_get_stamp(c,t,s) do { BUG(); } while (0) |
| 405 | #define audit_get_loginuid(c) ({ -1; }) | 450 | #define audit_get_loginuid(c) ({ -1; }) |
| 406 | #define audit_ipc_obj(i) ({ 0; }) | 451 | #define audit_ipc_obj(i) ({ 0; }) |
| @@ -415,6 +460,7 @@ static inline int audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) | |||
| 415 | #define audit_mq_timedreceive(d,l,p,t) ({ 0; }) | 460 | #define audit_mq_timedreceive(d,l,p,t) ({ 0; }) |
| 416 | #define audit_mq_notify(d,n) ({ 0; }) | 461 | #define audit_mq_notify(d,n) ({ 0; }) |
| 417 | #define audit_mq_getsetattr(d,s) ({ 0; }) | 462 | #define audit_mq_getsetattr(d,s) ({ 0; }) |
| 463 | #define audit_n_rules 0 | ||
| 418 | #endif | 464 | #endif |
| 419 | 465 | ||
| 420 | #ifdef CONFIG_AUDIT | 466 | #ifdef CONFIG_AUDIT |
