<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/security/keys, branch v2.6.33-rc6</title>
<subtitle>Linux kernel source tree</subtitle>
<id>https://git.amat.us/linux/atom/security/keys?h=v2.6.33-rc6</id>
<link rel='self' href='https://git.amat.us/linux/atom/security/keys?h=v2.6.33-rc6'/>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/'/>
<updated>2009-12-16T22:27:59Z</updated>
<entry>
<title>Keys: KEYCTL_SESSION_TO_PARENT needs TIF_NOTIFY_RESUME architecture support</title>
<updated>2009-12-16T22:27:59Z</updated>
<author>
<name>Geert Uytterhoeven</name>
<email>geert@linux-m68k.org</email>
</author>
<published>2009-12-13T19:21:34Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=a00ae4d21b2fa9379914f270ffffd8d3bec55430'/>
<id>urn:sha1:a00ae4d21b2fa9379914f270ffffd8d3bec55430</id>
<content type='text'>
As of commit ee18d64c1f632043a02e6f5ba5e045bb26a5465f ("KEYS: Add a keyctl to
install a process's session keyring on its parent [try #6]"), CONFIG_KEYS=y
fails to build on architectures that haven't implemented TIF_NOTIFY_RESUME yet:

security/keys/keyctl.c: In function 'keyctl_session_to_parent':
security/keys/keyctl.c:1312: error: 'TIF_NOTIFY_RESUME' undeclared (first use in this function)
security/keys/keyctl.c:1312: error: (Each undeclared identifier is reported only once
security/keys/keyctl.c:1312: error: for each function it appears in.)

Make KEYCTL_SESSION_TO_PARENT depend on TIF_NOTIFY_RESUME until
m68k, and xtensa have implemented it.

Signed-off-by: Geert Uytterhoeven &lt;geert@linux-m68k.org&gt;
Signed-off-by: James Morris &lt;jmorris@namei.org&gt;
Acked-by: Mike Frysinger &lt;vapier@gentoo.org&gt;
</content>
</entry>
<entry>
<title>keys: PTR_ERR return of wrong pointer in keyctl_get_security()</title>
<updated>2009-12-16T22:23:48Z</updated>
<author>
<name>Roel Kluin</name>
<email>roel.kluin@gmail.com</email>
</author>
<published>2009-12-15T23:05:12Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=fa1cc7b5a5c4171dfdcac855428295340ccf87ec'/>
<id>urn:sha1:fa1cc7b5a5c4171dfdcac855428295340ccf87ec</id>
<content type='text'>
Return the PTR_ERR of the correct pointer.

Signed-off-by: Roel Kluin &lt;roel.kluin@gmail.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Acked-by: David Howells &lt;dhowells@redhat.com&gt;
Signed-off-by: James Morris &lt;jmorris@namei.org&gt;
</content>
</entry>
<entry>
<title>sysctl: Drop &amp; in front of every proc_handler.</title>
<updated>2009-11-18T16:37:40Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2009-11-16T11:11:48Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=6d4561110a3e9fa742aeec6717248a491dfb1878'/>
<id>urn:sha1:6d4561110a3e9fa742aeec6717248a491dfb1878</id>
<content type='text'>
For consistency drop &amp; in front of every proc_handler.  Explicity
taking the address is unnecessary and it prevents optimizations
like stubbing the proc_handlers to NULL.

Cc: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
Cc: Ingo Molnar &lt;mingo@elte.hu&gt;
Cc: Joe Perches &lt;joe@perches.com&gt;
Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
</content>
</entry>
<entry>
<title>sysctl security/keys: Remove dead binary sysctl support</title>
<updated>2009-11-12T10:04:56Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2009-04-03T12:08:03Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=5cdb35557d022f8dc51b532b5cd1a8e9ed7bcdb7'/>
<id>urn:sha1:5cdb35557d022f8dc51b532b5cd1a8e9ed7bcdb7</id>
<content type='text'>
Now that sys_sysctl is a generic wrapper around /proc/sys  .ctl_name
and .strategy members of sysctl tables are dead code.  Remove them.

Cc: David Howells &lt;dhowells@redhat.com&gt;
Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
</content>
</entry>
<entry>
<title>KEYS: get_instantiation_keyring() should inc the keyring refcount in all cases</title>
<updated>2009-10-15T22:19:58Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2009-10-15T09:14:35Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=21279cfa107af07ef985539ac0de2152b9cba5f5'/>
<id>urn:sha1:21279cfa107af07ef985539ac0de2152b9cba5f5</id>
<content type='text'>
The destination keyring specified to request_key() and co. is made available to
the process that instantiates the key (the slave process started by
/sbin/request-key typically).  This is passed in the request_key_auth struct as
the dest_keyring member.

keyctl_instantiate_key and keyctl_negate_key() call get_instantiation_keyring()
to get the keyring to attach the newly constructed key to at the end of
instantiation.  This may be given a specific keyring into which a link will be
made later, or it may be asked to find the keyring passed to request_key().  In
the former case, it returns a keyring with the refcount incremented by
lookup_user_key(); in the latter case, it returns the keyring from the
request_key_auth struct - and does _not_ increment the refcount.

The latter case will eventually result in an oops when the keyring prematurely
runs out of references and gets destroyed.  The effect may take some time to
show up as the key is destroyed lazily.

To fix this, the keyring returned by get_instantiation_keyring() must always
have its refcount incremented, no matter where it comes from.

This can be tested by setting /etc/request-key.conf to:

#OP	TYPE	DESCRIPTION	CALLOUT INFO	PROGRAM ARG1 ARG2 ARG3 ...
#======	=======	===============	===============	===============================
create  *	test:*		*		|/bin/false %u %g %d %{user:_display}
negate	*	*		*		/bin/keyctl negate %k 10 @u

and then doing:

	keyctl add user _display aaaaaaaa @u
        while keyctl request2 user test:x test:x @u &amp;&amp;
        keyctl list @u;
        do
                keyctl request2 user test:x test:x @u;
                sleep 31;
                keyctl list @u;
        done

which will oops eventually.  Changing the negate line to have @u rather than
%S at the end is important as that forces the latter case by passing a special
keyring ID rather than an actual keyring ID.

Reported-by: Alexander Zangerl &lt;az@bond.edu.au&gt;
Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Tested-by: Alexander Zangerl &lt;az@bond.edu.au&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>KEYS: Have the garbage collector set its timer for live expired keys</title>
<updated>2009-09-23T18:03:47Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2009-09-16T14:54:14Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=606531c316d30e9639473a6da09ee917125ab467'/>
<id>urn:sha1:606531c316d30e9639473a6da09ee917125ab467</id>
<content type='text'>
The key garbage collector sets a timer to start a new collection cycle at the
point the earliest key to expire should be considered garbage.  However, it
currently only does this if the key it is considering hasn't yet expired.

If the key being considering has expired, but hasn't yet reached the collection
time then it is ignored, and won't be collected until some other key provokes a
round of collection.

Make the garbage collector set the timer for the earliest key that hasn't yet
passed its collection time, rather than the earliest key that hasn't yet
expired.

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 garbage collector</title>
<updated>2009-09-14T23:11:02Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2009-09-14T16:26:13Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=c08ef808ef24df32e25fbd949fe5310172f3c408'/>
<id>urn:sha1:c08ef808ef24df32e25fbd949fe5310172f3c408</id>
<content type='text'>
Fix a number of problems with the new key garbage collector:

 (1) A rogue semicolon in keyring_gc() was causing the initial count of dead
     keys to be miscalculated.

 (2) A missing return in keyring_gc() meant that under certain circumstances,
     the keyring semaphore would be unlocked twice.

 (3) The key serial tree iterator (key_garbage_collector()) part of the garbage
     collector has been modified to:

     (a) Complete each scan of the keyrings before setting the new timer.

     (b) Only set the new timer for keys that have yet to expire.  This means
         that the new timer is now calculated correctly, and the gc doesn't
         get into a loop continually scanning for keys that have expired, and
         preventing other things from happening, like RCU cleaning up the old
         keyring contents.

     (c) Perform an extra scan if any keys were garbage collected in this one
     	 as a key might become garbage during a scan, and (b) could mean we
     	 don't set the timer again.

 (4) Made key_schedule_gc() take the time at which to do a collection run,
     rather than the time at which the key expires.  This means the collection
     of dead keys (key type unregistered) can happen immediately.

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: Unlock tasklist when exiting early from keyctl_session_to_parent</title>
<updated>2009-09-14T23:10:59Z</updated>
<author>
<name>Marc Dionne</name>
<email>marc.c.dionne@gmail.com</email>
</author>
<published>2009-09-14T11:46:23Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=5c84342a3e147a23752276650340801c237d0e56'/>
<id>urn:sha1:5c84342a3e147a23752276650340801c237d0e56</id>
<content type='text'>
When we exit early from keyctl_session_to_parent because of permissions or
because the session keyring is the same as the parent, we need to unlock the
tasklist.

The missing unlock causes the system to hang completely when using
keyctl(KEYCTL_SESSION_TO_PARENT) with a keyring shared with the parent.

Signed-off-by: Marc Dionne &lt;marc.c.dionne@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: Add a keyctl to install a process's session keyring on its parent [try #6]</title>
<updated>2009-09-02T11:29:22Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2009-09-02T08:14:21Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=ee18d64c1f632043a02e6f5ba5e045bb26a5465f'/>
<id>urn:sha1:ee18d64c1f632043a02e6f5ba5e045bb26a5465f</id>
<content type='text'>
Add a keyctl to install a process's session keyring onto its parent.  This
replaces the parent's session keyring.  Because the COW credential code does
not permit one process to change another process's credentials directly, the
change is deferred until userspace next starts executing again.  Normally this
will be after a wait*() syscall.

To support this, three new security hooks have been provided:
cred_alloc_blank() to allocate unset security creds, cred_transfer() to fill in
the blank security creds and key_session_to_parent() - which asks the LSM if
the process may replace its parent's session keyring.

The replacement may only happen if the process has the same ownership details
as its parent, and the process has LINK permission on the session keyring, and
the session keyring is owned by the process, and the LSM permits it.

Note that this requires alteration to each architecture's notify_resume path.
This has been done for all arches barring blackfin, m68k* and xtensa, all of
which need assembly alteration to support TIF_NOTIFY_RESUME.  This allows the
replacement to be performed at the point the parent process resumes userspace
execution.

This allows the userspace AFS pioctl emulation to fully emulate newpag() and
the VIOCSETTOK and VIOCSETTOK2 pioctls, all of which require the ability to
alter the parent process's PAG membership.  However, since kAFS doesn't use
PAGs per se, but rather dumps the keys into the session keyring, the session
keyring of the parent must be replaced if, for example, VIOCSETTOK is passed
the newpag flag.

This can be tested with the following program:

	#include &lt;stdio.h&gt;
	#include &lt;stdlib.h&gt;
	#include &lt;keyutils.h&gt;

	#define KEYCTL_SESSION_TO_PARENT	18

	#define OSERROR(X, S) do { if ((long)(X) == -1) { perror(S); exit(1); } } while(0)

	int main(int argc, char **argv)
	{
		key_serial_t keyring, key;
		long ret;

		keyring = keyctl_join_session_keyring(argv[1]);
		OSERROR(keyring, "keyctl_join_session_keyring");

		key = add_key("user", "a", "b", 1, keyring);
		OSERROR(key, "add_key");

		ret = keyctl(KEYCTL_SESSION_TO_PARENT);
		OSERROR(ret, "KEYCTL_SESSION_TO_PARENT");

		return 0;
	}

Compiled and linked with -lkeyutils, you should see something like:

	[dhowells@andromeda ~]$ keyctl show
	Session Keyring
	       -3 --alswrv   4043  4043  keyring: _ses
	355907932 --alswrv   4043    -1   \_ keyring: _uid.4043
	[dhowells@andromeda ~]$ /tmp/newpag
	[dhowells@andromeda ~]$ keyctl show
	Session Keyring
	       -3 --alswrv   4043  4043  keyring: _ses
	1055658746 --alswrv   4043  4043   \_ user: a
	[dhowells@andromeda ~]$ /tmp/newpag hello
	[dhowells@andromeda ~]$ keyctl show
	Session Keyring
	       -3 --alswrv   4043  4043  keyring: hello
	340417692 --alswrv   4043  4043   \_ user: a

Where the test program creates a new session keyring, sticks a user key named
'a' into it and then installs it on its parent.

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: Do some whitespace cleanups [try #6]</title>
<updated>2009-09-02T11:29:16Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2009-09-02T08:14:11Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=7b1b9164598286fe93927ff41eed2a2609fd9056'/>
<id>urn:sha1:7b1b9164598286fe93927ff41eed2a2609fd9056</id>
<content type='text'>
Do some whitespace cleanups in the key management code.

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