public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: dhowells@redhat.com, james.l.morris@oracle.com, serge@hallyn.com,
	keyrings@vger.kernel.org, linux-security-module@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>,
	syzkaller@googlegroups.com, Kostya Serebryany <kcc@google.com>,
	Alexander Potapenko <glider@google.com>,
	Andrey Konovalov <andreyknvl@google.com>,
	Sasha Levin <sasha.levin@oracle.com>,
	Julien Tinnes <jln@google.com>, Kees Cook <keescook@google.com>
Subject: Re: GPF in keyring_destroy
Date: Mon, 19 Oct 2015 11:33:38 +0100	[thread overview]
Message-ID: <17443.1445250818@warthog.procyon.org.uk> (raw)
In-Reply-To: <CACT4Y+YTQsuNxDM4Zudb=tx0f8s+LbApEXoW2XcYZV84aMtADA@mail.gmail.com>

Dmitry Vyukov <dvyukov@google.com> wrote:

> > Does the attached patch fix it for you?
> 
> Yes, it fixes the crash for me.

I have an additional patch to prevent keyrings from being constructed by
request_key() at all (though it can still search for them).  Could you give
this a spin in addition to the previous one also?

Thanks,
David
---
commit 27874345bb8d2c39f3d493607a86ecbfcb100405
Author: David Howells <dhowells@redhat.com>
Date:   Mon Oct 19 11:20:28 2015 +0100

    KEYS: Don't permit request_key() to construct a new keyring
    
    If request_key() is used to find a keyring, only do the search part - don't
    do the construction part if the keyring was not found by the search.  We
    don't really want keyrings in the negative instantiated state since the
    rejected/negative instantiation error value in the payload is unioned with
    keyring metadata.
    
    Signed-off-by: David Howells <dhowells@redhat.com>

diff --git a/security/keys/request_key.c b/security/keys/request_key.c
index 486ef6fa393b..0d6253124278 100644
--- a/security/keys/request_key.c
+++ b/security/keys/request_key.c
@@ -440,6 +440,9 @@ static struct key *construct_key_and_link(struct keyring_search_context *ctx,
 
 	kenter("");
 
+	if (ctx->index_key.type == &key_type_keyring)
+		return ERR_PTR(-EPERM);
+	
 	user = key_user_lookup(current_fsuid());
 	if (!user)
 		return ERR_PTR(-ENOMEM);

  parent reply	other threads:[~2015-10-19 10:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-12  8:40 GPF in keyring_destroy Dmitry Vyukov
2015-10-15 15:29 ` David Howells
2015-10-15 19:21 ` David Howells
2015-10-19  8:26   ` Dmitry Vyukov
2015-10-19  9:30     ` David Howells
2015-10-19  9:31       ` Dmitry Vyukov
2015-10-19 10:25         ` David Howells
2015-10-19 10:33     ` David Howells [this message]
2015-10-19 10:41       ` Dmitry Vyukov
2015-10-19 10:55         ` David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17443.1445250818@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=andreyknvl@google.com \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=james.l.morris@oracle.com \
    --cc=jln@google.com \
    --cc=kcc@google.com \
    --cc=keescook@google.com \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=sasha.levin@oracle.com \
    --cc=serge@hallyn.com \
    --cc=syzkaller@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox