[PATCH] KEYS: prevent KEYCTL_READ on negative key
Eric Biggers
ebiggers3 at gmail.com
Thu Sep 21 23:34:16 UTC 2017
On Tue, Sep 19, 2017 at 05:09:02PM +0100, David Howells wrote:
> Eric Biggers <ebiggers3 at 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
More information about the Linux-security-module-archive
mailing list