Linux 3.8: session_keyring changes

The session_keyring is now attached directly to the cred structure
and the thread_group_cred structure (cred->tgcred) no longer exists.

Adapt code that makes use of tgcred, and use the standard rcu based
mechanism to update session_keyring.

Change-Id: If4b88cbc7f9af6343353648837b28541a5088429
Reviewed-on: http://gerrit.openafs.org/8905
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
This commit is contained in:
Marc Dionne 2013-01-09 19:26:54 -05:00 committed by Derrick Brashear
parent b61eac783e
commit c6d27e322a
4 changed files with 42 additions and 11 deletions

View File

@ -827,6 +827,7 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
[write_begin], [fs.h])
AC_CHECK_LINUX_STRUCT([backing_dev_info], [name],
[backing-dev.h])
AC_CHECK_LINUX_STRUCT([cred], [session_keyring], [cred.h])
AC_CHECK_LINUX_STRUCT([ctl_table], [ctl_name], [sysctl.h])
AC_CHECK_LINUX_STRUCT([dentry_operations], [d_automount], [dcache.h])
AC_CHECK_LINUX_STRUCT([inode], [i_alloc_sem], [fs.h])

View File

@ -186,14 +186,24 @@ afs_linux_key_alloc(struct key_type *type, const char *desc, uid_t uid,
}
# if defined(STRUCT_TASK_STRUCT_HAS_CRED)
static inline struct key *
afs_session_keyring(afs_ucred_t *cred)
{
# if defined(STRUCT_CRED_HAS_SESSION_KEYRING)
return cred->session_keyring;
# else
return cred->tgcred->session_keyring;
# endif
}
static inline struct key*
afs_linux_search_keyring(afs_ucred_t *cred, struct key_type *type)
{
key_ref_t key_ref;
if (cred->tgcred->session_keyring) {
if (afs_session_keyring(cred)) {
key_ref = keyring_search(
make_key_ref(cred->tgcred->session_keyring, 1),
make_key_ref(afs_session_keyring(cred), 1),
type, "_pag");
if (IS_ERR(key_ref))
return ERR_CAST(key_ref);
@ -550,4 +560,24 @@ afs_putname(afs_name_t name) {
}
#endif
static_inline struct key *
afs_set_session_keyring(struct key *keyring)
{
struct key *old;
#if defined(STRUCT_CRED_HAS_SESSION_KEYRING)
struct cred *new_creds;
old = current_session_keyring();
new_creds = prepare_creds();
rcu_assign_pointer(new_creds->session_keyring, keyring);
commit_creds(new_creds);
#else
spin_lock_irq(&current->sighand->siglock);
old = task_session_keyring(current);
smp_wmb();
task_session_keyring(current) = keyring;
spin_unlock_irq(&current->sighand->siglock);
#endif
return old;
}
#endif /* AFS_LINUX_OSI_COMPAT_H */

View File

@ -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;

View File

@ -184,8 +184,13 @@ afs_set_cr_group_info(cred_t *cred, struct group_info *group_info) {
# define current_group_info() (current->cred->group_info)
# define task_gid(task) (task->cred->gid)
# define task_user(task) (task->cred->user)
# define task_session_keyring(task) (task->cred->tgcred->session_keyring)
# define current_session_keyring() (current->cred->tgcred->session_keyring)
# if defined(STRUCT_CRED_HAS_SESSION_KEYRING)
# define task_session_keyring(task) (task->cred->session_keyring)
# define current_session_keyring() (current->cred->session_keyring)
# else
# define task_session_keyring(task) (task->cred->tgcred->session_keyring)
# define current_session_keyring() (current->cred->tgcred->session_keyring)
# endif
#else