From: Chas Williams Date: Thu, 17 Aug 2006 14:57:28 +0000 (+0000) Subject: DEVEL15-linux-keyring-pag-update-20060817 X-Git-Tag: openafs-devel-1_5_7 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=819155a50be94de04820b62130c7336d02d22f01;p=packages%2Fo%2Fopenafs.git DEVEL15-linux-keyring-pag-update-20060817 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) --- diff --git a/src/afs/LINUX/osi_groups.c b/src/afs/LINUX/osi_groups.c index bf2117296..1409624f7 100644 --- a/src/afs/LINUX/osi_groups.c +++ b/src/afs/LINUX/osi_groups.c @@ -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(); diff --git a/src/afs/LINUX/osi_prototypes.h b/src/afs/LINUX/osi_prototypes.h index 149274cc5..a82143d66 100644 --- a/src/afs/LINUX/osi_prototypes.h +++ b/src/afs/LINUX/osi_prototypes.h @@ -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 */ diff --git a/src/afs/afs_osi_pag.c b/src/afs/afs_osi_pag.c index a7fda7715..2de0d6297 100644 --- a/src/afs/afs_osi_pag.c +++ b/src/afs/afs_osi_pag.c @@ -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;