lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1417317854-11799-1-git-send-email-sasha.levin@oracle.com>
Date:	Sat, 29 Nov 2014 22:24:14 -0500
From:	Sasha Levin <sasha.levin@...cle.com>
To:	dhowells@...hat.com, james.l.morris@...cle.com, serge@...lyn.com
Cc:	keyrings@...ux-nfs.org, linux-security-module@...r.kernel.org,
	linux-kernel@...r.kernel.org, Sasha Levin <sasha.levin@...cle.com>
Subject: [PATCH] KEYS: Destroy by key type before removing the rest of the key

We should make sure that the key type does it's destruction dance first
before we start tearing down the key structure itself so that we won't
have a live key in a semi-coherent state.

This would prevent a race between key destruction and lookup in the
keyring case, resulting in a use-after-free.

Signed-off-by: Sasha Levin <sasha.levin@...cle.com>
---
 security/keys/gc.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/security/keys/gc.c b/security/keys/gc.c
index 9609a7f..8f3b518 100644
--- a/security/keys/gc.c
+++ b/security/keys/gc.c
@@ -134,6 +134,9 @@ static noinline void key_gc_unused_keys(struct list_head *keys)
 		kdebug("- %u", key->serial);
 		key_check(key);
 
+		if (key->type->destroy)
+			key->type->destroy(key);
+
 		security_key_free(key);
 
 		/* deal with the user's key tracking and quota */
@@ -151,9 +154,6 @@ static noinline void key_gc_unused_keys(struct list_head *keys)
 		key_user_put(key->user);
 
 		/* now throw away the key memory */
-		if (key->type->destroy)
-			key->type->destroy(key);
-
 		kfree(key->description);
 
 #ifdef KEY_DEBUGGING
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ