All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers3@gmail.com>
To: linux-security-module@vger.kernel.org
Subject: Re: [PATCH] KEYS: prevent KEYCTL_READ on negative key
Date: Thu, 21 Sep 2017 23:34:16 +0000	[thread overview]
Message-ID: <20170921233416.GC89627@gmail.com> (raw)
In-Reply-To: <30124.1505837342@warthog.procyon.org.uk>

On Tue, Sep 19, 2017 at 05:09:02PM +0100, David Howells wrote:
> Eric Biggers <ebiggers3@gmail.com> wrote:
> 
> > +	if (test_bit(KEY_FLAG_NEGATIVE, &key->flags)) {
> > +		ret = -ENOKEY;
> > +		goto error2;
> > +	}
> 
> It might be better to do this check in key_validate().  Also, it should
> perhaps take the error from key->reject_error.
> 
> David

Putting the check in key_validate() would make lookups with KEY_LOOKUP_PARTIAL
stop returning negative keys, which would break keyctl_describe(),
keyctl_chown(), keyctl_setperm(), keyctl_set_timeout(), keyctl_get_security() on
negative keys.  I presume those are supposed to work?

Another solution would be to remove the special case from lookup_user_key()
where it can return a negative/revoked/invalidated/expired key if
KEY_LOOKUP_PARTIAL is not specified and the 'perm' mask is 0.  The only callers
it would affect are the case in question here which is clearly a bug, and the
root-only exceptions for keyctl_invalidate() and keyctl_clear().  And I suspect
the latter two are unintentional as well.  (Is root *supposed* to be able to
invalidate a negative/revoked/invalidated/expired key, or clear a
revoked/invalidated/expired keyring?)

Eric

WARNING: multiple messages have this Message-ID (diff)
From: ebiggers3@gmail.com (Eric Biggers)
To: linux-security-module@vger.kernel.org
Subject: [PATCH] KEYS: prevent KEYCTL_READ on negative key
Date: Thu, 21 Sep 2017 16:34:16 -0700	[thread overview]
Message-ID: <20170921233416.GC89627@gmail.com> (raw)
In-Reply-To: <30124.1505837342@warthog.procyon.org.uk>

On Tue, Sep 19, 2017 at 05:09:02PM +0100, David Howells wrote:
> Eric Biggers <ebiggers3@gmail.com> wrote:
> 
> > +	if (test_bit(KEY_FLAG_NEGATIVE, &key->flags)) {
> > +		ret = -ENOKEY;
> > +		goto error2;
> > +	}
> 
> It might be better to do this check in key_validate().  Also, it should
> perhaps take the error from key->reject_error.
> 
> David

Putting the check in key_validate() would make lookups with KEY_LOOKUP_PARTIAL
stop returning negative keys, which would break keyctl_describe(),
keyctl_chown(), keyctl_setperm(), keyctl_set_timeout(), keyctl_get_security() on
negative keys.  I presume those are supposed to work?

Another solution would be to remove the special case from lookup_user_key()
where it can return a negative/revoked/invalidated/expired key if
KEY_LOOKUP_PARTIAL is not specified and the 'perm' mask is 0.  The only callers
it would affect are the case in question here which is clearly a bug, and the
root-only exceptions for keyctl_invalidate() and keyctl_clear().  And I suspect
the latter two are unintentional as well.  (Is root *supposed* to be able to
invalidate a negative/revoked/invalidated/expired key, or clear a
revoked/invalidated/expired keyring?)

Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Eric Biggers <ebiggers3@gmail.com>
To: David Howells <dhowells@redhat.com>
Cc: keyrings@vger.kernel.org, Michael Halcrow <mhalcrow@google.com>,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org, Eric Biggers <ebiggers@google.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH] KEYS: prevent KEYCTL_READ on negative key
Date: Thu, 21 Sep 2017 16:34:16 -0700	[thread overview]
Message-ID: <20170921233416.GC89627@gmail.com> (raw)
In-Reply-To: <30124.1505837342@warthog.procyon.org.uk>

On Tue, Sep 19, 2017 at 05:09:02PM +0100, David Howells wrote:
> Eric Biggers <ebiggers3@gmail.com> wrote:
> 
> > +	if (test_bit(KEY_FLAG_NEGATIVE, &key->flags)) {
> > +		ret = -ENOKEY;
> > +		goto error2;
> > +	}
> 
> It might be better to do this check in key_validate().  Also, it should
> perhaps take the error from key->reject_error.
> 
> David

Putting the check in key_validate() would make lookups with KEY_LOOKUP_PARTIAL
stop returning negative keys, which would break keyctl_describe(),
keyctl_chown(), keyctl_setperm(), keyctl_set_timeout(), keyctl_get_security() on
negative keys.  I presume those are supposed to work?

Another solution would be to remove the special case from lookup_user_key()
where it can return a negative/revoked/invalidated/expired key if
KEY_LOOKUP_PARTIAL is not specified and the 'perm' mask is 0.  The only callers
it would affect are the case in question here which is clearly a bug, and the
root-only exceptions for keyctl_invalidate() and keyctl_clear().  And I suspect
the latter two are unintentional as well.  (Is root *supposed* to be able to
invalidate a negative/revoked/invalidated/expired key, or clear a
revoked/invalidated/expired keyring?)

Eric

  reply	other threads:[~2017-09-21 23:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-18 18:37 [PATCH] KEYS: prevent KEYCTL_READ on negative key Eric Biggers
2017-09-18 18:37 ` Eric Biggers
2017-09-18 18:37 ` Eric Biggers
2017-09-19 16:09 ` David Howells
2017-09-19 16:09   ` David Howells
2017-09-19 16:09   ` David Howells
2017-09-21 23:34   ` Eric Biggers [this message]
2017-09-21 23:34     ` Eric Biggers
2017-09-21 23:34     ` Eric Biggers
2017-09-25 13:29     ` David Howells
2017-09-25 13:29       ` David Howells
2017-09-25 13:29       ` David Howells
2017-09-25 18:35       ` Eric Biggers
2017-09-25 18:35         ` Eric Biggers
2017-09-25 18:35         ` Eric Biggers

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=20170921233416.GC89627@gmail.com \
    --to=ebiggers3@gmail.com \
    --cc=linux-security-module@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.