KEYS: request_key() should return -ENOKEY if the constructed key is negative
[sfrench/cifs-2.6.git] / security / keys / request_key.c
index f5ec9ac5d57cf6af80f90eb90427ecb98385ae4f..0088dd8bf68a77b29637527733ff0b8985b8ecb7 100644 (file)
@@ -144,6 +144,7 @@ static int call_sbin_request_key(struct key_construction *cons,
        prkey = 0;
        if (cred->tgcred->process_keyring)
                prkey = cred->tgcred->process_keyring->serial;
+       sprintf(keyring_str[1], "%d", prkey);
 
        rcu_read_lock();
        session = rcu_dereference(cred->tgcred->session_keyring);
@@ -536,6 +537,8 @@ int wait_for_key_construction(struct key *key, bool intr)
                          intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);
        if (ret < 0)
                return ret;
+       if (test_bit(KEY_FLAG_NEGATIVE, &key->flags))
+               return -ENOKEY;
        return key_validate(key);
 }
 EXPORT_SYMBOL(wait_for_key_construction);