aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2008-11-11 06:02:50 -0500
committerJames Morris <jmorris@namei.org>2008-11-11 06:02:50 -0500
commit06112163f5fd9e491a7f810443d81efa9d88e247 (patch)
tree48039f7488abbec36c0982a57405b57d47311dd6 /include
parent637d32dc720897616e8a1a4f9e9609e29d431800 (diff)
Add a new capable interface that will be used by systems that use audit to
make an A or B type decision instead of a security decision. Currently this is the case at least for filesystems when deciding if a process can use the reserved 'root' blocks and for the case of things like the oom algorithm determining if processes are root processes and should be less likely to be killed. These types of security system requests should not be audited or logged since they are not really security decisions. It would be possible to solve this problem like the vm_enough_memory security check did by creating a new LSM interface and moving all of the policy into that interface but proves the needlessly bloat the LSM and provide complex indirection. This merely allows those decisions to be made where they belong and to not flood logs or printk with denials for thing that are not security decisions. Signed-off-by: Eric Paris <eparis@redhat.com> Acked-by: Stephen Smalley <sds@tycho.nsa.gov> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/capability.h3
-rw-r--r--include/linux/security.h16
2 files changed, 16 insertions, 3 deletions
diff --git a/include/linux/capability.h b/include/linux/capability.h
index 0f1950181102..b313ba1dd5d1 100644
--- a/include/linux/capability.h
+++ b/include/linux/capability.h
@@ -521,6 +521,8 @@ extern const kernel_cap_t __cap_init_eff_set;
521 521
522kernel_cap_t cap_set_effective(const kernel_cap_t pE_new); 522kernel_cap_t cap_set_effective(const kernel_cap_t pE_new);
523 523
524extern int security_capable(struct task_struct *t, int cap);
525extern int security_capable_noaudit(struct task_struct *t, int cap);
524/** 526/**
525 * has_capability - Determine if a task has a superior capability available 527 * has_capability - Determine if a task has a superior capability available
526 * @t: The task in question 528 * @t: The task in question
@@ -532,6 +534,7 @@ kernel_cap_t cap_set_effective(const kernel_cap_t pE_new);
532 * Note that this does not set PF_SUPERPRIV on the task. 534 * Note that this does not set PF_SUPERPRIV on the task.
533 */ 535 */
534#define has_capability(t, cap) (security_capable((t), (cap)) == 0) 536#define has_capability(t, cap) (security_capable((t), (cap)) == 0)
537#define has_capability_noaudit(t, cap) (security_capable_noaudit((t), (cap)) == 0)
535 538
536extern int capable(int cap); 539extern int capable(int cap);
537 540
diff --git a/include/linux/security.h b/include/linux/security.h
index c13f1cec9abb..5fe28a671cd3 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -37,6 +37,10 @@
37/* Maximum number of letters for an LSM name string */ 37/* Maximum number of letters for an LSM name string */
38#define SECURITY_NAME_MAX 10 38#define SECURITY_NAME_MAX 10
39 39
40/* If capable should audit the security request */
41#define SECURITY_CAP_NOAUDIT 0
42#define SECURITY_CAP_AUDIT 1
43
40struct ctl_table; 44struct ctl_table;
41struct audit_krule; 45struct audit_krule;
42 46
@@ -44,7 +48,7 @@ struct audit_krule;
44 * These functions are in security/capability.c and are used 48 * These functions are in security/capability.c and are used
45 * as the default capabilities functions 49 * as the default capabilities functions
46 */ 50 */
47extern int cap_capable(struct task_struct *tsk, int cap); 51extern int cap_capable(struct task_struct *tsk, int cap, int audit);
48extern int cap_settime(struct timespec *ts, struct timezone *tz); 52extern int cap_settime(struct timespec *ts, struct timezone *tz);
49extern int cap_ptrace_may_access(struct task_struct *child, unsigned int mode); 53extern int cap_ptrace_may_access(struct task_struct *child, unsigned int mode);
50extern int cap_ptrace_traceme(struct task_struct *parent); 54extern int cap_ptrace_traceme(struct task_struct *parent);
@@ -1307,7 +1311,7 @@ struct security_operations {
1307 kernel_cap_t *effective, 1311 kernel_cap_t *effective,
1308 kernel_cap_t *inheritable, 1312 kernel_cap_t *inheritable,
1309 kernel_cap_t *permitted); 1313 kernel_cap_t *permitted);
1310 int (*capable) (struct task_struct *tsk, int cap); 1314 int (*capable) (struct task_struct *tsk, int cap, int audit);
1311 int (*acct) (struct file *file); 1315 int (*acct) (struct file *file);
1312 int (*sysctl) (struct ctl_table *table, int op); 1316 int (*sysctl) (struct ctl_table *table, int op);
1313 int (*quotactl) (int cmds, int type, int id, struct super_block *sb); 1317 int (*quotactl) (int cmds, int type, int id, struct super_block *sb);
@@ -1577,6 +1581,7 @@ void security_capset_set(struct task_struct *target,
1577 kernel_cap_t *inheritable, 1581 kernel_cap_t *inheritable,
1578 kernel_cap_t *permitted); 1582 kernel_cap_t *permitted);
1579int security_capable(struct task_struct *tsk, int cap); 1583int security_capable(struct task_struct *tsk, int cap);
1584int security_capable_noaudit(struct task_struct *tsk, int cap);
1580int security_acct(struct file *file); 1585int security_acct(struct file *file);
1581int security_sysctl(struct ctl_table *table, int op); 1586int security_sysctl(struct ctl_table *table, int op);
1582int security_quotactl(int cmds, int type, int id, struct super_block *sb); 1587int security_quotactl(int cmds, int type, int id, struct super_block *sb);
@@ -1782,7 +1787,12 @@ static inline void security_capset_set(struct task_struct *target,
1782 1787
1783static inline int security_capable(struct task_struct *tsk, int cap) 1788static inline int security_capable(struct task_struct *tsk, int cap)
1784{ 1789{
1785 return cap_capable(tsk, cap); 1790 return cap_capable(tsk, cap, SECURITY_CAP_AUDIT);
1791}
1792
1793static inline int security_capable_noaudit(struct task_struct *tsk, int cap)
1794{
1795 return cap_capable(tsk, cap, SECURITY_CAP_NOAUDIT);
1786} 1796}
1787 1797
1788static inline int security_acct(struct file *file) 1798static inline int security_acct(struct file *file)