<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/security/keys/process_keys.c, branch v3.13.2</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v3.13.2</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v3.13.2'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2013-09-25T16:17:01Z</updated>
<entry>
<title>KEYS: initialize root uid and session keyrings early</title>
<updated>2013-09-25T16:17:01Z</updated>
<author>
<name>Mimi Zohar</name>
<email>zohar@linux.vnet.ibm.com</email>
</author>
<published>2013-09-04T12:26:22Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=c124bde28bce41f9e46e32d03d134a81e116d38c'/>
<id>urn:sha1:c124bde28bce41f9e46e32d03d134a81e116d38c</id>
<content type='text'>
In order to create the integrity keyrings (eg. _evm, _ima), root's
uid and session keyrings need to be initialized early.

Signed-off-by: Mimi Zohar &lt;zohar@us.ibm.com&gt;
Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
</content>
</entry>
<entry>
<title>KEYS: Define a __key_get() wrapper to use rather than atomic_inc()</title>
<updated>2013-09-24T09:35:16Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2013-09-24T09:35:16Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=ccc3e6d9c9aea07a0b60b2b0bfc5b05a704b66d5'/>
<id>urn:sha1:ccc3e6d9c9aea07a0b60b2b0bfc5b05a704b66d5</id>
<content type='text'>
Define a __key_get() wrapper to use rather than atomic_inc() on the key usage
count as this makes it easier to hook in refcount error debugging.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
</content>
</entry>
<entry>
<title>KEYS: Introduce a search context structure</title>
<updated>2013-09-24T09:35:15Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2013-09-24T09:35:15Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=4bdf0bc300314141e5475e145acb8b5ad846f00d'/>
<id>urn:sha1:4bdf0bc300314141e5475e145acb8b5ad846f00d</id>
<content type='text'>
Search functions pass around a bunch of arguments, each of which gets copied
with each call.  Introduce a search context structure to hold these.

Whilst we're at it, create a search flag that indicates whether the search
should be directly to the description or whether it should iterate through all
keys looking for a non-description match.

This will be useful when keyrings use a generic data struct with generic
routines to manage their content as the search terms can just be passed
through to the iterator callback function.

Also, for future use, the data to be supplied to the match function is
separated from the description pointer in the search context.  This makes it
clear which is being supplied.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
</content>
</entry>
<entry>
<title>KEYS: Skip key state checks when checking for possession</title>
<updated>2013-09-24T09:35:13Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2013-09-24T09:35:13Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=61ea0c0ba904a55f55317d850c1072ff7835ac92'/>
<id>urn:sha1:61ea0c0ba904a55f55317d850c1072ff7835ac92</id>
<content type='text'>
Skip key state checks (invalidation, revocation and expiration) when checking
for possession.  Without this, keys that have been marked invalid, revoked
keys and expired keys are not given a possession attribute - which means the
possessor is not granted any possession permits and cannot do anything with
them unless they also have one a user, group or other permit.

This causes failures in the keyutils test suite's revocation and expiration
tests now that commit 96b5c8fea6c0861621051290d705ec2e971963f1 reduced the
initial permissions granted to a key.

The failures are due to accesses to revoked and expired keys being given
EACCES instead of EKEYREVOKED or EKEYEXPIRED.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
</content>
</entry>
<entry>
<title>keys: fix race with concurrent install_user_keyrings()</title>
<updated>2013-03-12T05:44:31Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2013-03-12T05:44:31Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=0da9dfdd2cd9889201bc6f6f43580c99165cd087'/>
<id>urn:sha1:0da9dfdd2cd9889201bc6f6f43580c99165cd087</id>
<content type='text'>
This fixes CVE-2013-1792.

There is a race in install_user_keyrings() that can cause a NULL pointer
dereference when called concurrently for the same user if the uid and
uid-session keyrings are not yet created.  It might be possible for an
unprivileged user to trigger this by calling keyctl() from userspace in
parallel immediately after logging in.

Assume that we have two threads both executing lookup_user_key(), both
looking for KEY_SPEC_USER_SESSION_KEYRING.

	THREAD A			THREAD B
	===============================	===============================
					==&gt;call install_user_keyrings();
	if (!cred-&gt;user-&gt;session_keyring)
	==&gt;call install_user_keyrings()
					...
					user-&gt;uid_keyring = uid_keyring;
	if (user-&gt;uid_keyring)
		return 0;
	&lt;==
	key = cred-&gt;user-&gt;session_keyring [== NULL]
					user-&gt;session_keyring = session_keyring;
	atomic_inc(&amp;key-&gt;usage); [oops]

At the point thread A dereferences cred-&gt;user-&gt;session_keyring, thread B
hasn't updated user-&gt;session_keyring yet, but thread A assumes it is
populated because install_user_keyrings() returned ok.

The race window is really small but can be exploited if, for example,
thread B is interrupted or preempted after initializing uid_keyring, but
before doing setting session_keyring.

This couldn't be reproduced on a stock kernel.  However, after placing
systemtap probe on 'user-&gt;session_keyring = session_keyring;' that
introduced some delay, the kernel could be crashed reliably.

Fix this by checking both pointers before deciding whether to return.
Alternatively, the test could be done away with entirely as it is checked
inside the mutex - but since the mutex is global, that may not be the best
way.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Reported-by: Mateusz Guzik &lt;mguzik@redhat.com&gt;
Cc: &lt;stable@kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: James Morris &lt;james.l.morris@oracle.com&gt;
</content>
</entry>
<entry>
<title>userns: Stop oopsing in key_change_session_keyring</title>
<updated>2013-03-04T03:35:38Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2013-03-03T03:14:03Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=ba0e3427b03c3d1550239779eca5c1c5a53a2152'/>
<id>urn:sha1:ba0e3427b03c3d1550239779eca5c1c5a53a2152</id>
<content type='text'>
Dave Jones &lt;davej@redhat.com&gt; writes:
&gt; Just hit this on Linus' current tree.
&gt;
&gt; [   89.621770] BUG: unable to handle kernel NULL pointer dereference at 00000000000000c8
&gt; [   89.623111] IP: [&lt;ffffffff810784b0&gt;] commit_creds+0x250/0x2f0
&gt; [   89.624062] PGD 122bfd067 PUD 122bfe067 PMD 0
&gt; [   89.624901] Oops: 0000 [#1] PREEMPT SMP
&gt; [   89.625678] Modules linked in: caif_socket caif netrom bridge hidp 8021q garp stp mrp rose llc2 af_rxrpc phonet af_key binfmt_misc bnep l2tp_ppp can_bcm l2tp_core pppoe pppox can_raw scsi_transport_iscsi ppp_generic slhc nfnetlink can ipt_ULOG ax25 decnet irda nfc rds x25 crc_ccitt appletalk atm ipx p8023 psnap p8022 llc lockd sunrpc ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ipv6 xt_conntrack nf_conntrack ip6table_filter ip6_tables btusb bluetooth snd_hda_codec_realtek snd_hda_intel snd_hda_codec snd_pcm vhost_net snd_page_alloc snd_timer tun macvtap usb_debug snd rfkill microcode macvlan edac_core pcspkr serio_raw kvm_amd soundcore kvm r8169 mii
&gt; [   89.637846] CPU 2
&gt; [   89.638175] Pid: 782, comm: trinity-main Not tainted 3.8.0+ #63 Gigabyte Technology Co., Ltd. GA-MA78GM-S2H/GA-MA78GM-S2H
&gt; [   89.639850] RIP: 0010:[&lt;ffffffff810784b0&gt;]  [&lt;ffffffff810784b0&gt;] commit_creds+0x250/0x2f0
&gt; [   89.641161] RSP: 0018:ffff880115657eb8  EFLAGS: 00010207
&gt; [   89.641984] RAX: 00000000000003e8 RBX: ffff88012688b000 RCX: 0000000000000000
&gt; [   89.643069] RDX: 0000000000000000 RSI: ffffffff81c32960 RDI: ffff880105839600
&gt; [   89.644167] RBP: ffff880115657ed8 R08: 0000000000000000 R09: 0000000000000000
&gt; [   89.645254] R10: 0000000000000001 R11: 0000000000000246 R12: ffff880105839600
&gt; [   89.646340] R13: ffff88011beea490 R14: ffff88011beea490 R15: 0000000000000000
&gt; [   89.647431] FS:  00007f3ac063b740(0000) GS:ffff88012b200000(0000) knlGS:0000000000000000
&gt; [   89.648660] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
&gt; [   89.649548] CR2: 00000000000000c8 CR3: 0000000122bfc000 CR4: 00000000000007e0
&gt; [   89.650635] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
&gt; [   89.651723] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
&gt; [   89.652812] Process trinity-main (pid: 782, threadinfo ffff880115656000, task ffff88011beea490)
&gt; [   89.654128] Stack:
&gt; [   89.654433]  0000000000000000 ffff8801058396a0 ffff880105839600 ffff88011beeaa78
&gt; [   89.655769]  ffff880115657ef8 ffffffff812c7d9b ffffffff82079be0 0000000000000000
&gt; [   89.657073]  ffff880115657f28 ffffffff8106c665 0000000000000002 ffff880115657f58
&gt; [   89.658399] Call Trace:
&gt; [   89.658822]  [&lt;ffffffff812c7d9b&gt;] key_change_session_keyring+0xfb/0x140
&gt; [   89.659845]  [&lt;ffffffff8106c665&gt;] task_work_run+0xa5/0xd0
&gt; [   89.660698]  [&lt;ffffffff81002911&gt;] do_notify_resume+0x71/0xb0
&gt; [   89.661581]  [&lt;ffffffff816c9a4a&gt;] int_signal+0x12/0x17
&gt; [   89.662385] Code: 24 90 00 00 00 48 8b b3 90 00 00 00 49 8b 4c 24 40 48 39 f2 75 08 e9 83 00 00 00 48 89 ca 48 81 fa 60 29 c3 81 0f 84 41 fe ff ff &lt;48&gt; 8b 8a c8 00 00 00 48 39 ce 75 e4 3b 82 d0 00 00 00 0f 84 4b
&gt; [   89.667778] RIP  [&lt;ffffffff810784b0&gt;] commit_creds+0x250/0x2f0
&gt; [   89.668733]  RSP &lt;ffff880115657eb8&gt;
&gt; [   89.669301] CR2: 00000000000000c8
&gt;
&gt; My fastest trinity induced oops yet!
&gt;
&gt;
&gt; Appears to be..
&gt;
&gt;                 if ((set_ns == subset_ns-&gt;parent)  &amp;&amp;
&gt;      850:       48 8b 8a c8 00 00 00    mov    0xc8(%rdx),%rcx
&gt;
&gt; from the inlined cred_cap_issubset

By historical accident we have been reading trying to set new-&gt;user_ns
from new-&gt;user_ns.  Which is totally silly as new-&gt;user_ns is NULL (as
is every other field in new except session_keyring at that point).

The intent is clearly to copy all of the fields from old to new so copy
old-&gt;user_ns into  into new-&gt;user_ns.

Cc: stable@vger.kernel.org
Reported-by: Dave Jones &lt;davej@redhat.com&gt;
Tested-by: Dave Jones &lt;davej@redhat.com&gt;
Acked-by: Serge Hallyn &lt;serge.hallyn@canonical.com&gt;
Signed-off-by: "Eric W. Biederman" &lt;ebiederm@xmission.com&gt;
</content>
</entry>
<entry>
<title>KEYS: Revert one application of "Fix unreachable code" patch</title>
<updated>2013-02-21T15:56:25Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2013-02-21T12:00:25Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=fe9453a1dcb5fb146f9653267e78f4a558066f6f'/>
<id>urn:sha1:fe9453a1dcb5fb146f9653267e78f4a558066f6f</id>
<content type='text'>
A patch to fix some unreachable code in search_my_process_keyrings() got
applied twice by two different routes upstream as commits e67eab39bee2
and b010520ab3d2 (both "fix unreachable code").

Unfortunately, the second application removed something it shouldn't
have and this wasn't detected by GIT.  This is due to the patch not
having sufficient lines of context to distinguish the two places of
application.

The effect of this is relatively minor: inside the kernel, the keyring
search routines may search multiple keyrings and then prioritise the
errors if no keys or negative keys are found in any of them.  With the
extra deletion, the presence of a negative key in the thread keyring
(causing ENOKEY) is incorrectly overridden by an error searching the
process keyring.

So revert the second application of the patch.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Cc: Jiri Kosina &lt;jkosina@suse.cz&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>keys: fix unreachable code</title>
<updated>2012-12-21T01:40:21Z</updated>
<author>
<name>Alan Cox</name>
<email>alan@linux.intel.com</email>
</author>
<published>2012-12-20T23:05:54Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=e67eab39bee26f509d38d00ca1a8f24b63f46a31'/>
<id>urn:sha1:e67eab39bee26f509d38d00ca1a8f24b63f46a31</id>
<content type='text'>
We set ret to NULL then test it. Remove the bogus test

Signed-off-by: Alan Cox &lt;alan@linux.intel.com&gt;
Signed-off-by: David Howells &lt;dhowells@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>Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security</title>
<updated>2012-12-16T23:40:50Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2012-12-16T23:40:50Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=2a74dbb9a86e8102dcd07d284135b4530a84826e'/>
<id>urn:sha1:2a74dbb9a86e8102dcd07d284135b4530a84826e</id>
<content type='text'>
Pull security subsystem updates from James Morris:
 "A quiet cycle for the security subsystem with just a few maintenance
  updates."

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security:
  Smack: create a sysfs mount point for smackfs
  Smack: use select not depends in Kconfig
  Yama: remove locking from delete path
  Yama: add RCU to drop read locking
  drivers/char/tpm: remove tasklet and cleanup
  KEYS: Use keyring_alloc() to create special keyrings
  KEYS: Reduce initial permissions on keys
  KEYS: Make the session and process keyrings per-thread
  seccomp: Make syscall skipping and nr changes more consistent
  key: Fix resource leak
  keys: Fix unreachable code
  KEYS: Add payload preparsing opportunity prior to key instantiate or update
</content>
</entry>
<entry>
<title>Merge branch 'master' into for-next</title>
<updated>2012-10-28T18:29:19Z</updated>
<author>
<name>Jiri Kosina</name>
<email>jkosina@suse.cz</email>
</author>
<published>2012-10-28T18:28:52Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=3bd7bf1f0fe14f591c089ae61bbfa9bd356f178a'/>
<id>urn:sha1:3bd7bf1f0fe14f591c089ae61bbfa9bd356f178a</id>
<content type='text'>
Sync up with Linus' tree to be able to apply Cesar's patch
against newer version of the code.

Signed-off-by: Jiri Kosina &lt;jkosina@suse.cz&gt;
</content>
</entry>
</feed>
