security: Yama LSM
Subsystems (3)
PATCH 1/1 security: Yama LSM
This creates the Yama Linux Security Module to collect several security features that have existed in various forms over the years and have been carried by other distros outside the mainline kernel.
It includes symlink and hardlink protections, as well as PTRACE scope limitations.
--- security/Kconfig | 6 + security/Makefile | 2 + security/yama/Kconfig | 72 ++++++++++++++ security/yama/Makefile | 3 + security/yama/yama_lsm.c | 238 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 321 insertions(+), 0 deletions(-) create mode 100644 security/yama/Kconfig create mode 100644 security/yama/Makefile create mode 100644 security/yama/yama_lsm.c
security/Kconfig +6 -0
@@ -140,6 +140,7 @@ config LSM_MMAP_MIN_ADDR source security/selinux/Kconfig source security/smack/Kconfig source security/tomoyo/Kconfig +source security/yama/Kconfig source security/integrity/ima/Kconfig
@@ -148,6 +149,7 @@ choice default DEFAULT_SECURITY_SELINUX if SECURITY_SELINUX default DEFAULT_SECURITY_SMACK if SECURITY_SMACK default DEFAULT_SECURITY_TOMOYO if SECURITY_TOMOYO + default DEFAULT_SECURITY_YAMA if SECURITY_YAMA default DEFAULT_SECURITY_DAC help
@@ -163,6 +165,9 @@ choice config DEFAULT_SECURITY_TOMOYO bool "TOMOYO" if SECURITY_TOMOYO=y + config DEFAULT_SECURITY_YAMA + bool "Yama" if SECURITY_YAMA=y + config DEFAULT_SECURITY_DAC bool "Unix Discretionary Access Controls"
@@ -173,6 +178,7 @@ config DEFAULT_SECURITY default "selinux" if DEFAULT_SECURITY_SELINUX default "smack" if DEFAULT_SECURITY_SMACK default "tomoyo" if DEFAULT_SECURITY_TOMOYO + default "yama" if DEFAULT_SECURITY_YAMA default "" if DEFAULT_SECURITY_DAC endmenu
security/Makefile +2 -0
@@ -6,6 +6,7 @@ obj-$(CONFIG_KEYS) += keys/ subdir-$(CONFIG_SECURITY_SELINUX) += selinux subdir-$(CONFIG_SECURITY_SMACK) += smack subdir-$(CONFIG_SECURITY_TOMOYO) += tomoyo +subdir-$(CONFIG_SECURITY_YAMA) += yama # always enable default capabilities obj-y += commoncap.o
@@ -19,6 +20,7 @@ obj-$(CONFIG_SECURITY_SELINUX) += selinux/built-in.o obj-$(CONFIG_SECURITY_SMACK) += smack/built-in.o obj-$(CONFIG_AUDIT) += lsm_audit.o obj-$(CONFIG_SECURITY_TOMOYO) += tomoyo/built-in.o +obj-$(CONFIG_SECURITY_YAMA) += yama/built-in.o obj-$(CONFIG_CGROUP_DEVICE) += device_cgroup.o # Object integrity file lists
security/yama/Kconfig new file +72 -0
72 lines not on this page · raw message
security/yama/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +obj-$(CONFIG_SECURITY_YAMA) := yama.o + +yama-y := yama_lsm.o
security/yama/yama_lsm.c new file +238 -0
238 lines not on this page · raw message
Signature · 6 lines
1.7.1 -- Kees Cook Ubuntu Security Team
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Tetsuo,
Quoted 10 lines · Tetsuo Handa
security/yama/yama_lsm.c line 44
Quoted 6 lines · Kees Cook
security/yama/yama_lsm.c new file +6
-0+/* require ptrace target be a child of ptracer on attach */ +if (mode ==PTRACE_MODE_ATTACH && ptrace_scope && + !capable (CAP_SYS_PTRACE )) { +struct task_struct *walker = child; + +read_lock (&tasklist_lock);Holding
tasklist_lockdoes not imply rcu protection. Don't you needrcu_read_lock()likesetpriority()andgetppid()?
You're totally right, thanks for the catch! Looks like setpriority() does a similar kind of thing, so I've wrapped the whole thing in rcu_ now:
...
+ rcu_read_lock();
read_lock(&tasklist_lock);
while (walker->pid > 0) {
...
rc = -EPERM;
read_unlock(&tasklist_lock);+ rcu_read_unlock();
...
-Kees
Signature · 2 lines
Kees Cook Ubuntu Security Team
Hi,
What is YAMA?
Where is the tree?
Thanks,
Dmitry
Quoted 33 lines · ext Kees Cook
Hi Tetsuo,
Quoted 9 lines · Tetsuo Handa
security/yama/yama_lsm.c line 44
Quoted 7 lines · Kees Cook
security/yama/yama_lsm.c new file +6
-0+/* require ptrace target be a child of ptracer on attach */ +if (mode ==PTRACE_MODE_ATTACH && ptrace_scope && + !capable (CAP_SYS_PTRACE )) { +struct task_struct *walker = child; + +read_lock (&tasklist_lock);Quoted 3 lines
Holding
tasklist_lockdoes not imply rcu protection. Don't you needrcu_read_lock()likesetpriority()andgetppid()?You're totally right, thanks for the catch! Looks like
setpriority()does a similar kind of thing, so I've wrapped the whole thing inrcu_now:...
(quoted diff) +2
-1+ rcu_read_lock(); read_lock(&tasklist_lock); while (walker->pid > 0) { rc = -EPERM; read_unlock(&tasklist_lock); + rcu_read_unlock(); -Kees
Hi Dmitry,
Quoted 1 line · Dmitry Kasatkin
What is YAMA?
"Yama" is just the name of the LSM. It's inspired by:
http://en.wikipedia.org/wiki/Yama
Quoted 1 line
Where is the tree?
At the moment:
http://kernel.ubuntu.com/git?p=kees/linux-2.6.git;a=shortlog;h=refs/heads/yama
-Kees
Signature · 2 lines
Kees Cook Ubuntu Security Team
Quoted 9 lines · ext Kees Cook
Hi Dmitry,
Quoted 2 lines · Dmitry Kasatkin
What is YAMA?
"Yama" is just the name of the LSM. It's inspired by:
http://en.wikipedia.org/wiki/Yama
Really?
Quoted 8 lines
Quoted 3 lines
Where is the tree?
At the moment:
http://kernel.ubuntu.com/git?p=kees/linux-2.6.git;a=shortlog;h=refs/heads/yama-Kees
"You've already had those suggestions some days ago. Use a security module, either by using something like SELinux (where you can do this just fine as far as I can see including exceptions by label for problem apps)", [Alan Cox, 2010-06-08], or integrate it into an already existing solution eg. grsecurity (www.grsecurity.net).
Christian Stroetmann
Quoted 5 lines · Christian Stroetmann
"You've already had those suggestions some days ago. Use a security module, either by using something like SELinux (where you can do this just fine as far as I can see including exceptions by label for problem apps)", [Alan Cox, 2010-06-08], or integrate it into an already existing solution eg. grsecurity (www.grsecurity.net).
You appear to be quoting[1], but you left off a bit. To edit it a bit:
"Use a security module, either by using something like SELinux (...), or write your own little security module that does it."
I have done the latter.
I don't need to integrate this into grsecurity because grsecurity already has these protections. It is Openwall and grsecurity that I'm using as the starting point for this attempt at upstreaming the protections.
-Kees
[1] http://lkml.org/lkml/2010/6/8/56
Signature · 2 lines
Kees Cook Ubuntu Security Team
Quoted 10 lines · Kees Cook
Quoted 6 lines · Christian Stroetmann
"You've already had those suggestions some days ago. Use a security module, either by using something like SELinux (where you can do this just fine as far as I can see including exceptions by label for problem apps)", [Alan Cox, 2010-06-08], or integrate it into an already existing solution eg. grsecurity (www.grsecurity.net).
You appear to be quoting[1], but you left off a bit. To edit it a bit:
Quoted 9 lines
"Use a security module, either by using something like SELinux (...), or write your own little security module that does it."
I have done the latter.
I don't need to integrate this into grsecurity because grsecurity already has these protections. It is Openwall and grsecurity that I'm using as the starting point for this attempt at upstreaming the protections.
So, this sounds as if you are porting functionalities from grsecurtiy into LSM. But [1].
Quoted 5 lines
-Kees
[1] http://www.grsecurity.net/lsm.php
Chrisitan Stroetmann
Quoted 14 lines · Christian Stroetmann
Quoted 13 lines · Kees Cook
Quoted 5 lines · Christian Stroetmann
"You've already had those suggestions some days ago. Use a security module, either by using something like SELinux (where you can do this just fine as far as I can see including exceptions by label for problem apps)", [Alan Cox, 2010-06-08], or integrate it into an already existing solution eg. grsecurity (www.grsecurity.net).
You appear to be quoting[1], but you left off a bit. To edit it a bit:
"Use a security module, either by using something like SELinux (...), or write your own little security module that does it."
I have done the latter.
Quoted 7 lines
Quoted 3 lines
I don't need to integrate this into grsecurity because grsecurity already has these protections. It is Openwall and grsecurity that I'm using as the starting point for this attempt at upstreaming the protections.
So, this sounds as if you are porting functionalities from grsecurtiy into LSM. But [1].
[1] http://www.grsecurity.net/lsm.php
grsecurity is not in mainline. I want a few specific features but not the entire patchset, therefore, I must port functionalities from grsecurity into mainline. Since these features have been rejected from the core, they must go into an LSM. Luckily for me, there are hooks to handle the 3 protections I am currently interested in. :)
If you can, please come to the Linux Security Summit[1], where things like the future of LSM will be discussed.
-Kees
[1] https://security.wiki.kernel.org/index.php/LinuxSecuritySummit2010/Schedule
Signature · 2 lines
Kees Cook Ubuntu Security Team
Quoted 5 lines
I have done the latter.
I don't need to integrate this into grsecurity because grsecurity already has these protections. It is Openwall and grsecurity that I'm using as the starting point for this attempt at upstreaming the protections.
In effect its turning bits of grsecurity into an LSM which is a good thing.
Alan