rpms/kernel/F-11 keys-Handle-there-being-no-fallback-destination-key.patch, NONE, 1.1 kernel.spec, 1.1623, 1.1624

Kyle McMartin kyle at fedoraproject.org
Mon May 25 20:16:22 UTC 2009


Author: kyle

Update of /cvs/pkgs/rpms/kernel/F-11
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv29330

Modified Files:
	kernel.spec 
Added Files:
	keys-Handle-there-being-no-fallback-destination-key.patch 
Log Message:
* Mon May 25 2009 Kyle McMartin <kyle at redhat.com> 2.6.29.4-162
- keys-Handle-there-being-no-fallback-destination-key.patch:
  fix oops at boot with autofs/krb/cifs rhbz#501588.


keys-Handle-there-being-no-fallback-destination-key.patch:

--- NEW FILE keys-Handle-there-being-no-fallback-destination-key.patch ---
>From 2e60675798c3fee2c5a636c7a1f9b4c8ed050e97 Mon Sep 17 00:00:00 2001
From: David Howells <dhowells at redhat.com>
Date: Thu, 9 Apr 2009 17:14:05 +0100
Subject: [PATCH] keys: Handle there being no fallback destination keyring for request_key()

When request_key() is called, without there being any standard process
keyrings on which to fall back if a destination keyring is not specified, an
oops is liable to occur when construct_alloc_key() calls down_write() on
dest_keyring's semaphore.

Due to function inlining this may be seen as an oops in down_write() as called
from request_key_and_link().

This situation crops up during boot, where request_key() is called from within
the kernel (such as in CIFS mounts) where nobody is actually logged in, and so
PAM has not had a chance to create a session keyring and user keyrings to act
as the fallback.

To fix this, make construct_alloc_key() not attempt to cache a key if there is
no fallback key if no destination keyring is given specifically.

Signed-off-by: David Howells <dhowells at redhat.com>
Tested-by: Jeff Layton <jlayton at redhat.com>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
---
 security/keys/request_key.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/security/keys/request_key.c b/security/keys/request_key.c
index 0e04f72..ab70cab 100644
--- a/security/keys/request_key.c
+++ b/security/keys/request_key.c
@@ -311,7 +311,8 @@ static int construct_alloc_key(struct key_type *type,
 
 	set_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags);
 
-	down_write(&dest_keyring->sem);
+	if (dest_keyring)
+		down_write(&dest_keyring->sem);
 
 	/* attach the key to the destination keyring under lock, but we do need
 	 * to do another check just in case someone beat us to it whilst we
@@ -322,10 +323,12 @@ static int construct_alloc_key(struct key_type *type,
 	if (!IS_ERR(key_ref))
 		goto key_already_present;
 
-	__key_link(dest_keyring, key);
+	if (dest_keyring)
+		__key_link(dest_keyring, key);
 
 	mutex_unlock(&key_construction_mutex);
-	up_write(&dest_keyring->sem);
+	if (dest_keyring)
+		up_write(&dest_keyring->sem);
 	mutex_unlock(&user->cons_lock);
 	*_key = key;
 	kleave(" = 0 [%d]", key_serial(key));
-- 
1.6.2.2



Index: kernel.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/F-11/kernel.spec,v
retrieving revision 1.1623
retrieving revision 1.1624
diff -u -p -r1.1623 -r1.1624
--- kernel.spec	25 May 2009 20:11:10 -0000	1.1623
+++ kernel.spec	25 May 2009 20:15:52 -0000	1.1624
@@ -608,6 +608,8 @@ Patch41: linux-2.6-sysrq-c.patch
 #Patch102: linux-2.6-e820-acpi3-bios-workaround.patch
 #Patch103: linux-2.6-e820-guard-against-pre-acpi3.patch
 
+Patch120: keys-Handle-there-being-no-fallback-destination-key.patch
+
 Patch141: linux-2.6-ps3-storage-alias.patch
 Patch143: linux-2.6-g5-therm-shutdown.patch
 Patch144: linux-2.6-vio-modalias.patch
@@ -1173,6 +1175,8 @@ ApplyPatch linux-2.6-iommu-fixes.patch
 # enable sysrq-c on all kernels, not only kexec
 ApplyPatch linux-2.6-sysrq-c.patch
 
+ApplyPatch keys-Handle-there-being-no-fallback-destination-key.patch
+
 # Architecture patches
 # x86(-64)
 #ApplyPatch linux-2.6-e820-save-restore-edi-ebp.patch
@@ -2006,6 +2010,10 @@ fi
 # and build.
 
 %changelog
+* Mon May 25 2009 Kyle McMartin <kyle at redhat.com> 2.6.29.4-162
+- keys-Handle-there-being-no-fallback-destination-key.patch:
+  fix oops at boot with autofs/krb/cifs rhbz#501588.
+
 * Mon May 25 2009 Kyle McMartin <kyle at redhat.com> 2.6.29.4-161
 - Linux 2.6.29.4
 - dropped patches:




More information about the scm-commits mailing list