DEVEL15-linux-keyring-pag-update-20060817 openafs-devel-1_5_7
authorChas Williams <chas@cmf.nrl.navy.mil>
Thu, 17 Aug 2006 14:57:28 +0000 (14:57 +0000)
committerDerrick Brashear <shadow@dementia.org>
Thu, 17 Aug 2006 14:57:28 +0000 (14:57 +0000)
FIXES 37887

if you manage to patch the syscall table, then the setpag() in the
patched setgroups syscall and creates a new session keyring. it does
contain the right pag id but this isnt the intended behavior.

so setpag() becomes __setpag() which just does the group insertion.
(and perhaps it should be called something else?). the stat count for
the setpag operation might be more correct now (instead of also counting
the pag restores).

(cherry picked from commit b6da19fe253f456b7d9372d6620057bbd8ad2c8b)

src/afs/LINUX/osi_groups.c
src/afs/LINUX/osi_prototypes.h
src/afs/afs_osi_pag.c

index bf21172..1409624 100644 (file)
@@ -153,7 +153,7 @@ set_pag_in_parent(int pag, int g0, int g1)
 
 #if defined(AFS_LINUX26_ENV)
 int
-__setpag(cred_t ** cr, afs_uint32 pagvalue, afs_uint32 * newpag,
+__setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag,
          int change_parent)
 {
     struct group_info *group_info;
@@ -162,8 +162,6 @@ __setpag(cred_t ** cr, afs_uint32 pagvalue, afs_uint32 * newpag,
     int i;
     int need_space = 0;
 
-    AFS_STATCNT(setpag);
-
     group_info = afs_getgroups(*cr);
     if (group_info->ngroups < 2
        ||  afs_get_pag_from_groups(GROUP_AT(group_info, 0),
@@ -204,54 +202,15 @@ __join_session_keyring(char *name)
 }
 #endif /* LINUX_KEYRING_SUPPORT */
 
-int
-setpag(cred_t ** cr, afs_uint32 pagvalue, afs_uint32 * newpag,
-         int change_parent)
-{
-    int code;
-
-    code = __setpag(cr, pagvalue, newpag, change_parent);
-
-#ifdef LINUX_KEYRING_SUPPORT
-    if (code == 0) {
-
-       (void) __join_session_keyring(NULL);
-
-       if (current->signal->session_keyring) {
-           struct key *key;
-           key_perm_t perm;
-
-           perm = KEY_POS_VIEW | KEY_POS_SEARCH;
-           perm |= KEY_USR_VIEW | KEY_USR_SEARCH;
-
-#ifdef KEY_ALLOC_NEEDS_STRUCT_TASK
-           key = key_alloc(&key_type_afs_pag, "_pag", 0, 0, current, perm, 1);
-#else
-           key = key_alloc(&key_type_afs_pag, "_pag", 0, 0, perm, 1);
-#endif
-
-           if (!IS_ERR(key)) {
-               key_instantiate_and_link(key, (void *) newpag, sizeof(afs_uint32),
-                                        current->signal->session_keyring, NULL);
-               key_put(key);
-           }
-       }
-    }
-#endif /* LINUX_KEYRING_SUPPORT */
-
-    return code;
-}
 #else
 int
-setpag(cred_t ** cr, afs_uint32 pagvalue, afs_uint32 * newpag,
-       int change_parent)
+__setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag,
+         int change_parent)
 {
     gid_t *gidset;
     afs_int32 ngroups, code = 0;
     int j;
 
-    AFS_STATCNT(setpag);
-
     gidset = (gid_t *) osi_Alloc(NGROUPS * sizeof(gidset[0]));
     ngroups = afs_getgroups(*cr, gidset);
 
@@ -283,6 +242,47 @@ setpag(cred_t ** cr, afs_uint32 pagvalue, afs_uint32 * newpag,
 #endif
 
 
+int
+setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag,
+       int change_parent)
+{
+    int code;
+
+    AFS_STATCNT(setpag);
+
+    code = __setpag(cr, pagvalue, newpag, change_parent);
+
+#ifdef LINUX_KEYRING_SUPPORT
+    if (code == 0) {
+
+       (void) __join_session_keyring(NULL);
+
+       if (current->signal->session_keyring) {
+           struct key *key;
+           key_perm_t perm;
+
+           perm = KEY_POS_VIEW | KEY_POS_SEARCH;
+           perm |= KEY_USR_VIEW | KEY_USR_SEARCH;
+
+#ifdef KEY_ALLOC_NEEDS_STRUCT_TASK
+           key = key_alloc(&key_type_afs_pag, "_pag", 0, 0, current, perm, 1);
+#else
+           key = key_alloc(&key_type_afs_pag, "_pag", 0, 0, perm, 1);
+#endif
+
+           if (!IS_ERR(key)) {
+               key_instantiate_and_link(key, (void *) newpag, sizeof(afs_uint32),
+                                        current->signal->session_keyring, NULL);
+               key_put(key);
+           }
+       }
+    }
+#endif /* LINUX_KEYRING_SUPPORT */
+
+    return code;
+}
+
+
 /* Intercept the standard system call. */
 extern asmlinkage long (*sys_setgroupsp) (int gidsetsize, gid_t * grouplist);
 asmlinkage long
@@ -307,7 +307,7 @@ afs_xsetgroups(int gidsetsize, gid_t * grouplist)
     cr = crref();
     if (old_pag != NOPAG && PagInCred(cr) == NOPAG) {
        /* re-install old pag if there's room. */
-       code = setpag(&cr, old_pag, &junk, 0);
+       code = __setpag(&cr, old_pag, &junk, 0);
     }
     crfree(cr);
     unlock_kernel();
@@ -342,7 +342,7 @@ afs_xsetgroups32(int gidsetsize, gid_t * grouplist)
     cr = crref();
     if (old_pag != NOPAG && PagInCred(cr) == NOPAG) {
        /* re-install old pag if there's room. */
-       code = setpag(&cr, old_pag, &junk, 0);
+       code = __setpag(&cr, old_pag, &junk, 0);
     }
     crfree(cr);
     unlock_kernel();
@@ -376,7 +376,7 @@ asmlinkage long afs32_xsetgroups(int gidsetsize, gid_t *grouplist)
     cr = crref();
     if (old_pag != NOPAG && PagInCred(cr) == NOPAG) {
        /* re-install old pag if there's room. */
-       code = setpag(&cr, old_pag, &junk, 0);
+       code = __setpag(&cr, old_pag, &junk, 0);
     }
     crfree(cr);
     unlock_kernel();
@@ -411,7 +411,7 @@ afs32_xsetgroups(int gidsetsize, u16 * grouplist)
     cr = crref();
     if (old_pag != NOPAG && PagInCred(cr) == NOPAG) {
        /* re-install old pag if there's room. */
-       code = setpag(&cr, old_pag, &junk, 0);
+       code = __setpag(&cr, old_pag, &junk, 0);
     }
     crfree(cr);
     unlock_kernel();
@@ -445,7 +445,7 @@ afs32_xsetgroups32(int gidsetsize, gid_t * grouplist)
     cr = crref();
     if (old_pag != NOPAG && PagInCred(cr) == NOPAG) {
        /* re-install old pag if there's room. */
-       code = setpag(&cr, old_pag, &junk, 0);
+       code = __setpag(&cr, old_pag, &junk, 0);
     }
     crfree(cr);
     unlock_kernel();
index 149274c..a82143d 100644 (file)
@@ -91,7 +91,7 @@ extern void afs_fill_inode(struct inode *ip, struct vattr *vattr);
 extern void osi_keyring_init(void);
 extern void osi_keyring_shutdown(void);
 extern int __setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag,
-                    int change_parent);
+                   int change_parent);
 #ifdef LINUX_KEYRING_SUPPORT
 extern struct key_type key_type_afs_pag;
 #endif /* LINUX_KEYRING_SUPPORT */
index a7fda77..2de0d62 100644 (file)
@@ -539,7 +539,7 @@ PagInCred(const struct AFS_UCRED *cred)
 #endif
     pag = (afs_int32) afs_get_pag_from_groups(g0, g1);
 out:
-#ifdef LINUX_KEYRING_SUPPORT
+#if defined(AFS_LINUX26_ENV) && defined(LINUX_KEYRING_SUPPORT)
     if (pag == NOPAG) {
        struct key *key;
        afs_uint32 pag, newpag;