Message ID | 20170927195047.122358-2-ebiggers3@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Eric Biggers <ebiggers3@gmail.com> wrote: > + if ((key->flags & ((1 << KEY_FLAG_INVALIDATED) | > + (1 << KEY_FLAG_REVOKED) | > + (1 << KEY_FLAG_INSTANTIATED))) != > + (1 << KEY_FLAG_INSTANTIATED)) { Does this need READ_ONCE(), I wonder? David -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Eric Biggers <ebiggers3@gmail.com> wrote: > Therefore, change find_key_to_update() to return NULL if the found key > is uninstantiated, so that add_key() replaces the key rather than > instantiating it. This seems to be better than fixing __key_update() to > call __key_instantiate_and_link(), since given all the bugs noted above > as well as that the existing behavior was undocumented and > keyctl_instantiate() is supposed to be used instead, I doubt anyone was > relying on the existing behavior. keyctl_instantiate() can only be called from an upcall. It can't be called in the same context as keyctl_update(). I would be okay with making key_update() wait for completion of construction in this case. David -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/security/keys/keyring.c b/security/keys/keyring.c index 4fa82a8a9c0e..129a4175760b 100644 --- a/security/keys/keyring.c +++ b/security/keys/keyring.c @@ -1056,8 +1056,8 @@ EXPORT_SYMBOL(keyring_restrict); * caller must also hold a lock on the keyring semaphore. * * Returns a pointer to the found key with usage count incremented if - * successful and returns NULL if not found. Revoked and invalidated keys are - * skipped over. + * successful and returns NULL if not found. Revoked, invalidated, and + * uninstantiated keys are skipped over. (But negative keys are not!) * * If successful, the possession indicator is propagated from the keyring ref * to the returned key reference. @@ -1084,8 +1084,10 @@ key_ref_t find_key_to_update(key_ref_t keyring_ref, found: key = keyring_ptr_to_key(object); - if (key->flags & ((1 << KEY_FLAG_INVALIDATED) | - (1 << KEY_FLAG_REVOKED))) { + if ((key->flags & ((1 << KEY_FLAG_INVALIDATED) | + (1 << KEY_FLAG_REVOKED) | + (1 << KEY_FLAG_INSTANTIATED))) != + (1 << KEY_FLAG_INSTANTIATED)) { kleave(" = NULL [x]"); return NULL; }