CRED: Constify the kernel_cap_t arguments to the capset LSM hooks
[linux-2.6-block.git] / include / linux / security.h
index c13f1cec9abb154e24296216d91d225d245166b2..9f305d4a31a7c0babe80883fa8d36e9881302783 100644 (file)
 /* Maximum number of letters for an LSM name string */
 #define SECURITY_NAME_MAX      10
 
+/* If capable should audit the security request */
+#define SECURITY_CAP_NOAUDIT 0
+#define SECURITY_CAP_AUDIT 1
+
 struct ctl_table;
 struct audit_krule;
 
@@ -44,13 +48,17 @@ struct audit_krule;
  * These functions are in security/capability.c and are used
  * as the default capabilities functions
  */
-extern int cap_capable(struct task_struct *tsk, int cap);
+extern int cap_capable(struct task_struct *tsk, int cap, int audit);
 extern int cap_settime(struct timespec *ts, struct timezone *tz);
 extern int cap_ptrace_may_access(struct task_struct *child, unsigned int mode);
 extern int cap_ptrace_traceme(struct task_struct *parent);
 extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
-extern int cap_capset_check(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
-extern void cap_capset_set(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
+extern int cap_capset_check(const kernel_cap_t *effective,
+                           const kernel_cap_t *inheritable,
+                           const kernel_cap_t *permitted);
+extern void cap_capset_set(const kernel_cap_t *effective,
+                          const kernel_cap_t *inheritable,
+                          const kernel_cap_t *permitted);
 extern int cap_bprm_set_security(struct linux_binprm *bprm);
 extern void cap_bprm_apply_creds(struct linux_binprm *bprm, int unsafe);
 extern int cap_bprm_secureexec(struct linux_binprm *bprm);
@@ -1187,24 +1195,14 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
  *     Return 0 if the capability sets were successfully obtained.
  * @capset_check:
  *     Check permission before setting the @effective, @inheritable, and
- *     @permitted capability sets for the @target process.
- *     Caveat:  @target is also set to current if a set of processes is
- *     specified (i.e. all processes other than current and init or a
- *     particular process group).  Hence, the capset_set hook may need to
- *     revalidate permission to the actual target process.
- *     @target contains the task_struct structure for target process.
+ *     @permitted capability sets for the current process.
  *     @effective contains the effective capability set.
  *     @inheritable contains the inheritable capability set.
  *     @permitted contains the permitted capability set.
  *     Return 0 if permission is granted.
  * @capset_set:
  *     Set the @effective, @inheritable, and @permitted capability sets for
- *     the @target process.  Since capset_check cannot always check permission
- *     to the real @target process, this hook may also perform permission
- *     checking to determine if the current process is allowed to set the
- *     capability sets of the @target process.  However, this hook has no way
- *     of returning an error due to the structure of the sys_capset code.
- *     @target contains the task_struct structure for target process.
+ *     the current process.
  *     @effective contains the effective capability set.
  *     @inheritable contains the inheritable capability set.
  *     @permitted contains the permitted capability set.
@@ -1299,15 +1297,13 @@ struct security_operations {
        int (*capget) (struct task_struct *target,
                       kernel_cap_t *effective,
                       kernel_cap_t *inheritable, kernel_cap_t *permitted);
-       int (*capset_check) (struct task_struct *target,
-                            kernel_cap_t *effective,
-                            kernel_cap_t *inheritable,
-                            kernel_cap_t *permitted);
-       void (*capset_set) (struct task_struct *target,
-                           kernel_cap_t *effective,
-                           kernel_cap_t *inheritable,
-                           kernel_cap_t *permitted);
-       int (*capable) (struct task_struct *tsk, int cap);
+       int (*capset_check) (const kernel_cap_t *effective,
+                            const kernel_cap_t *inheritable,
+                            const kernel_cap_t *permitted);
+       void (*capset_set) (const kernel_cap_t *effective,
+                           const kernel_cap_t *inheritable,
+                           const kernel_cap_t *permitted);
+       int (*capable) (struct task_struct *tsk, int cap, int audit);
        int (*acct) (struct file *file);
        int (*sysctl) (struct ctl_table *table, int op);
        int (*quotactl) (int cmds, int type, int id, struct super_block *sb);
@@ -1568,15 +1564,14 @@ int security_capget(struct task_struct *target,
                    kernel_cap_t *effective,
                    kernel_cap_t *inheritable,
                    kernel_cap_t *permitted);
-int security_capset_check(struct task_struct *target,
-                         kernel_cap_t *effective,
-                         kernel_cap_t *inheritable,
-                         kernel_cap_t *permitted);
-void security_capset_set(struct task_struct *target,
-                        kernel_cap_t *effective,
-                        kernel_cap_t *inheritable,
-                        kernel_cap_t *permitted);
+int security_capset_check(const kernel_cap_t *effective,
+                         const kernel_cap_t *inheritable,
+                         const kernel_cap_t *permitted);
+void security_capset_set(const kernel_cap_t *effective,
+                        const kernel_cap_t *inheritable,
+                        const kernel_cap_t *permitted);
 int security_capable(struct task_struct *tsk, int cap);
+int security_capable_noaudit(struct task_struct *tsk, int cap);
 int security_acct(struct file *file);
 int security_sysctl(struct ctl_table *table, int op);
 int security_quotactl(int cmds, int type, int id, struct super_block *sb);
@@ -1764,25 +1759,28 @@ static inline int security_capget(struct task_struct *target,
        return cap_capget(target, effective, inheritable, permitted);
 }
 
-static inline int security_capset_check(struct task_struct *target,
-                                        kernel_cap_t *effective,
-                                        kernel_cap_t *inheritable,
-                                        kernel_cap_t *permitted)
+static inline int security_capset_check(const kernel_cap_t *effective,
+                                       const kernel_cap_t *inheritable,
+                                       const kernel_cap_t *permitted)
 {
-       return cap_capset_check(target, effective, inheritable, permitted);
+       return cap_capset_check(effective, inheritable, permitted);
 }
 
-static inline void security_capset_set(struct task_struct *target,
-                                       kernel_cap_t *effective,
-                                       kernel_cap_t *inheritable,
-                                       kernel_cap_t *permitted)
+static inline void security_capset_set(const kernel_cap_t *effective,
+                                      const kernel_cap_t *inheritable,
+                                      const kernel_cap_t *permitted)
 {
-       cap_capset_set(target, effective, inheritable, permitted);
+       cap_capset_set(effective, inheritable, permitted);
 }
 
 static inline int security_capable(struct task_struct *tsk, int cap)
 {
-       return cap_capable(tsk, cap);
+       return cap_capable(tsk, cap, SECURITY_CAP_AUDIT);
+}
+
+static inline int security_capable_noaudit(struct task_struct *tsk, int cap)
+{
+       return cap_capable(tsk, cap, SECURITY_CAP_NOAUDIT);
 }
 
 static inline int security_acct(struct file *file)