aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/security.h
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2012-01-03 12:25:14 -0500
committerEric Paris <eparis@redhat.com>2012-01-05 18:52:53 -0500
commit6a9de49115d5ff9871d953af1a5c8249e1585731 (patch)
treeeee3700ccc2ce26c566bfe99129e646fac9f983e /include/linux/security.h
parent2653812e14f4e16688ec8247d7fd290bdbbc4747 (diff)
capabilities: remove the task from capable LSM hook entirely
The capabilities framework is based around credentials, not necessarily the current task. Yet we still passed the current task down into LSMs from the security_capable() LSM hook as if it was a meaningful portion of the security decision. This patch removes the 'generic' passing of current and instead forces individual LSMs to use current explicitly if they think it is appropriate. In our case those LSMs are SELinux and AppArmor. I believe the AppArmor use of current is incorrect, but that is wholely unrelated to this patch. This patch does not change what AppArmor does, it just makes it clear in the AppArmor code that it is doing it. The SELinux code still uses current in it's audit message, which may also be wrong and needs further investigation. Again this is NOT a change, it may have always been wrong, this patch just makes it clear what is happening. Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'include/linux/security.h')
-rw-r--r--include/linux/security.h16
1 files changed, 7 insertions, 9 deletions
diff --git a/include/linux/security.h b/include/linux/security.h
index ebd2a53a3d07..4921163b2752 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -53,8 +53,8 @@ struct user_namespace;
53 * These functions are in security/capability.c and are used 53 * These functions are in security/capability.c and are used
54 * as the default capabilities functions 54 * as the default capabilities functions
55 */ 55 */
56extern int cap_capable(struct task_struct *tsk, const struct cred *cred, 56extern int cap_capable(const struct cred *cred, struct user_namespace *ns,
57 struct user_namespace *ns, int cap, int audit); 57 int cap, int audit);
58extern int cap_settime(const struct timespec *ts, const struct timezone *tz); 58extern int cap_settime(const struct timespec *ts, const struct timezone *tz);
59extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode); 59extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode);
60extern int cap_ptrace_traceme(struct task_struct *parent); 60extern int cap_ptrace_traceme(struct task_struct *parent);
@@ -1261,7 +1261,6 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
1261 * @capable: 1261 * @capable:
1262 * Check whether the @tsk process has the @cap capability in the indicated 1262 * Check whether the @tsk process has the @cap capability in the indicated
1263 * credentials. 1263 * credentials.
1264 * @tsk contains the task_struct for the process.
1265 * @cred contains the credentials to use. 1264 * @cred contains the credentials to use.
1266 * @ns contains the user namespace we want the capability in 1265 * @ns contains the user namespace we want the capability in
1267 * @cap contains the capability <include/linux/capability.h>. 1266 * @cap contains the capability <include/linux/capability.h>.
@@ -1385,8 +1384,8 @@ struct security_operations {
1385 const kernel_cap_t *effective, 1384 const kernel_cap_t *effective,
1386 const kernel_cap_t *inheritable, 1385 const kernel_cap_t *inheritable,
1387 const kernel_cap_t *permitted); 1386 const kernel_cap_t *permitted);
1388 int (*capable) (struct task_struct *tsk, const struct cred *cred, 1387 int (*capable) (const struct cred *cred, struct user_namespace *ns,
1389 struct user_namespace *ns, int cap, int audit); 1388 int cap, int audit);
1390 int (*quotactl) (int cmds, int type, int id, struct super_block *sb); 1389 int (*quotactl) (int cmds, int type, int id, struct super_block *sb);
1391 int (*quota_on) (struct dentry *dentry); 1390 int (*quota_on) (struct dentry *dentry);
1392 int (*syslog) (int type); 1391 int (*syslog) (int type);
@@ -1867,7 +1866,7 @@ static inline int security_capset(struct cred *new,
1867static inline int security_capable(struct user_namespace *ns, 1866static inline int security_capable(struct user_namespace *ns,
1868 const struct cred *cred, int cap) 1867 const struct cred *cred, int cap)
1869{ 1868{
1870 return cap_capable(current, cred, ns, cap, SECURITY_CAP_AUDIT); 1869 return cap_capable(cred, ns, cap, SECURITY_CAP_AUDIT);
1871} 1870}
1872 1871
1873static inline int security_real_capable(struct task_struct *tsk, struct user_namespace *ns, int cap) 1872static inline int security_real_capable(struct task_struct *tsk, struct user_namespace *ns, int cap)
@@ -1875,7 +1874,7 @@ static inline int security_real_capable(struct task_struct *tsk, struct user_nam
1875 int ret; 1874 int ret;
1876 1875
1877 rcu_read_lock(); 1876 rcu_read_lock();
1878 ret = cap_capable(tsk, __task_cred(tsk), ns, cap, SECURITY_CAP_AUDIT); 1877 ret = cap_capable(__task_cred(tsk), ns, cap, SECURITY_CAP_AUDIT);
1879 rcu_read_unlock(); 1878 rcu_read_unlock();
1880 return ret; 1879 return ret;
1881} 1880}
@@ -1886,8 +1885,7 @@ int security_real_capable_noaudit(struct task_struct *tsk, struct user_namespace
1886 int ret; 1885 int ret;
1887 1886
1888 rcu_read_lock(); 1887 rcu_read_lock();
1889 ret = cap_capable(tsk, __task_cred(tsk), ns, cap, 1888 ret = cap_capable(__task_cred(tsk), ns, cap, SECURITY_CAP_NOAUDIT);
1890 SECURITY_CAP_NOAUDIT);
1891 rcu_read_unlock(); 1889 rcu_read_unlock();
1892 return ret; 1890 return ret;
1893} 1891}