<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/security/yama, branch linux-5.1.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.</subtitle>
<id>https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-5.1.y</id>
<link rel='self' href='https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-5.1.y'/>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/'/>
<updated>2019-03-28T17:02:29Z</updated>
<entry>
<title>Yama: mark local symbols as static</title>
<updated>2019-03-28T17:02:29Z</updated>
<author>
<name>Jann Horn</name>
<email>jannh@google.com</email>
</author>
<published>2019-03-28T00:21:42Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=1aa176ef5a451adc0546d5aaa3fb107975c786b7'/>
<id>urn:sha1:1aa176ef5a451adc0546d5aaa3fb107975c786b7</id>
<content type='text'>
sparse complains that Yama defines functions and a variable as non-static
even though they don't exist in any header. Fix it by making them static.

Co-developed-by: Mukesh Ojha &lt;mojha@codeaurora.org&gt;
Signed-off-by: Mukesh Ojha &lt;mojha@codeaurora.org&gt;
Signed-off-by: Jann Horn &lt;jannh@google.com&gt;
[kees: merged similar static-ness fixes into a single patch]
Link: https://lkml.kernel.org/r/20190326230841.87834-1-jannh@google.com
Link: https://lkml.kernel.org/r/1553673018-19234-1-git-send-email-mojha@codeaurora.org
Signed-off-by: Kees Cook &lt;keescook@chromium.org&gt;
Signed-off-by: James Morris &lt;james.morris@microsoft.com&gt;
</content>
</entry>
<entry>
<title>Merge tag 'v5.0-rc3' into next-general</title>
<updated>2019-01-22T22:33:10Z</updated>
<author>
<name>James Morris</name>
<email>james.morris@microsoft.com</email>
</author>
<published>2019-01-22T22:33:10Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=9624d5c9c7ff6836bbf9f9b230fd1fcf3d56f91a'/>
<id>urn:sha1:9624d5c9c7ff6836bbf9f9b230fd1fcf3d56f91a</id>
<content type='text'>
Sync to Linux 5.0-rc3 to pull in the VFS changes which impacted a lot
of the LSM code.
</content>
</entry>
<entry>
<title>Yama: Check for pid death before checking ancestry</title>
<updated>2019-01-16T20:00:56Z</updated>
<author>
<name>Kees Cook</name>
<email>keescook@chromium.org</email>
</author>
<published>2019-01-16T18:31:09Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=9474f4e7cd71a633fa1ef93b7daefd44bbdfd482'/>
<id>urn:sha1:9474f4e7cd71a633fa1ef93b7daefd44bbdfd482</id>
<content type='text'>
It's possible that a pid has died before we take the rcu lock, in which
case we can't walk the ancestry list as it may be detached. Instead, check
for death first before doing the walk.

Reported-by: syzbot+a9ac39bf55329e206219@syzkaller.appspotmail.com
Fixes: 2d514487faf1 ("security: Yama LSM")
Cc: stable@vger.kernel.org
Suggested-by: Oleg Nesterov &lt;oleg@redhat.com&gt;
Signed-off-by: Kees Cook &lt;keescook@chromium.org&gt;
Signed-off-by: James Morris &lt;james.morris@microsoft.com&gt;
</content>
</entry>
<entry>
<title>Yama: Initialize as ordered LSM</title>
<updated>2019-01-08T21:18:43Z</updated>
<author>
<name>Kees Cook</name>
<email>keescook@chromium.org</email>
</author>
<published>2018-09-14T22:37:20Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=d6aed64b74b73b64278c059eacd59d87167aa968'/>
<id>urn:sha1:d6aed64b74b73b64278c059eacd59d87167aa968</id>
<content type='text'>
This converts Yama from being a direct "minor" LSM into an ordered LSM.

Signed-off-by: Kees Cook &lt;keescook@chromium.org&gt;
Reviewed-by: Casey Schaufler &lt;casey@schaufler-ca.com&gt;
</content>
</entry>
<entry>
<title>pids: introduce find_get_task_by_vpid() helper</title>
<updated>2018-02-07T02:32:46Z</updated>
<author>
<name>Mike Rapoport</name>
<email>rppt@linux.vnet.ibm.com</email>
</author>
<published>2018-02-06T23:40:17Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=2ee0826085d1c0281cb60c1f4bc3e0c27efeedc3'/>
<id>urn:sha1:2ee0826085d1c0281cb60c1f4bc3e0c27efeedc3</id>
<content type='text'>
There are several functions that do find_task_by_vpid() followed by
get_task_struct().  We can use a helper function instead.

Link: http://lkml.kernel.org/r/1509602027-11337-1-git-send-email-rppt@linux.vnet.ibm.com
Signed-off-by: Mike Rapoport &lt;rppt@linux.vnet.ibm.com&gt;
Acked-by: Oleg Nesterov &lt;oleg@redhat.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>doc: ReSTify Yama.txt</title>
<updated>2017-05-18T16:33:04Z</updated>
<author>
<name>Kees Cook</name>
<email>keescook@chromium.org</email>
</author>
<published>2017-05-13T11:51:47Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=90bb766440f2147486a2acc3e793d7b8348b0c22'/>
<id>urn:sha1:90bb766440f2147486a2acc3e793d7b8348b0c22</id>
<content type='text'>
Adjusts for ReST markup and moves under LSM admin guide.

Signed-off-by: Kees Cook &lt;keescook@chromium.org&gt;
Signed-off-by: Jonathan Corbet &lt;corbet@lwn.net&gt;
</content>
</entry>
<entry>
<title>security: mark LSM hooks as __ro_after_init</title>
<updated>2017-03-06T00:00:15Z</updated>
<author>
<name>James Morris</name>
<email>jmorris@namei.org</email>
</author>
<published>2017-02-14T13:18:51Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=ca97d939db114c8d1619e10a3b82af8615372dae'/>
<id>urn:sha1:ca97d939db114c8d1619e10a3b82af8615372dae</id>
<content type='text'>
Mark all of the registration hooks as __ro_after_init (via the
__lsm_ro_after_init macro).

Signed-off-by: James Morris &lt;james.l.morris@oracle.com&gt;
Acked-by:  Stephen Smalley &lt;sds@tycho.nsa.gov&gt;
Acked-by: Kees Cook &lt;keescook@chromium.org&gt;
</content>
</entry>
<entry>
<title>LSM: Add /sys/kernel/security/lsm</title>
<updated>2017-01-19T02:18:29Z</updated>
<author>
<name>Casey Schaufler</name>
<email>casey@schaufler-ca.com</email>
</author>
<published>2017-01-19T01:09:05Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=d69dece5f5b6bc7a5e39d2b6136ddc69469331fe'/>
<id>urn:sha1:d69dece5f5b6bc7a5e39d2b6136ddc69469331fe</id>
<content type='text'>
I am still tired of having to find indirect ways to determine
what security modules are active on a system. I have added
/sys/kernel/security/lsm, which contains a comma separated
list of the active security modules. No more groping around
in /proc/filesystems or other clever hacks.

Unchanged from previous versions except for being updated
to the latest security next branch.

Signed-off-by: Casey Schaufler &lt;casey@schaufler-ca.com&gt;
Acked-by: John Johansen &lt;john.johansen@canonical.com&gt;
Acked-by: Paul Moore &lt;paul@paul-moore.com&gt;
Acked-by: Kees Cook &lt;keescook@chromium.org&gt;
Signed-off-by: James Morris &lt;james.l.morris@oracle.com&gt;
</content>
</entry>
<entry>
<title>Yama: allow access for the current ptrace parent</title>
<updated>2016-12-05T00:48:01Z</updated>
<author>
<name>Josh Stone</name>
<email>jistone@redhat.com</email>
</author>
<published>2016-12-02T23:49:43Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=50523a29d900d5a403e0352d3d7aeda6a33df25c'/>
<id>urn:sha1:50523a29d900d5a403e0352d3d7aeda6a33df25c</id>
<content type='text'>
Under ptrace_scope=1, it's possible to have a tracee that is already
ptrace-attached, but is no longer a direct descendant.  For instance, a
forking daemon will be re-parented to init, losing its ancestry to the
tracer that launched it.

The tracer can continue using ptrace in that state, but it will be
denied other accesses that check PTRACE_MODE_ATTACH, like process_vm_rw
and various procfs files.  There's no reason to prevent such access for
a tracer that already has ptrace control anyway.

This patch adds a case to ptracer_exception_found to allow access for
any task in the same thread group as the current ptrace parent.

Signed-off-by: Josh Stone &lt;jistone@redhat.com&gt;
Cc: Kees Cook &lt;keescook@chromium.org&gt;
Cc: James Morris &lt;james.l.morris@oracle.com&gt;
Cc: "Serge E. Hallyn" &lt;serge@hallyn.com&gt;
Cc: linux-security-module@vger.kernel.org
Signed-off-by: Kees Cook &lt;keescook@chromium.org&gt;
Signed-off-by: James Morris &lt;james.l.morris@oracle.com&gt;
</content>
</entry>
<entry>
<title>Yama: fix double-spinlock and user access in atomic context</title>
<updated>2016-05-25T23:56:18Z</updated>
<author>
<name>Jann Horn</name>
<email>jann@thejh.net</email>
</author>
<published>2016-05-22T04:01:34Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=dca6b4149181baaa363b9a7ce7c550840bb3bc83'/>
<id>urn:sha1:dca6b4149181baaa363b9a7ce7c550840bb3bc83</id>
<content type='text'>
Commit 8a56038c2aef ("Yama: consolidate error reporting") causes lockups
when someone hits a Yama denial. Call chain:

process_vm_readv -&gt; process_vm_rw -&gt; process_vm_rw_core -&gt; mm_access
-&gt; ptrace_may_access
task_lock(...) is taken
__ptrace_may_access -&gt; security_ptrace_access_check
-&gt; yama_ptrace_access_check -&gt; report_access -&gt; kstrdup_quotable_cmdline
-&gt; get_cmdline -&gt; access_process_vm -&gt; get_task_mm
task_lock(...) is taken again

task_lock(p) just calls spin_lock(&amp;p-&gt;alloc_lock), so at this point,
spin_lock() is called on a lock that is already held by the current
process.

Also: Since the alloc_lock is a spinlock, sleeping inside
security_ptrace_access_check hooks is probably not allowed at all? So it's
not even possible to print the cmdline from in there because that might
involve paging in userspace memory.

It would be tempting to rewrite ptrace_may_access() to drop the alloc_lock
before calling the LSM, but even then, ptrace_may_access() itself might be
called from various contexts in which you're not allowed to sleep; for
example, as far as I understand, to be able to hold a reference to another
task, usually an RCU read lock will be taken (see e.g. kcmp() and
get_robust_list()), so that also prohibits sleeping. (And using e.g. FUSE,
a user can cause pagefault handling to take arbitrary amounts of time -
see https://bugs.chromium.org/p/project-zero/issues/detail?id=808.)

Therefore, AFAIK, in order to print the name of a process below
security_ptrace_access_check(), you'd have to either grab a reference to
the mm_struct and defer the access violation reporting or just use the
"comm" value that's stored in kernelspace and accessible without big
complications. (Or you could try to use some kind of atomic remote VM
access that fails if the memory isn't paged in, similar to
copy_from_user_inatomic(), and if necessary fall back to comm, but
that'd be kind of ugly because the comm/cmdline choice would look
pretty random to the user.)

Fix it by deferring reporting of the access violation until current
exits kernelspace the next time.

v2: Don't oops on PTRACE_TRACEME, call report_access under
task_lock(current). Also fix nonsensical comment. And don't use
GPF_ATOMIC for memory allocation with no locks held.
This patch is tested both for ptrace attach and ptrace traceme.

Fixes: 8a56038c2aef ("Yama: consolidate error reporting")
Signed-off-by: Jann Horn &lt;jann@thejh.net&gt;
Acked-by: Kees Cook &lt;keescook@chromium.org&gt;
Signed-off-by: James Morris &lt;james.l.morris@oracle.com&gt;
</content>
</entry>
</feed>
