aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-01-17 19:06:51 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-17 19:41:31 -0500
commitf429ee3b808118591d1f3cdf3c0d0793911a5677 (patch)
tree96d848f5f677d96758ecd2aee5eb6931b75bf218 /include/linux
parent22b4eb5e3174efb49791c62823d0cccc35394c36 (diff)
parentc158a35c8a681cf68d36f22f058f9f5466386c71 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/audit
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/audit: (29 commits) audit: no leading space in audit_log_d_path prefix audit: treat s_id as an untrusted string audit: fix signedness bug in audit_log_execve_info() audit: comparison on interprocess fields audit: implement all object interfield comparisons audit: allow interfield comparison between gid and ogid audit: complex interfield comparison helper audit: allow interfield comparison in audit rules Kernel: Audit Support For The ARM Platform audit: do not call audit_getname on error audit: only allow tasks to set their loginuid if it is -1 audit: remove task argument to audit_set_loginuid audit: allow audit matching on inode gid audit: allow matching on obj_uid audit: remove audit_finish_fork as it can't be called audit: reject entry,always rules audit: inline audit_free to simplify the look of generic code audit: drop audit_set_macxattr as it doesn't do anything audit: inline checks for not needing to collect aux records audit: drop some potentially inadvisable likely notations ... Use evil merge to fix up grammar mistakes in Kconfig file. Bad speling and horrible grammar (and copious swearing) is to be expected, but let's keep it to commit messages and comments, rather than expose it to users in config help texts or printouts.
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/audit.h116
-rw-r--r--include/linux/ptrace.h10
2 files changed, 106 insertions, 20 deletions
diff --git a/include/linux/audit.h b/include/linux/audit.h
index 426ab9f4dd85..9ff7a2c48b50 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -26,6 +26,7 @@
26 26
27#include <linux/types.h> 27#include <linux/types.h>
28#include <linux/elf-em.h> 28#include <linux/elf-em.h>
29#include <linux/ptrace.h>
29 30
30/* The netlink messages for the audit system is divided into blocks: 31/* The netlink messages for the audit system is divided into blocks:
31 * 1000 - 1099 are for commanding the audit system 32 * 1000 - 1099 are for commanding the audit system
@@ -181,6 +182,40 @@
181 * AUDIT_UNUSED_BITS is updated if need be. */ 182 * AUDIT_UNUSED_BITS is updated if need be. */
182#define AUDIT_UNUSED_BITS 0x07FFFC00 183#define AUDIT_UNUSED_BITS 0x07FFFC00
183 184
185/* AUDIT_FIELD_COMPARE rule list */
186#define AUDIT_COMPARE_UID_TO_OBJ_UID 1
187#define AUDIT_COMPARE_GID_TO_OBJ_GID 2
188#define AUDIT_COMPARE_EUID_TO_OBJ_UID 3
189#define AUDIT_COMPARE_EGID_TO_OBJ_GID 4
190#define AUDIT_COMPARE_AUID_TO_OBJ_UID 5
191#define AUDIT_COMPARE_SUID_TO_OBJ_UID 6
192#define AUDIT_COMPARE_SGID_TO_OBJ_GID 7
193#define AUDIT_COMPARE_FSUID_TO_OBJ_UID 8
194#define AUDIT_COMPARE_FSGID_TO_OBJ_GID 9
195
196#define AUDIT_COMPARE_UID_TO_AUID 10
197#define AUDIT_COMPARE_UID_TO_EUID 11
198#define AUDIT_COMPARE_UID_TO_FSUID 12
199#define AUDIT_COMPARE_UID_TO_SUID 13
200
201#define AUDIT_COMPARE_AUID_TO_FSUID 14
202#define AUDIT_COMPARE_AUID_TO_SUID 15
203#define AUDIT_COMPARE_AUID_TO_EUID 16
204
205#define AUDIT_COMPARE_EUID_TO_SUID 17
206#define AUDIT_COMPARE_EUID_TO_FSUID 18
207
208#define AUDIT_COMPARE_SUID_TO_FSUID 19
209
210#define AUDIT_COMPARE_GID_TO_EGID 20
211#define AUDIT_COMPARE_GID_TO_FSGID 21
212#define AUDIT_COMPARE_GID_TO_SGID 22
213
214#define AUDIT_COMPARE_EGID_TO_FSGID 23
215#define AUDIT_COMPARE_EGID_TO_SGID 24
216#define AUDIT_COMPARE_SGID_TO_FSGID 25
217
218#define AUDIT_MAX_FIELD_COMPARE AUDIT_COMPARE_SGID_TO_FSGID
184 219
185/* Rule fields */ 220/* Rule fields */
186 /* These are useful when checking the 221 /* These are useful when checking the
@@ -222,6 +257,9 @@
222#define AUDIT_PERM 106 257#define AUDIT_PERM 106
223#define AUDIT_DIR 107 258#define AUDIT_DIR 107
224#define AUDIT_FILETYPE 108 259#define AUDIT_FILETYPE 108
260#define AUDIT_OBJ_UID 109
261#define AUDIT_OBJ_GID 110
262#define AUDIT_FIELD_COMPARE 111
225 263
226#define AUDIT_ARG0 200 264#define AUDIT_ARG0 200
227#define AUDIT_ARG1 (AUDIT_ARG0+1) 265#define AUDIT_ARG1 (AUDIT_ARG0+1)
@@ -408,28 +446,24 @@ struct audit_field {
408 void *lsm_rule; 446 void *lsm_rule;
409}; 447};
410 448
411#define AUDITSC_INVALID 0
412#define AUDITSC_SUCCESS 1
413#define AUDITSC_FAILURE 2
414#define AUDITSC_RESULT(x) ( ((long)(x))<0?AUDITSC_FAILURE:AUDITSC_SUCCESS )
415extern int __init audit_register_class(int class, unsigned *list); 449extern int __init audit_register_class(int class, unsigned *list);
416extern int audit_classify_syscall(int abi, unsigned syscall); 450extern int audit_classify_syscall(int abi, unsigned syscall);
417extern int audit_classify_arch(int arch); 451extern int audit_classify_arch(int arch);
418#ifdef CONFIG_AUDITSYSCALL 452#ifdef CONFIG_AUDITSYSCALL
419/* These are defined in auditsc.c */ 453/* These are defined in auditsc.c */
420 /* Public API */ 454 /* Public API */
421extern void audit_finish_fork(struct task_struct *child);
422extern int audit_alloc(struct task_struct *task); 455extern int audit_alloc(struct task_struct *task);
423extern void audit_free(struct task_struct *task); 456extern void __audit_free(struct task_struct *task);
424extern void audit_syscall_entry(int arch, 457extern void __audit_syscall_entry(int arch,
425 int major, unsigned long a0, unsigned long a1, 458 int major, unsigned long a0, unsigned long a1,
426 unsigned long a2, unsigned long a3); 459 unsigned long a2, unsigned long a3);
427extern void audit_syscall_exit(int failed, long return_code); 460extern void __audit_syscall_exit(int ret_success, long ret_value);
428extern void __audit_getname(const char *name); 461extern void __audit_getname(const char *name);
429extern void audit_putname(const char *name); 462extern void audit_putname(const char *name);
430extern void __audit_inode(const char *name, const struct dentry *dentry); 463extern void __audit_inode(const char *name, const struct dentry *dentry);
431extern void __audit_inode_child(const struct dentry *dentry, 464extern void __audit_inode_child(const struct dentry *dentry,
432 const struct inode *parent); 465 const struct inode *parent);
466extern void __audit_seccomp(unsigned long syscall);
433extern void __audit_ptrace(struct task_struct *t); 467extern void __audit_ptrace(struct task_struct *t);
434 468
435static inline int audit_dummy_context(void) 469static inline int audit_dummy_context(void)
@@ -437,6 +471,27 @@ static inline int audit_dummy_context(void)
437 void *p = current->audit_context; 471 void *p = current->audit_context;
438 return !p || *(int *)p; 472 return !p || *(int *)p;
439} 473}
474static inline void audit_free(struct task_struct *task)
475{
476 if (unlikely(task->audit_context))
477 __audit_free(task);
478}
479static inline void audit_syscall_entry(int arch, int major, unsigned long a0,
480 unsigned long a1, unsigned long a2,
481 unsigned long a3)
482{
483 if (unlikely(!audit_dummy_context()))
484 __audit_syscall_entry(arch, major, a0, a1, a2, a3);
485}
486static inline void audit_syscall_exit(void *pt_regs)
487{
488 if (unlikely(current->audit_context)) {
489 int success = is_syscall_success(pt_regs);
490 int return_code = regs_return_value(pt_regs);
491
492 __audit_syscall_exit(success, return_code);
493 }
494}
440static inline void audit_getname(const char *name) 495static inline void audit_getname(const char *name)
441{ 496{
442 if (unlikely(!audit_dummy_context())) 497 if (unlikely(!audit_dummy_context()))
@@ -453,6 +508,12 @@ static inline void audit_inode_child(const struct dentry *dentry,
453} 508}
454void audit_core_dumps(long signr); 509void audit_core_dumps(long signr);
455 510
511static inline void audit_seccomp(unsigned long syscall)
512{
513 if (unlikely(!audit_dummy_context()))
514 __audit_seccomp(syscall);
515}
516
456static inline void audit_ptrace(struct task_struct *t) 517static inline void audit_ptrace(struct task_struct *t)
457{ 518{
458 if (unlikely(!audit_dummy_context())) 519 if (unlikely(!audit_dummy_context()))
@@ -463,17 +524,16 @@ static inline void audit_ptrace(struct task_struct *t)
463extern unsigned int audit_serial(void); 524extern unsigned int audit_serial(void);
464extern int auditsc_get_stamp(struct audit_context *ctx, 525extern int auditsc_get_stamp(struct audit_context *ctx,
465 struct timespec *t, unsigned int *serial); 526 struct timespec *t, unsigned int *serial);
466extern int audit_set_loginuid(struct task_struct *task, uid_t loginuid); 527extern int audit_set_loginuid(uid_t loginuid);
467#define audit_get_loginuid(t) ((t)->loginuid) 528#define audit_get_loginuid(t) ((t)->loginuid)
468#define audit_get_sessionid(t) ((t)->sessionid) 529#define audit_get_sessionid(t) ((t)->sessionid)
469extern void audit_log_task_context(struct audit_buffer *ab); 530extern void audit_log_task_context(struct audit_buffer *ab);
470extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp); 531extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp);
471extern void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode); 532extern void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode);
472extern int audit_bprm(struct linux_binprm *bprm); 533extern int __audit_bprm(struct linux_binprm *bprm);
473extern void audit_socketcall(int nargs, unsigned long *args); 534extern void __audit_socketcall(int nargs, unsigned long *args);
474extern int audit_sockaddr(int len, void *addr); 535extern int __audit_sockaddr(int len, void *addr);
475extern void __audit_fd_pair(int fd1, int fd2); 536extern void __audit_fd_pair(int fd1, int fd2);
476extern int audit_set_macxattr(const char *name);
477extern void __audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr); 537extern void __audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr);
478extern void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout); 538extern void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout);
479extern void __audit_mq_notify(mqd_t mqdes, const struct sigevent *notification); 539extern void __audit_mq_notify(mqd_t mqdes, const struct sigevent *notification);
@@ -499,6 +559,23 @@ static inline void audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid
499 if (unlikely(!audit_dummy_context())) 559 if (unlikely(!audit_dummy_context()))
500 __audit_ipc_set_perm(qbytes, uid, gid, mode); 560 __audit_ipc_set_perm(qbytes, uid, gid, mode);
501} 561}
562static inline int audit_bprm(struct linux_binprm *bprm)
563{
564 if (unlikely(!audit_dummy_context()))
565 return __audit_bprm(bprm);
566 return 0;
567}
568static inline void audit_socketcall(int nargs, unsigned long *args)
569{
570 if (unlikely(!audit_dummy_context()))
571 __audit_socketcall(nargs, args);
572}
573static inline int audit_sockaddr(int len, void *addr)
574{
575 if (unlikely(!audit_dummy_context()))
576 return __audit_sockaddr(len, addr);
577 return 0;
578}
502static inline void audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr) 579static inline void audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr)
503{ 580{
504 if (unlikely(!audit_dummy_context())) 581 if (unlikely(!audit_dummy_context()))
@@ -544,12 +621,11 @@ static inline void audit_mmap_fd(int fd, int flags)
544 621
545extern int audit_n_rules; 622extern int audit_n_rules;
546extern int audit_signals; 623extern int audit_signals;
547#else 624#else /* CONFIG_AUDITSYSCALL */
548#define audit_finish_fork(t)
549#define audit_alloc(t) ({ 0; }) 625#define audit_alloc(t) ({ 0; })
550#define audit_free(t) do { ; } while (0) 626#define audit_free(t) do { ; } while (0)
551#define audit_syscall_entry(ta,a,b,c,d,e) do { ; } while (0) 627#define audit_syscall_entry(ta,a,b,c,d,e) do { ; } while (0)
552#define audit_syscall_exit(f,r) do { ; } while (0) 628#define audit_syscall_exit(r) do { ; } while (0)
553#define audit_dummy_context() 1 629#define audit_dummy_context() 1
554#define audit_getname(n) do { ; } while (0) 630#define audit_getname(n) do { ; } while (0)
555#define audit_putname(n) do { ; } while (0) 631#define audit_putname(n) do { ; } while (0)
@@ -558,6 +634,7 @@ extern int audit_signals;
558#define audit_inode(n,d) do { (void)(d); } while (0) 634#define audit_inode(n,d) do { (void)(d); } while (0)
559#define audit_inode_child(i,p) do { ; } while (0) 635#define audit_inode_child(i,p) do { ; } while (0)
560#define audit_core_dumps(i) do { ; } while (0) 636#define audit_core_dumps(i) do { ; } while (0)
637#define audit_seccomp(i) do { ; } while (0)
561#define auditsc_get_stamp(c,t,s) (0) 638#define auditsc_get_stamp(c,t,s) (0)
562#define audit_get_loginuid(t) (-1) 639#define audit_get_loginuid(t) (-1)
563#define audit_get_sessionid(t) (-1) 640#define audit_get_sessionid(t) (-1)
@@ -568,7 +645,6 @@ extern int audit_signals;
568#define audit_socketcall(n,a) ((void)0) 645#define audit_socketcall(n,a) ((void)0)
569#define audit_fd_pair(n,a) ((void)0) 646#define audit_fd_pair(n,a) ((void)0)
570#define audit_sockaddr(len, addr) ({ 0; }) 647#define audit_sockaddr(len, addr) ({ 0; })
571#define audit_set_macxattr(n) do { ; } while (0)
572#define audit_mq_open(o,m,a) ((void)0) 648#define audit_mq_open(o,m,a) ((void)0)
573#define audit_mq_sendrecv(d,l,p,t) ((void)0) 649#define audit_mq_sendrecv(d,l,p,t) ((void)0)
574#define audit_mq_notify(d,n) ((void)0) 650#define audit_mq_notify(d,n) ((void)0)
@@ -579,7 +655,7 @@ extern int audit_signals;
579#define audit_ptrace(t) ((void)0) 655#define audit_ptrace(t) ((void)0)
580#define audit_n_rules 0 656#define audit_n_rules 0
581#define audit_signals 0 657#define audit_signals 0
582#endif 658#endif /* CONFIG_AUDITSYSCALL */
583 659
584#ifdef CONFIG_AUDIT 660#ifdef CONFIG_AUDIT
585/* These are defined in audit.c */ 661/* These are defined in audit.c */
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
index a27e56ca41a4..c2f1f6a5fcb8 100644
--- a/include/linux/ptrace.h
+++ b/include/linux/ptrace.h
@@ -112,6 +112,7 @@
112 112
113#include <linux/compiler.h> /* For unlikely. */ 113#include <linux/compiler.h> /* For unlikely. */
114#include <linux/sched.h> /* For struct task_struct. */ 114#include <linux/sched.h> /* For struct task_struct. */
115#include <linux/err.h> /* for IS_ERR_VALUE */
115 116
116 117
117extern long arch_ptrace(struct task_struct *child, long request, 118extern long arch_ptrace(struct task_struct *child, long request,
@@ -266,6 +267,15 @@ static inline void ptrace_release_task(struct task_struct *task)
266#define force_successful_syscall_return() do { } while (0) 267#define force_successful_syscall_return() do { } while (0)
267#endif 268#endif
268 269
270#ifndef is_syscall_success
271/*
272 * On most systems we can tell if a syscall is a success based on if the retval
273 * is an error value. On some systems like ia64 and powerpc they have different
274 * indicators of success/failure and must define their own.
275 */
276#define is_syscall_success(regs) (!IS_ERR_VALUE((unsigned long)(regs_return_value(regs))))
277#endif
278
269/* 279/*
270 * <asm/ptrace.h> should define the following things inside #ifdef __KERNEL__. 280 * <asm/ptrace.h> should define the following things inside #ifdef __KERNEL__.
271 * 281 *