<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/security/keys/key.c, branch v3.14.11</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v3.14.11</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v3.14.11'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2013-12-02T11:24:18+00:00</updated>
<entry>
<title>KEYS: Pre-clear struct key on allocation</title>
<updated>2013-12-02T11:24:18+00:00</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2013-12-02T11:24:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=2480f57fb3023eb047c5f2d6dfefef41ab9b893c'/>
<id>urn:sha1:2480f57fb3023eb047c5f2d6dfefef41ab9b893c</id>
<content type='text'>
The second word of key-&gt;payload does not get initialised in key_alloc(), but
the big_key type is relying on it having been cleared.  The problem comes when
big_key fails to instantiate a large key and doesn't then set the payload.  The
big_key_destroy() op is called from the garbage collector and this assumes that
the dentry pointer stored in the second word will be NULL if instantiation did
not complete.

Therefore just pre-clear the entire struct key on allocation rather than trying
to be clever and only initialising to 0 only those bits that aren't otherwise
initialised.

The lack of initialisation can lead to a bug report like the following if
big_key failed to initialise its file:

	general protection fault: 0000 [#1] SMP
	Modules linked in: ...
	CPU: 0 PID: 51 Comm: kworker/0:1 Not tainted 3.10.0-53.el7.x86_64 #1
	Hardware name: Dell Inc. PowerEdge 1955/0HC513, BIOS 1.4.4 12/09/2008
	Workqueue: events key_garbage_collector
	task: ffff8801294f5680 ti: ffff8801296e2000 task.ti: ffff8801296e2000
	RIP: 0010:[&lt;ffffffff811b4a51&gt;] dput+0x21/0x2d0
	...
	Call Trace:
	 [&lt;ffffffff811a7b06&gt;] path_put+0x16/0x30
	 [&lt;ffffffff81235604&gt;] big_key_destroy+0x44/0x60
	 [&lt;ffffffff8122dc4b&gt;] key_gc_unused_keys.constprop.2+0x5b/0xe0
	 [&lt;ffffffff8122df2f&gt;] key_garbage_collector+0x1df/0x3c0
	 [&lt;ffffffff8107759b&gt;] process_one_work+0x17b/0x460
	 [&lt;ffffffff8107834b&gt;] worker_thread+0x11b/0x400
	 [&lt;ffffffff81078230&gt;] ? rescuer_thread+0x3e0/0x3e0
	 [&lt;ffffffff8107eb00&gt;] kthread+0xc0/0xd0
	 [&lt;ffffffff8107ea40&gt;] ? kthread_create_on_node+0x110/0x110
	 [&lt;ffffffff815c4bec&gt;] ret_from_fork+0x7c/0xb0
	 [&lt;ffffffff8107ea40&gt;] ? kthread_create_on_node+0x110/0x110

Reported-by: Patrik Kis &lt;pkis@redhat.com&gt;
Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Reviewed-by: Stephen Gallagher &lt;sgallagh@redhat.com&gt;
</content>
</entry>
<entry>
<title>KEYS: Fix a race between negating a key and reading the error set</title>
<updated>2013-10-30T11:15:24+00:00</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2013-10-30T11:15:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=74792b0001ee85b845dc82c1a716c6052c2db9de'/>
<id>urn:sha1:74792b0001ee85b845dc82c1a716c6052c2db9de</id>
<content type='text'>
key_reject_and_link() marking a key as negative and setting the error with
which it was negated races with keyring searches and other things that read
that error.

The fix is to switch the order in which the assignments are done in
key_reject_and_link() and to use memory barriers.

Kudos to Dave Wysochanski &lt;dwysocha@redhat.com&gt; and Scott Mayhew
&lt;smayhew@redhat.com&gt; for tracking this down.

This may be the cause of:

BUG: unable to handle kernel NULL pointer dereference at 0000000000000070
IP: [&lt;ffffffff81219011&gt;] wait_for_key_construction+0x31/0x80
PGD c6b2c3067 PUD c59879067 PMD 0
Oops: 0000 [#1] SMP
last sysfs file: /sys/devices/system/cpu/cpu3/cache/index2/shared_cpu_map
CPU 0
Modules linked in: ...

Pid: 13359, comm: amqzxma0 Not tainted 2.6.32-358.20.1.el6.x86_64 #1 IBM System x3650 M3 -[7945PSJ]-/00J6159
RIP: 0010:[&lt;ffffffff81219011&gt;] wait_for_key_construction+0x31/0x80
RSP: 0018:ffff880c6ab33758  EFLAGS: 00010246
RAX: ffffffff81219080 RBX: 0000000000000000 RCX: 0000000000000002
RDX: ffffffff81219060 RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffff880c6ab33768 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000000 R12: ffff880adfcbce40
R13: ffffffffa03afb84 R14: ffff880adfcbce40 R15: ffff880adfcbce43
FS:  00007f29b8042700(0000) GS:ffff880028200000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000070 CR3: 0000000c613dc000 CR4: 00000000000007f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Process amqzxma0 (pid: 13359, threadinfo ffff880c6ab32000, task ffff880c610deae0)
Stack:
 ffff880adfcbce40 0000000000000000 ffff880c6ab337b8 ffffffff81219695
&lt;d&gt; 0000000000000000 ffff880a000000d0 ffff880c6ab337a8 000000000000000f
&lt;d&gt; ffffffffa03afb93 000000000000000f ffff88186c7882c0 0000000000000014
Call Trace:
 [&lt;ffffffff81219695&gt;] request_key+0x65/0xa0
 [&lt;ffffffffa03a0885&gt;] nfs_idmap_request_key+0xc5/0x170 [nfs]
 [&lt;ffffffffa03a0eb4&gt;] nfs_idmap_lookup_id+0x34/0x80 [nfs]
 [&lt;ffffffffa03a1255&gt;] nfs_map_group_to_gid+0x75/0xa0 [nfs]
 [&lt;ffffffffa039a9ad&gt;] decode_getfattr_attrs+0xbdd/0xfb0 [nfs]
 [&lt;ffffffff81057310&gt;] ? __dequeue_entity+0x30/0x50
 [&lt;ffffffff8100988e&gt;] ? __switch_to+0x26e/0x320
 [&lt;ffffffffa039ae03&gt;] decode_getfattr+0x83/0xe0 [nfs]
 [&lt;ffffffffa039b610&gt;] ? nfs4_xdr_dec_getattr+0x0/0xa0 [nfs]
 [&lt;ffffffffa039b69f&gt;] nfs4_xdr_dec_getattr+0x8f/0xa0 [nfs]
 [&lt;ffffffffa02dada4&gt;] rpcauth_unwrap_resp+0x84/0xb0 [sunrpc]
 [&lt;ffffffffa039b610&gt;] ? nfs4_xdr_dec_getattr+0x0/0xa0 [nfs]
 [&lt;ffffffffa02cf923&gt;] call_decode+0x1b3/0x800 [sunrpc]
 [&lt;ffffffff81096de0&gt;] ? wake_bit_function+0x0/0x50
 [&lt;ffffffffa02cf770&gt;] ? call_decode+0x0/0x800 [sunrpc]
 [&lt;ffffffffa02d99a7&gt;] __rpc_execute+0x77/0x350 [sunrpc]
 [&lt;ffffffff81096c67&gt;] ? bit_waitqueue+0x17/0xd0
 [&lt;ffffffffa02d9ce1&gt;] rpc_execute+0x61/0xa0 [sunrpc]
 [&lt;ffffffffa02d03a5&gt;] rpc_run_task+0x75/0x90 [sunrpc]
 [&lt;ffffffffa02d04c2&gt;] rpc_call_sync+0x42/0x70 [sunrpc]
 [&lt;ffffffffa038ff80&gt;] _nfs4_call_sync+0x30/0x40 [nfs]
 [&lt;ffffffffa038836c&gt;] _nfs4_proc_getattr+0xac/0xc0 [nfs]
 [&lt;ffffffff810aac87&gt;] ? futex_wait+0x227/0x380
 [&lt;ffffffffa038b856&gt;] nfs4_proc_getattr+0x56/0x80 [nfs]
 [&lt;ffffffffa0371403&gt;] __nfs_revalidate_inode+0xe3/0x220 [nfs]
 [&lt;ffffffffa037158e&gt;] nfs_revalidate_mapping+0x4e/0x170 [nfs]
 [&lt;ffffffffa036f147&gt;] nfs_file_read+0x77/0x130 [nfs]
 [&lt;ffffffff811811aa&gt;] do_sync_read+0xfa/0x140
 [&lt;ffffffff81096da0&gt;] ? autoremove_wake_function+0x0/0x40
 [&lt;ffffffff8100bb8e&gt;] ? apic_timer_interrupt+0xe/0x20
 [&lt;ffffffff8100b9ce&gt;] ? common_interrupt+0xe/0x13
 [&lt;ffffffff81228ffb&gt;] ? selinux_file_permission+0xfb/0x150
 [&lt;ffffffff8121bed6&gt;] ? security_file_permission+0x16/0x20
 [&lt;ffffffff81181a95&gt;] vfs_read+0xb5/0x1a0
 [&lt;ffffffff81181bd1&gt;] sys_read+0x51/0x90
 [&lt;ffffffff810dc685&gt;] ? __audit_syscall_exit+0x265/0x290
 [&lt;ffffffff8100b072&gt;] system_call_fastpath+0x16/0x1b

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
cc: Dave Wysochanski &lt;dwysocha@redhat.com&gt;
cc: Scott Mayhew &lt;smayhew@redhat.com&gt;
</content>
</entry>
<entry>
<title>KEYS: Add a 'trusted' flag and a 'trusted only' flag</title>
<updated>2013-09-25T16:17:01+00:00</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2013-08-30T15:07:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=008643b86c5f33c115c84ccdda1725cac3ad50ad'/>
<id>urn:sha1:008643b86c5f33c115c84ccdda1725cac3ad50ad</id>
<content type='text'>
Add KEY_FLAG_TRUSTED to indicate that a key either comes from a trusted source
or had a cryptographic signature chain that led back to a trusted key the
kernel already possessed.

Add KEY_FLAGS_TRUSTED_ONLY to indicate that a keyring will only accept links to
keys marked with KEY_FLAGS_TRUSTED.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Reviewed-by: Kees Cook &lt;keescook@chromium.org&gt;
</content>
</entry>
<entry>
<title>KEYS: Expand the capacity of a keyring</title>
<updated>2013-09-24T09:35:18+00:00</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2013-09-24T09:35:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=b2a4df200d570b2c33a57e1ebfa5896e4bc81b69'/>
<id>urn:sha1:b2a4df200d570b2c33a57e1ebfa5896e4bc81b69</id>
<content type='text'>
Expand the capacity of a keyring to be able to hold a lot more keys by using
the previously added associative array implementation.  Currently the maximum
capacity is:

	(PAGE_SIZE - sizeof(header)) / sizeof(struct key *)

which, on a 64-bit system, is a little more 500.  However, since this is being
used for the NFS uid mapper, we need more than that.  The new implementation
gives us effectively unlimited capacity.

With some alterations, the keyutils testsuite runs successfully to completion
after this patch is applied.  The alterations are because (a) keyrings that
are simply added to no longer appear ordered and (b) some of the errors have
changed a bit.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;

</content>
</entry>
<entry>
<title>KEYS: Drop the permissions argument from __keyring_search_one()</title>
<updated>2013-09-24T09:35:17+00:00</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2013-09-24T09:35:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=e57e8669f2ab8350d30f771dd2fdd5377f183db2'/>
<id>urn:sha1:e57e8669f2ab8350d30f771dd2fdd5377f183db2</id>
<content type='text'>
Drop the permissions argument from __keyring_search_one() as the only caller
passes 0 here - which causes all checks to be skipped.

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:16+00:00</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2013-09-24T09:35:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/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: Consolidate the concept of an 'index key' for key access</title>
<updated>2013-09-24T09:35:15+00:00</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2013-09-24T09:35:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=16feef4340172b7dbb9cba60850e78fa6388adf1'/>
<id>urn:sha1:16feef4340172b7dbb9cba60850e78fa6388adf1</id>
<content type='text'>
Consolidate the concept of an 'index key' for accessing keys.  The index key
is the search term needed to find a key directly - basically the key type and
the key description.  We can add to that the description length.

This will be useful when turning a keyring into an associative array rather
than just a pointer block.

Signed-off-by: David Howells &lt;dhowells@redhat.com&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:50+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2012-12-16T23:40:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/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 'modules-next' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux</title>
<updated>2012-10-14T20:39:34+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2012-10-14T20:39:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=d25282d1c9b9bc4cda7f9d3c0205108e99aa7a9d'/>
<id>urn:sha1:d25282d1c9b9bc4cda7f9d3c0205108e99aa7a9d</id>
<content type='text'>
Pull module signing support from Rusty Russell:
 "module signing is the highlight, but it's an all-over David Howells frenzy..."

Hmm "Magrathea: Glacier signing key". Somebody has been reading too much HHGTTG.

* 'modules-next' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux: (37 commits)
  X.509: Fix indefinite length element skip error handling
  X.509: Convert some printk calls to pr_devel
  asymmetric keys: fix printk format warning
  MODSIGN: Fix 32-bit overflow in X.509 certificate validity date checking
  MODSIGN: Make mrproper should remove generated files.
  MODSIGN: Use utf8 strings in signer's name in autogenerated X.509 certs
  MODSIGN: Use the same digest for the autogen key sig as for the module sig
  MODSIGN: Sign modules during the build process
  MODSIGN: Provide a script for generating a key ID from an X.509 cert
  MODSIGN: Implement module signature checking
  MODSIGN: Provide module signing public keys to the kernel
  MODSIGN: Automatically generate module signing keys if missing
  MODSIGN: Provide Kconfig options
  MODSIGN: Provide gitignore and make clean rules for extra files
  MODSIGN: Add FIPS policy
  module: signature checking hook
  X.509: Add a crypto key parser for binary (DER) X.509 certificates
  MPILIB: Provide a function to read raw data into an MPI
  X.509: Add an ASN.1 decoder
  X.509: Add simple ASN.1 grammar compiler
  ...
</content>
</entry>
<entry>
<title>KEYS: Add payload preparsing opportunity prior to key instantiate or update</title>
<updated>2012-10-08T03:19:48+00:00</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2012-09-13T12:06:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=cf7f601c067994f371ba77721d1e45fce61a4569'/>
<id>urn:sha1:cf7f601c067994f371ba77721d1e45fce61a4569</id>
<content type='text'>
Give the key type the opportunity to preparse the payload prior to the
instantiation and update routines being called.  This is done with the
provision of two new key type operations:

	int (*preparse)(struct key_preparsed_payload *prep);
	void (*free_preparse)(struct key_preparsed_payload *prep);

If the first operation is present, then it is called before key creation (in
the add/update case) or before the key semaphore is taken (in the update and
instantiate cases).  The second operation is called to clean up if the first
was called.

preparse() is given the opportunity to fill in the following structure:

	struct key_preparsed_payload {
		char		*description;
		void		*type_data[2];
		void		*payload;
		const void	*data;
		size_t		datalen;
		size_t		quotalen;
	};

Before the preparser is called, the first three fields will have been cleared,
the payload pointer and size will be stored in data and datalen and the default
quota size from the key_type struct will be stored into quotalen.

The preparser may parse the payload in any way it likes and may store data in
the type_data[] and payload fields for use by the instantiate() and update()
ops.

The preparser may also propose a description for the key by attaching it as a
string to the description field.  This can be used by passing a NULL or ""
description to the add_key() system call or the key_create_or_update()
function.  This cannot work with request_key() as that required the description
to tell the upcall about the key to be created.

This, for example permits keys that store PGP public keys to generate their own
name from the user ID and public key fingerprint in the key.

The instantiate() and update() operations are then modified to look like this:

	int (*instantiate)(struct key *key, struct key_preparsed_payload *prep);
	int (*update)(struct key *key, struct key_preparsed_payload *prep);

and the new payload data is passed in *prep, whether or not it was preparsed.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
</feed>
