<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/security/keys/keyctl.c, branch v3.0.86</title>
<subtitle>Linux kernel source tree</subtitle>
<id>https://git.amat.us/linux/atom/security/keys/keyctl.c?h=v3.0.86</id>
<link rel='self' href='https://git.amat.us/linux/atom/security/keys/keyctl.c?h=v3.0.86'/>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/'/>
<updated>2013-03-28T19:06:04Z</updated>
<entry>
<title>key: Fix resource leak</title>
<updated>2013-03-28T19:06:04Z</updated>
<author>
<name>Alan Cox</name>
<email>alan@linux.intel.com</email>
</author>
<published>2012-09-28T11:20:02Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=8fc39830ce6dc2a93f29872afce83b180a6d3deb'/>
<id>urn:sha1:8fc39830ce6dc2a93f29872afce83b180a6d3deb</id>
<content type='text'>
commit a84a921978b7d56e0e4b87ffaca6367429b4d8ff upstream.

On an error iov may still have been reallocated and need freeing

Signed-off-by: Alan Cox &lt;alan@linux.intel.com&gt;
Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>KEYS: Make request_key() and co. return an error for a negative key</title>
<updated>2011-03-17T00:59:49Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2011-03-11T17:57:33Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=4aab1e896a0a9d57420ff2867caa5a369123d8cb'/>
<id>urn:sha1:4aab1e896a0a9d57420ff2867caa5a369123d8cb</id>
<content type='text'>
Make request_key() and co. return an error for a negative or rejected key.  If
the key was simply negated, then return ENOKEY, otherwise return the error
with which it was rejected.

Without this patch, the following command returns a key number (with the latest
keyutils):

	[root@andromeda ~]# keyctl request2 user debug:foo rejected @s
	586569904

Trying to print the key merely gets you a permission denied error:

	[root@andromeda ~]# keyctl print 586569904
	keyctl_read_alloc: Permission denied

Doing another request_key() call does get you the error, as long as it hasn't
expired yet:

	[root@andromeda ~]# keyctl request user debug:foo
	request_key: Key was rejected by service

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Signed-off-by: James Morris &lt;jmorris@namei.org&gt;
</content>
</entry>
<entry>
<title>KEYS: Add an iovec version of KEYCTL_INSTANTIATE</title>
<updated>2011-03-08T00:17:22Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2011-03-07T15:06:20Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=ee009e4a0d4555ed522a631bae9896399674f064'/>
<id>urn:sha1:ee009e4a0d4555ed522a631bae9896399674f064</id>
<content type='text'>
Add a keyctl op (KEYCTL_INSTANTIATE_IOV) that is like KEYCTL_INSTANTIATE, but
takes an iovec array and concatenates the data in-kernel into one buffer.
Since the KEYCTL_INSTANTIATE copies the data anyway, this isn't too much of a
problem.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Signed-off-by: James Morris &lt;jmorris@namei.org&gt;
</content>
</entry>
<entry>
<title>KEYS: Add a new keyctl op to reject a key with a specified error code</title>
<updated>2011-03-08T00:17:18Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2011-03-07T15:06:09Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=fdd1b94581782a2ddf9124414e5b7a5f48ce2f9c'/>
<id>urn:sha1:fdd1b94581782a2ddf9124414e5b7a5f48ce2f9c</id>
<content type='text'>
Add a new keyctl op to reject a key with a specified error code.  This works
much the same as negating a key, and so keyctl_negate_key() is made a special
case of keyctl_reject_key().  The difference is that keyctl_negate_key()
selects ENOKEY as the error to be reported.

Typically the key would be rejected with EKEYEXPIRED, EKEYREVOKED or
EKEYREJECTED, but this is not mandatory.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Signed-off-by: James Morris &lt;jmorris@namei.org&gt;
</content>
</entry>
<entry>
<title>KEYS: Fix up comments in key management code</title>
<updated>2011-01-21T22:59:30Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2011-01-20T16:38:33Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=973c9f4f49ca96a53bcf6384c4c59ccd26c33906'/>
<id>urn:sha1:973c9f4f49ca96a53bcf6384c4c59ccd26c33906</id>
<content type='text'>
Fix up comments in the key management code.  No functional changes.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>KEYS: Do some style cleanup in the key management code.</title>
<updated>2011-01-21T22:59:29Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2011-01-20T16:38:27Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=a8b17ed019bd40d3bfa20439d9c36a99f9be9180'/>
<id>urn:sha1:a8b17ed019bd40d3bfa20439d9c36a99f9be9180</id>
<content type='text'>
Do a bit of a style clean up in the key management code.  No functional
changes.

Done using:

  perl -p -i -e 's!^/[*]*/\n!!' security/keys/*.c
  perl -p -i -e 's!} /[*] end [a-z0-9_]*[(][)] [*]/\n!}\n!' security/keys/*.c
  sed -i -s -e ": next" -e N -e 's/^\n[}]$/}/' -e t -e P -e 's/^.*\n//' -e "b next" security/keys/*.c

To remove /*****/ lines, remove comments on the closing brace of a
function to name the function and remove blank lines before the closing
brace of a function.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>KEYS: Fix bug in keyctl_session_to_parent() if parent has no session keyring</title>
<updated>2010-09-10T14:30:00Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2010-09-10T08:59:51Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=3d96406c7da1ed5811ea52a3b0905f4f0e295376'/>
<id>urn:sha1:3d96406c7da1ed5811ea52a3b0905f4f0e295376</id>
<content type='text'>
Fix a bug in keyctl_session_to_parent() whereby it tries to check the ownership
of the parent process's session keyring whether or not the parent has a session
keyring [CVE-2010-2960].

This results in the following oops:

  BUG: unable to handle kernel NULL pointer dereference at 00000000000000a0
  IP: [&lt;ffffffff811ae4dd&gt;] keyctl_session_to_parent+0x251/0x443
  ...
  Call Trace:
   [&lt;ffffffff811ae2f3&gt;] ? keyctl_session_to_parent+0x67/0x443
   [&lt;ffffffff8109d286&gt;] ? __do_fault+0x24b/0x3d0
   [&lt;ffffffff811af98c&gt;] sys_keyctl+0xb4/0xb8
   [&lt;ffffffff81001eab&gt;] system_call_fastpath+0x16/0x1b

if the parent process has no session keyring.

If the system is using pam_keyinit then it mostly protected against this as all
processes derived from a login will have inherited the session keyring created
by pam_keyinit during the log in procedure.

To test this, pam_keyinit calls need to be commented out in /etc/pam.d/.

Reported-by: Tavis Ormandy &lt;taviso@cmpxchg8b.com&gt;
Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Acked-by: Tavis Ormandy &lt;taviso@cmpxchg8b.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>KEYS: Fix RCU no-lock warning in keyctl_session_to_parent()</title>
<updated>2010-09-10T14:30:00Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2010-09-10T08:59:46Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=9d1ac65a9698513d00e5608d93fca0c53f536c14'/>
<id>urn:sha1:9d1ac65a9698513d00e5608d93fca0c53f536c14</id>
<content type='text'>
There's an protected access to the parent process's credentials in the middle
of keyctl_session_to_parent().  This results in the following RCU warning:

  ===================================================
  [ INFO: suspicious rcu_dereference_check() usage. ]
  ---------------------------------------------------
  security/keys/keyctl.c:1291 invoked rcu_dereference_check() without protection!

  other info that might help us debug this:

  rcu_scheduler_active = 1, debug_locks = 0
  1 lock held by keyctl-session-/2137:
   #0:  (tasklist_lock){.+.+..}, at: [&lt;ffffffff811ae2ec&gt;] keyctl_session_to_parent+0x60/0x236

  stack backtrace:
  Pid: 2137, comm: keyctl-session- Not tainted 2.6.36-rc2-cachefs+ #1
  Call Trace:
   [&lt;ffffffff8105606a&gt;] lockdep_rcu_dereference+0xaa/0xb3
   [&lt;ffffffff811ae379&gt;] keyctl_session_to_parent+0xed/0x236
   [&lt;ffffffff811af77e&gt;] sys_keyctl+0xb4/0xb6
   [&lt;ffffffff81001eab&gt;] system_call_fastpath+0x16/0x1b

The code should take the RCU read lock to make sure the parents credentials
don't go away, even though it's holding a spinlock and has IRQ disabled.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>KEYS: Use the variable 'key' in keyctl_describe_key()</title>
<updated>2010-08-02T05:34:56Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2010-06-28T13:05:04Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=94fd8405ea62bd2d4a40f3013e8e6935b6643235'/>
<id>urn:sha1:94fd8405ea62bd2d4a40f3013e8e6935b6643235</id>
<content type='text'>
keyctl_describe_key() turns the key reference it gets into a usable key pointer
and assigns that to a variable called 'key', which it then ignores in favour of
recomputing the key pointer each time it needs it.  Make it use the precomputed
pointer instead.

Without this patch, gcc 4.6 reports that the variable key is set but not used:

	building with gcc 4.6 I'm getting a warning message:
	 CC      security/keys/keyctl.o
	security/keys/keyctl.c: In function 'keyctl_describe_key':
	security/keys/keyctl.c:472:14: warning: variable 'key' set but not used

Reported-by: Justin P. Mattock &lt;justinmattock@gmail.com&gt;
Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Signed-off-by: James Morris &lt;jmorris@namei.org&gt;
</content>
</entry>
<entry>
<title>KEYS: Authorise keyctl_set_timeout() on a key if we have its authorisation key</title>
<updated>2010-08-02T05:34:27Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2010-06-11T16:31:05Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=9156235b3427d6f01c5c95022f72f381f07583f5'/>
<id>urn:sha1:9156235b3427d6f01c5c95022f72f381f07583f5</id>
<content type='text'>
Authorise a process to perform keyctl_set_timeout() on an uninstantiated key if
that process has the authorisation key for it.

This allows the instantiator to set the timeout on a key it is instantiating -
provided it does it before instantiating the key.

For instance, the test upcall script provided with the keyutils package could
be modified to set the expiry to an hour hence before instantiating the key:

	[/usr/share/keyutils/request-key-debug.sh]
	 if [ "$3" != "neg" ]
	 then
	+    keyctl timeout $1 3600
	     keyctl instantiate $1 "Debug $3" $4 || exit 1
	 else

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Signed-off-by: James Morris &lt;jmorris@namei.org&gt;
</content>
</entry>
</feed>
