[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170921233416.GC89627@gmail.com>
Date: Thu, 21 Sep 2017 16:34:16 -0700
From: Eric Biggers <ebiggers3@...il.com>
To: David Howells <dhowells@...hat.com>
Cc: keyrings@...r.kernel.org, Michael Halcrow <mhalcrow@...gle.com>,
linux-security-module@...r.kernel.org,
linux-kernel@...r.kernel.org, Eric Biggers <ebiggers@...gle.com>,
stable@...r.kernel.org
Subject: Re: [PATCH] KEYS: prevent KEYCTL_READ on negative key
On Tue, Sep 19, 2017 at 05:09:02PM +0100, David Howells wrote:
> Eric Biggers <ebiggers3@...il.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
Powered by blists - more mailing lists