Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 329099
b: refs/heads/master
c: c6993e4
h: refs/heads/master
i:
  329097: 042eb72
  329095: 4902986
v: v3
  • Loading branch information
Kees Cook authored and James Morris committed Sep 5, 2012
1 parent a8ead46 commit b7feba3
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 81198078d7da4240f3cbfc2c6a8ea6cd417f51a7
refs/heads/master: c6993e4ac002c92bc75379212e9179c36d4bf7ee
31 changes: 31 additions & 0 deletions trunk/include/linux/security.h
Original file line number Diff line number Diff line change
Expand Up @@ -3021,5 +3021,36 @@ static inline void free_secdata(void *secdata)
{ }
#endif /* CONFIG_SECURITY */

#ifdef CONFIG_SECURITY_YAMA
extern int yama_ptrace_access_check(struct task_struct *child,
unsigned int mode);
extern int yama_ptrace_traceme(struct task_struct *parent);
extern void yama_task_free(struct task_struct *task);
extern int yama_task_prctl(int option, unsigned long arg2, unsigned long arg3,
unsigned long arg4, unsigned long arg5);
#else
static inline int yama_ptrace_access_check(struct task_struct *child,
unsigned int mode)
{
return 0;
}

static inline int yama_ptrace_traceme(struct task_struct *parent)
{
return 0;
}

static inline void yama_task_free(struct task_struct *task)
{
}

static inline int yama_task_prctl(int option, unsigned long arg2,
unsigned long arg3, unsigned long arg4,
unsigned long arg5)
{
return -ENOSYS;
}
#endif /* CONFIG_SECURITY_YAMA */

#endif /* ! __LINUX_SECURITY_H */

21 changes: 21 additions & 0 deletions trunk/security/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,23 @@ int __init register_security(struct security_operations *ops)

int security_ptrace_access_check(struct task_struct *child, unsigned int mode)
{
#ifdef CONFIG_SECURITY_YAMA_STACKED
int rc;
rc = yama_ptrace_access_check(child, mode);
if (rc)
return rc;
#endif
return security_ops->ptrace_access_check(child, mode);
}

int security_ptrace_traceme(struct task_struct *parent)
{
#ifdef CONFIG_SECURITY_YAMA_STACKED
int rc;
rc = yama_ptrace_traceme(parent);
if (rc)
return rc;
#endif
return security_ops->ptrace_traceme(parent);
}

Expand Down Expand Up @@ -761,6 +773,9 @@ int security_task_create(unsigned long clone_flags)

void security_task_free(struct task_struct *task)
{
#ifdef CONFIG_SECURITY_YAMA_STACKED
yama_task_free(task);
#endif
security_ops->task_free(task);
}

Expand Down Expand Up @@ -876,6 +891,12 @@ int security_task_wait(struct task_struct *p)
int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
unsigned long arg4, unsigned long arg5)
{
#ifdef CONFIG_SECURITY_YAMA_STACKED
int rc;
rc = yama_task_prctl(option, arg2, arg3, arg4, arg5);
if (rc != -ENOSYS)
return rc;
#endif
return security_ops->task_prctl(option, arg2, arg3, arg4, arg5);
}

Expand Down
8 changes: 8 additions & 0 deletions trunk/security/yama/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@ config SECURITY_YAMA
Further information can be found in Documentation/security/Yama.txt.

If you are unsure how to answer this question, answer N.

config SECURITY_YAMA_STACKED
bool "Yama stacked with other LSMs"
depends on SECURITY_YAMA
default n
help
When Yama is built into the kernel, force it to stack with the
selected primary LSM.
14 changes: 10 additions & 4 deletions trunk/security/yama/yama_lsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static void yama_ptracer_del(struct task_struct *tracer,
* yama_task_free - check for task_pid to remove from exception list
* @task: task being removed
*/
static void yama_task_free(struct task_struct *task)
void yama_task_free(struct task_struct *task)
{
yama_ptracer_del(task, task);
}
Expand All @@ -116,7 +116,7 @@ static void yama_task_free(struct task_struct *task)
* Return 0 on success, -ve on error. -ENOSYS is returned when Yama
* does not handle the given option.
*/
static int yama_task_prctl(int option, unsigned long arg2, unsigned long arg3,
int yama_task_prctl(int option, unsigned long arg2, unsigned long arg3,
unsigned long arg4, unsigned long arg5)
{
int rc;
Expand Down Expand Up @@ -243,7 +243,7 @@ static int ptracer_exception_found(struct task_struct *tracer,
*
* Returns 0 if following the ptrace is allowed, -ve on error.
*/
static int yama_ptrace_access_check(struct task_struct *child,
int yama_ptrace_access_check(struct task_struct *child,
unsigned int mode)
{
int rc;
Expand Down Expand Up @@ -296,7 +296,7 @@ static int yama_ptrace_access_check(struct task_struct *child,
*
* Returns 0 if following the ptrace is allowed, -ve on error.
*/
static int yama_ptrace_traceme(struct task_struct *parent)
int yama_ptrace_traceme(struct task_struct *parent)
{
int rc;

Expand Down Expand Up @@ -330,6 +330,7 @@ static int yama_ptrace_traceme(struct task_struct *parent)
return rc;
}

#ifndef CONFIG_SECURITY_YAMA_STACKED
static struct security_operations yama_ops = {
.name = "yama",

Expand All @@ -338,6 +339,7 @@ static struct security_operations yama_ops = {
.task_prctl = yama_task_prctl,
.task_free = yama_task_free,
};
#endif

#ifdef CONFIG_SYSCTL
static int yama_dointvec_minmax(struct ctl_table *table, int write,
Expand Down Expand Up @@ -384,13 +386,17 @@ static struct ctl_table yama_sysctl_table[] = {

static __init int yama_init(void)
{
#ifndef CONFIG_SECURITY_YAMA_STACKED
if (!security_module_enable(&yama_ops))
return 0;
#endif

printk(KERN_INFO "Yama: becoming mindful.\n");

#ifndef CONFIG_SECURITY_YAMA_STACKED
if (register_security(&yama_ops))
panic("Yama: kernel registration failed.\n");
#endif

#ifdef CONFIG_SYSCTL
if (!register_sysctl_paths(yama_sysctl_path, yama_sysctl_table))
Expand Down

0 comments on commit b7feba3

Please sign in to comment.