Linux Keyring error handling
[openafs.git] / src / afs / LINUX / osi_groups.c
index 6c727f3..cc48f6c 100644 (file)
@@ -87,7 +87,7 @@ afs_linux_pag_from_groups(struct group_info *group_info) {
 
 static inline void
 afs_linux_pag_to_groups(afs_uint32 newpag,
-                       struct group_info *old, struct group_info *new) {
+                       struct group_info *old, struct group_info **new) {
     int need_space = 0;
     int i;
     gid_t g0;
@@ -214,14 +214,9 @@ install_session_keyring(struct key *keyring)
     }
 
     /* install the keyring */
-    spin_lock_irq(&current->sighand->siglock);
-    old = task_session_keyring(current);
-    smp_wmb();
-    task_session_keyring(current) = keyring;
-    spin_unlock_irq(&current->sighand->siglock);
-
+    old = afs_set_session_keyring(keyring);
     if (old)
-           key_put(old);
+       key_put(old);
 
 out:
     return code;
@@ -258,7 +253,7 @@ setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag,
            key = afs_linux_key_alloc(&key_type_afs_pag, "_pag", 0, 0, perm, KEY_ALLOC_NOT_IN_QUOTA);
 
            if (!IS_ERR(key)) {
-               key_instantiate_and_link(key, (void *) newpag, sizeof(afs_uint32),
+               code = key_instantiate_and_link(key, (void *) newpag, sizeof(afs_uint32),
                                         current_session_keyring(), NULL);
                key_put(key);
            } else {
@@ -457,7 +452,11 @@ static void afs_pag_describe(const struct key *key, struct seq_file *m)
     seq_printf(m, ": %u", key->datalen);
 }
 
+#if defined(STRUCT_KEY_TYPE_HAS_PREPARSE)
+static int afs_pag_instantiate(struct key *key, struct key_preparsed_payload *prep)
+#else
 static int afs_pag_instantiate(struct key *key, const void *data, size_t datalen)
+#endif
 {
     int code;
     afs_uint32 *userpag, pag = NOPAG;
@@ -468,7 +467,11 @@ static int afs_pag_instantiate(struct key *key, const void *data, size_t datalen
     code = -EINVAL;
     get_group_info(current_group_info());
 
+#if defined(STRUCT_KEY_TYPE_HAS_PREPARSE)
+    if (prep->datalen != sizeof(afs_uint32) || !prep->data)
+#else
     if (datalen != sizeof(afs_uint32) || !data)
+#endif
        goto error;
 
     /* ensure key being set matches current pag */
@@ -477,7 +480,11 @@ static int afs_pag_instantiate(struct key *key, const void *data, size_t datalen
     if (pag == NOPAG)
        goto error;
 
-    userpag = (afs_uint32 *) data;
+#if defined(STRUCT_KEY_TYPE_HAS_PREPARSE)
+    userpag = (afs_uint32 *)prep->data;
+#else
+    userpag = (afs_uint32 *)data;
+#endif
     if (*userpag != pag)
        goto error;