Linux-Security-Module Archive on lore.kernel.org
 help / Atom feed
* [PATCH] security: keys: add NULL checking for key->type->instantiate
@ 2019-01-25  7:16 Geliang Tang
  2019-02-06 22:26 ` David Howells
  0 siblings, 1 reply; 2+ messages in thread
From: Geliang Tang @ 2019-01-25  7:16 UTC (permalink / raw)
  To: David Howells, James Morris, Serge E. Hallyn
  Cc: Geliang Tang, keyrings, linux-security-module, linux-kernel

key->type->instantiate can be NULL, add NULL checking to prevent
NULL pointer dereference in __key_instantiate_and_link().

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 security/keys/key.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/security/keys/key.c b/security/keys/key.c
index 44a80d6741a1..ae3cc11be0d2 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -438,7 +438,8 @@ static int __key_instantiate_and_link(struct key *key,
 	/* can't instantiate twice */
 	if (key->state == KEY_IS_UNINSTANTIATED) {
 		/* instantiate the key */
-		ret = key->type->instantiate(key, prep);
+		if (key->type->instantiate)
+			ret = key->type->instantiate(key, prep);
 
 		if (ret == 0) {
 			/* mark the key as being instantiated */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] security: keys: add NULL checking for key->type->instantiate
  2019-01-25  7:16 [PATCH] security: keys: add NULL checking for key->type->instantiate Geliang Tang
@ 2019-02-06 22:26 ` David Howells
  0 siblings, 0 replies; 2+ messages in thread
From: David Howells @ 2019-02-06 22:26 UTC (permalink / raw)
  To: Geliang Tang
  Cc: dhowells, James Morris, Serge E. Hallyn, keyrings,
	linux-security-module, linux-kernel

Geliang Tang <geliangtang@gmail.com> wrote:

> key->type->instantiate can be NULL, add NULL checking to prevent
> NULL pointer dereference in __key_instantiate_and_link().

Do you have an oops report or test case for this?

David

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-25  7:16 [PATCH] security: keys: add NULL checking for key->type->instantiate Geliang Tang
2019-02-06 22:26 ` David Howells

Linux-Security-Module Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-security-module/0 linux-security-module/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-security-module linux-security-module/ https://lore.kernel.org/linux-security-module \
		linux-security-module@vger.kernel.org linux-security-module@archiver.kernel.org
	public-inbox-index linux-security-module


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-security-module


AGPL code for this site: git clone https://public-inbox.org/ public-inbox