const afs_ucred_t * afs_osi_proc2cred(afs_proc_t * pr) { afs_ucred_t *rv = NULL; static afs_ucred_t cr; if (pr == NULL) { return NULL; } if ((pr->state == TASK_RUNNING) || (pr->state == TASK_INTERRUPTIBLE) || (pr->state == TASK_UNINTERRUPTIBLE) || (pr->state == TASK_STOPPED)) { /* This is dangerous. If anyone ever crfree's the cred that's * returned from here, we'll go boom, because it's statically * allocated. */ atomic_set(&cr.cr_ref, 1); afs_set_cr_uid(&cr, task_uid(pr)); #if defined(AFS_LINUX26_ENV) #if defined(STRUCT_TASK_STRUCT_HAS_CRED) get_group_info(pr->cred->group_info); set_cr_group_info(&cr, pr->cred->group_info); #else get_group_info(pr->group_info); set_cr_group_info(&cr, pr->group_info); #endif #else cr.cr_ngroups = pr->ngroups; memcpy(cr.cr_groups, pr->groups, NGROUPS * sizeof(gid_t)); #endif rv = &cr; } return rv; }
/* Set the cred info into the current task */ void crset(cred_t * cr) { #if defined(STRUCT_TASK_STRUCT_HAS_CRED) struct cred *new_creds; /* If our current task doesn't have identical real and effective * credentials, commit_cred won't let us change them, so we just * bail here. */ if (current->cred != current->real_cred) return; new_creds = prepare_creds(); /* Drop the reference to group_info - we'll overwrite it in afs_copy_creds */ put_group_info(new_creds->group_info); afs_copy_creds(new_creds, current_cred()); commit_creds(new_creds); #else struct group_info *old_info; current->fsuid = afs_cr_uid(cr); current->uid = afs_cr_ruid(cr); current->fsgid = afs_cr_gid(cr); current->gid = afs_cr_rgid(cr); get_group_info(afs_cr_group_info(cr)); task_lock(current); old_info = current->group_info; current->group_info = afs_cr_group_info(cr); task_unlock(current); put_group_info(old_info); #endif }
static GdkFilterReturn filter( XEvent *xev, GdkEvent *event, gpointer data) { XkbEvent *xkbev; ENTER; if (xev->type != xkb_event_type) RET(GDK_FILTER_CONTINUE); xkbev = (XkbEvent *) xev; DBG("XkbTypeEvent %d \n", xkbev->any.xkb_type); if (xkbev->any.xkb_type == XkbStateNotify) { DBG("XkbStateNotify: group=%d\n", xkbev->state.group); cur_group = xkbev->state.group; if (cur_group >= ngroups) { ERR("current group is bigger then total group number"); cur_group = 0; } gui_update(); } else if (xkbev->any.xkb_type == XkbNewKeyboardNotify) { DBG("XkbNewKeyboardNotify\n"); free_group_info(); get_group_info(); gui_update(); gui_extra_rebuild(); } RET(GDK_FILTER_REMOVE); }
int group_member (gid_t gid) { #ifndef HAVE_GETGROUPS return ((gid == getgid ()) || (gid == getegid ())); #else int i; int found; struct group_info gi; if (! get_group_info (&gi)) return 0; /* Search through the list looking for GID. */ found = 0; for (i = 0; i < gi.n_groups; i++) { if (gid == gi.group[i]) { found = 1; break; } } free_group_info (&gi); return found; #endif /* HAVE_GETGROUPS */ }
int group_member (gid_t gid) { int i; int found; struct group_info gi; if (! get_group_info (&gi)) return 0; /* Search through the list looking for GID. */ found = 0; for (i = 0; i < gi.n_groups; i++) { if (gid == gi.group[i]) { found = 1; break; } } free_group_info (&gi); return found; }
asmlinkage long sys_getgroups(int gidsetsize, gid_t __user *grouplist) { int i = 0; /* * SMP: Nobody else can change our grouplist. Thus we are * safe. */ if (gidsetsize < 0) return -EINVAL; /* no need to grab task_lock here; it cannot change */ get_group_info(current->group_info); i = current->group_info->ngroups; if (gidsetsize) { if (i > gidsetsize) { i = -EINVAL; goto out; } if (groups_to_user(grouplist, current->group_info)) { i = -EFAULT; goto out; } } out: put_group_info(current->group_info); return i; }
/* Copy one credential structure to another, being careful about references */ static inline void afs_copy_creds(cred_t *to_cred, const cred_t *from_cred) { afs_set_cr_uid(to_cred, afs_cr_uid(from_cred)); afs_set_cr_gid(to_cred, afs_cr_gid(from_cred)); afs_set_cr_ruid(to_cred, afs_cr_ruid(from_cred)); afs_set_cr_rgid(to_cred, afs_cr_rgid(from_cred)); get_group_info(afs_cr_group_info(from_cred)); afs_set_cr_group_info(to_cred, afs_cr_group_info(from_cred)); }
static void create_all() { ENTER; get_group_info(); gui_create(); gui_update(); gui_extra_rebuild(); RET(); }
int in_egroup_p(gid_t grp) { int retval = 1; if (grp != current->egid) { get_group_info(current->group_info); retval = groups_search(current->group_info, grp); put_group_info(current->group_info); } return retval; }
/* Return the number of supplemental groups */ int crgetngroups(const cred_t *cr) { struct group_info *gi; int rc; gi = get_group_info(cr->group_info); rc = gi->ngroups; put_group_info(gi); return rc; }
/* Check if the passed gid is available is in supplied credential. */ int groupmember(gid_t gid, const cred_t *cr) { struct group_info *gi; int rc; gi = get_group_info(cr->group_info); rc = cr_groups_search(cr->group_info, gid); put_group_info(gi); return rc; }
/* * Return an array of supplemental gids. The returned address is safe * to use as long as the caller has taken a reference with crhold(). * The caller is responsible for releasing the reference with crfree(). */ gid_t * crgetgroups(const cred_t *cr) { struct group_info *gi; gid_t *gids; gi = get_group_info(cr->group_info); gids = gi->blocks[0]; put_group_info(gi); return gids; }
static inline void task_state(struct seq_file *m, struct pid_namespace *ns, struct pid *pid, struct task_struct *p) { struct group_info *group_info; int g; struct fdtable *fdt = NULL; pid_t ppid, tpid; rcu_read_lock(); ppid = pid_alive(p) ? task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0; tpid = 0; if (pid_alive(p)) { struct task_struct *tracer = tracehook_tracer_task(p); if (tracer) tpid = task_pid_nr_ns(tracer, ns); } seq_printf(m, "State:\t%s\n" "Tgid:\t%d\n" "Pid:\t%d\n" "PPid:\t%d\n" "TracerPid:\t%d\n" "Uid:\t%d\t%d\t%d\t%d\n" "Gid:\t%d\t%d\t%d\t%d\n", get_task_state(p), task_tgid_nr_ns(p, ns), pid_nr_ns(pid, ns), ppid, tpid, p->uid, p->euid, p->suid, p->fsuid, p->gid, p->egid, p->sgid, p->fsgid); task_lock(p); if (p->files) fdt = files_fdtable(p->files); seq_printf(m, "FDSize:\t%d\n" "Groups:\t", fdt ? fdt->max_fds : 0); rcu_read_unlock(); group_info = p->group_info; get_group_info(group_info); task_unlock(p); for (g = 0; g < min(group_info->ngroups, NGROUPS_SMALL); g++) seq_printf(m, "%d ", GROUP_AT(group_info, g)); put_group_info(group_info); seq_printf(m, "\n"); }
/* Check that the current application belongs to the * requested GID */ static bool tf_check_gid(gid_t requested_gid) { if (requested_gid == current_egid()) { return true; } else { u32 size; u32 i; /* Look in the supplementary GIDs */ get_group_info(GROUP_INFO); size = GROUP_INFO->ngroups; for (i = 0; i < size; i++) if (requested_gid == GROUP_AT(GROUP_INFO , i)) return true; } return false; }
/* Check that the current application belongs to the * requested GID */ static bool SCXLNXConnCheckGID(gid_t nRequestedGID) { if (nRequestedGID == current_egid()) { return true; } else { u32 nSize; u32 i; /* Look in the supplementary GIDs */ get_group_info(GROUP_INFO); nSize = GROUP_INFO->ngroups; for (i = 0; i < nSize; i++) if (nRequestedGID == GROUP_AT(GROUP_INFO , i)) return true; } return false; }
/* Return a duplicate of the cred. */ cred_t * crdup(cred_t * cr) { cred_t *tmp = crget(); #if defined(STRUCT_TASK_STRUCT_HAS_CRED) afs_copy_creds(tmp, cr); #else afs_set_cr_uid(tmp, afs_cr_uid(cr)); afs_set_cr_ruid(tmp, afs_cr_ruid(cr)); afs_set_cr_gid(tmp, afs_cr_gid(cr)); afs_set_cr_rgid(tmp, afs_cr_rgid(cr)); get_group_info(afs_cr_group_info(cr)); afs_set_cr_group_info(tmp, afs_cr_group_info(cr)); #endif return tmp; }
static inline char * task_state(struct task_struct *p, char *buffer) { struct group_info *group_info; int g; struct fdtable *fdt = NULL; read_lock(&tasklist_lock); buffer += sprintf(buffer, "State:\t%s\n" "SleepAVG:\t%lu%%\n" "Tgid:\t%d\n" "Pid:\t%d\n" "PPid:\t%d\n" "TracerPid:\t%d\n" "Uid:\t%d\t%d\t%d\t%d\n" "Gid:\t%d\t%d\t%d\t%d\n", get_task_state(p), (p->sleep_avg/1024)*100/(1020000000/1024), p->tgid, p->pid, pid_alive(p) ? p->group_leader->real_parent->tgid : 0, pid_alive(p) && p->ptrace ? p->parent->pid : 0, p->uid, p->euid, p->suid, p->fsuid, p->gid, p->egid, p->sgid, p->fsgid); read_unlock(&tasklist_lock); task_lock(p); rcu_read_lock(); if (p->files) fdt = files_fdtable(p->files); buffer += sprintf(buffer, "FDSize:\t%d\n" "Groups:\t", fdt ? fdt->max_fds : 0); rcu_read_unlock(); group_info = p->group_info; get_group_info(group_info); task_unlock(p); for (g = 0; g < min(group_info->ngroups,NGROUPS_SMALL); g++) buffer += sprintf(buffer, "%d ", GROUP_AT(group_info,g)); put_group_info(group_info); buffer += sprintf(buffer, "\n"); return buffer; }
/* * Use the SETCLIENTID credential */ static struct rpc_cred * nfsd4_lookupcred(struct nfs4_client *clp, int taskflags) { struct auth_cred acred; struct rpc_clnt *clnt = clp->cl_callback.cb_client; struct rpc_cred *ret; get_group_info(clp->cl_cred.cr_group_info); acred.uid = clp->cl_cred.cr_uid; acred.gid = clp->cl_cred.cr_gid; acred.group_info = clp->cl_cred.cr_group_info; dprintk("NFSD: looking up %s cred\n", clnt->cl_auth->au_ops->au_name); ret = rpcauth_lookup_credcache(clnt->cl_auth, &acred, taskflags); put_group_info(clp->cl_cred.cr_group_info); return ret; }
/* Return the number of supplemental groups */ int crgetngroups(const cred_t *cr) { int lock, rc; lock = (cr != current); if (lock) task_lock((struct task_struct *)cr); get_group_info(cr->group_info); rc = cr->group_info->ngroups; put_group_info(cr->group_info); if (lock) task_unlock((struct task_struct *)cr); return rc; }
/* Check if the passed gid is available is in supplied credential. */ int groupmember(gid_t gid, const cred_t *cr) { int lock, rc; lock = (cr != current); if (lock) task_lock((struct task_struct *)cr); get_group_info(cr->group_info); rc = cr_groups_search(cr->group_info, gid); put_group_info(cr->group_info); if (lock) task_unlock((struct task_struct *)cr); return rc; }
static inline void task_state(struct seq_file *m, struct pid *pid, struct task_struct *p) { struct group_info *group_info; int g; struct fdtable *fdt = NULL; rcu_read_lock(); seq_printf(m, "State:\t%s\n" "SleepAVG:\t%lu%%\n" "Tgid:\t%d\n" "Pid:\t%d\n" "PPid:\t%d\n" "TracerPid:\t%d\n" "Uid:\t%d\t%d\t%d\t%d\n" "Gid:\t%d\t%d\t%d\t%d\n", get_task_state(p), (p->sleep_avg/1024)*100/(1020000000/1024), p->tgid, p->pid, pid_alive(p) ? rcu_dereference(p->real_parent)->tgid : 0, pid_alive(p) && p->ptrace ? rcu_dereference(p->parent)->pid : 0, p->uid, p->euid, p->suid, p->fsuid, p->gid, p->egid, p->sgid, p->fsgid); task_lock(p); if (p->files) fdt = files_fdtable(p->files); seq_printf(m, "FDSize:\t%d\n" "Groups:\t", fdt ? fdt->max_fds : 0); rcu_read_unlock(); group_info = p->group_info; get_group_info(group_info); task_unlock(p); for (g = 0; g < min(group_info->ngroups, NGROUPS_SMALL); g++) seq_printf(m, "%d ", GROUP_AT(group_info, g)); put_group_info(group_info); seq_printf(m, "\n"); }
/* * Return an array of supplemental gids. The returned address is safe * to use as long as the caller has taken a reference with crhold(). * The caller is responsible for releasing the reference with crfree(). */ gid_t * crgetgroups(const cred_t *cr) { gid_t *gids; int lock; lock = (cr != current); if (lock) task_lock((struct task_struct *)cr); get_group_info(cr->group_info); gids = cr->group_info->blocks[0]; put_group_info(cr->group_info); if (lock) task_unlock((struct task_struct *)cr); return gids; }
/* Set the cred info into the current task */ void crset(cred_t * cr) { #if defined(STRUCT_TASK_HAS_CRED) struct cred *new_creds; new_creds = prepare_creds(); new_creds->fsuid = cr->cr_uid; new_creds->uid = cr->cr_ruid; new_creds->fsgid = cr->cr_gid; new_creds->gid = cr->cr_rgid; #else current->fsuid = cr->cr_uid; current->uid = cr->cr_ruid; current->fsgid = cr->cr_gid; current->gid = cr->cr_rgid; #endif #if defined(AFS_LINUX26_ENV) { struct group_info *old_info; /* using set_current_groups() will sort the groups */ get_group_info(cr->cr_group_info); task_lock(current); #if defined(STRUCT_TASK_HAS_CRED) old_info = current->cred->group_info; new_creds->group_info = cr->cr_group_info; commit_creds(new_creds); #else old_info = current->group_info; current->group_info = cr->cr_group_info; #endif task_unlock(current); put_group_info(old_info); } #else memcpy(current->groups, cr->cr_groups, NGROUPS * sizeof(gid_t)); current->ngroups = cr->cr_ngroups; #endif }
/* Return a duplicate of the cred. */ cred_t * crdup(cred_t * cr) { cred_t *tmp = crget(); tmp->cr_uid = cr->cr_uid; tmp->cr_ruid = cr->cr_ruid; tmp->cr_gid = cr->cr_gid; tmp->cr_rgid = cr->cr_rgid; #if defined(AFS_LINUX26_ENV) get_group_info(cr->cr_group_info); tmp->cr_group_info = cr->cr_group_info; #else memcpy(tmp->cr_groups, cr->cr_groups, NGROUPS * sizeof(gid_t)); tmp->cr_ngroups = cr->cr_ngroups; #endif return tmp; }
cred_t * crref(void) { cred_t *cr = crget(); cr->cr_uid = current_fsuid(); cr->cr_ruid = current_uid(); cr->cr_gid = current_fsgid(); cr->cr_rgid = current_gid(); #if defined(AFS_LINUX26_ENV) task_lock(current); get_group_info(current_group_info()); cr->cr_group_info = current_group_info(); task_unlock(current); #else memcpy(cr->cr_groups, current->groups, NGROUPS * sizeof(gid_t)); cr->cr_ngroups = current->ngroups; #endif return cr; }
/* validate and set current->group_info */ int set_current_groups(struct group_info *group_info) { int retval; struct group_info *old_info; retval = security_task_setgroups(group_info); if (retval) return retval; groups_sort(group_info); get_group_info(group_info); task_lock(current); old_info = current->group_info; current->group_info = group_info; task_unlock(current); put_group_info(old_info); return 0; }
cred_t * crref(void) { #if defined(STRUCT_TASK_STRUCT_HAS_CRED) return (cred_t *)get_current_cred(); #else cred_t *cr = crget(); afs_set_cr_uid(cr, current_fsuid()); afs_set_cr_ruid(cr, current_uid()); afs_set_cr_gid(cr, current_fsgid()); afs_set_cr_rgid(cr, current_gid()); task_lock(current); get_group_info(current_group_info()); afs_set_cr_group_info(cr, current_group_info()); task_unlock(current); return cr; #endif }
asmlinkage long sys_getgroups16(int gidsetsize, old_gid_t __user *grouplist) { int i = 0; if (gidsetsize < 0) return -EINVAL; get_group_info(current->group_info); i = current->group_info->ngroups; if (gidsetsize) { if (i > gidsetsize) { i = -EINVAL; goto out; } if (groups16_to_user(grouplist, current->group_info)) { i = -EFAULT; goto out; } } out: put_group_info(current->group_info); return i; }
/* * This creates a new process as a copy of the old one, * but does not actually start it yet. * * It copies the registers, and all the appropriate * parts of the process environment (as per the clone * flags). The actual kick-off is left to the caller. */ static task_t *copy_process(unsigned long clone_flags, unsigned long stack_start, struct pt_regs *regs, unsigned long stack_size, int __user *parent_tidptr, int __user *child_tidptr, int pid) { int retval; struct task_struct *p = NULL; if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS)) return ERR_PTR(-EINVAL); /* * Thread groups must share signals as well, and detached threads * can only be started up within the thread group. */ if ((clone_flags & CLONE_THREAD) && !(clone_flags & CLONE_SIGHAND)) return ERR_PTR(-EINVAL); /* * Shared signal handlers imply shared VM. By way of the above, * thread groups also imply shared VM. Blocking this case allows * for various simplifications in other code. */ if ((clone_flags & CLONE_SIGHAND) && !(clone_flags & CLONE_VM)) return ERR_PTR(-EINVAL); retval = security_task_create(clone_flags); if (retval) goto fork_out; retval = -ENOMEM; p = dup_task_struct(current); if (!p) goto fork_out; retval = -EAGAIN; if (atomic_read(&p->user->processes) >= p->signal->rlim[RLIMIT_NPROC].rlim_cur) { if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) && p->user != &root_user) goto bad_fork_free; } atomic_inc(&p->user->__count); atomic_inc(&p->user->processes); get_group_info(p->group_info); /* * If multiple threads are within copy_process(), then this check * triggers too late. This doesn't hurt, the check is only there * to stop root fork bombs. */ if (nr_threads >= max_threads) goto bad_fork_cleanup_count; if (!try_module_get(p->thread_info->exec_domain->module)) goto bad_fork_cleanup_count; if (p->binfmt && !try_module_get(p->binfmt->module)) goto bad_fork_cleanup_put_domain; p->did_exec = 0; copy_flags(clone_flags, p); p->pid = pid; retval = -EFAULT; if (clone_flags & CLONE_PARENT_SETTID) if (put_user(p->pid, parent_tidptr)) goto bad_fork_cleanup; p->proc_dentry = NULL; INIT_LIST_HEAD(&p->children); INIT_LIST_HEAD(&p->sibling); p->vfork_done = NULL; spin_lock_init(&p->alloc_lock); spin_lock_init(&p->proc_lock); clear_tsk_thread_flag(p, TIF_SIGPENDING); init_sigpending(&p->pending); p->it_real_value = 0; p->it_real_incr = 0; p->it_virt_value = cputime_zero; p->it_virt_incr = cputime_zero; p->it_prof_value = cputime_zero; p->it_prof_incr = cputime_zero; init_timer(&p->real_timer); p->real_timer.data = (unsigned long) p; p->utime = cputime_zero; p->stime = cputime_zero; p->rchar = 0; /* I/O counter: bytes read */ p->wchar = 0; /* I/O counter: bytes written */ p->syscr = 0; /* I/O counter: read syscalls */ p->syscw = 0; /* I/O counter: write syscalls */ acct_clear_integrals(p); p->lock_depth = -1; /* -1 = no lock */ do_posix_clock_monotonic_gettime(&p->start_time); p->security = NULL; p->io_context = NULL; p->io_wait = NULL; p->audit_context = NULL; #ifdef CONFIG_NUMA p->mempolicy = mpol_copy(p->mempolicy); if (IS_ERR(p->mempolicy)) { retval = PTR_ERR(p->mempolicy); p->mempolicy = NULL; goto bad_fork_cleanup; } #endif p->tgid = p->pid; if (clone_flags & CLONE_THREAD) p->tgid = current->tgid; if ((retval = security_task_alloc(p))) goto bad_fork_cleanup_policy; if ((retval = audit_alloc(p))) goto bad_fork_cleanup_security; /* copy all the process information */ if ((retval = copy_semundo(clone_flags, p))) goto bad_fork_cleanup_audit; if ((retval = copy_files(clone_flags, p))) goto bad_fork_cleanup_semundo; if ((retval = copy_fs(clone_flags, p))) goto bad_fork_cleanup_files; if ((retval = copy_sighand(clone_flags, p))) goto bad_fork_cleanup_fs; if ((retval = copy_signal(clone_flags, p))) goto bad_fork_cleanup_sighand; if ((retval = copy_mm(clone_flags, p))) goto bad_fork_cleanup_signal; if ((retval = copy_keys(clone_flags, p))) goto bad_fork_cleanup_mm; if ((retval = copy_namespace(clone_flags, p))) goto bad_fork_cleanup_keys; retval = copy_thread(0, clone_flags, stack_start, stack_size, p, regs); if (retval) goto bad_fork_cleanup_namespace; p->set_child_tid = (clone_flags & CLONE_CHILD_SETTID) ? child_tidptr : NULL; /* * Clear TID on mm_release()? */ p->clear_child_tid = (clone_flags & CLONE_CHILD_CLEARTID) ? child_tidptr: NULL; /* * Syscall tracing should be turned off in the child regardless * of CLONE_PTRACE. */ clear_tsk_thread_flag(p, TIF_SYSCALL_TRACE); /* Our parent execution domain becomes current domain These must match for thread signalling to apply */ p->parent_exec_id = p->self_exec_id; /* ok, now we should be set up.. */ p->exit_signal = (clone_flags & CLONE_THREAD) ? -1 : (clone_flags & CSIGNAL); p->pdeath_signal = 0; p->exit_state = 0; /* Perform scheduler related setup */ sched_fork(p); /* * Ok, make it visible to the rest of the system. * We dont wake it up yet. */ p->group_leader = p; INIT_LIST_HEAD(&p->ptrace_children); INIT_LIST_HEAD(&p->ptrace_list); /* Need tasklist lock for parent etc handling! */ write_lock_irq(&tasklist_lock); /* * The task hasn't been attached yet, so cpus_allowed mask cannot * have changed. The cpus_allowed mask of the parent may have * changed after it was copied first time, and it may then move to * another CPU - so we re-copy it here and set the child's CPU to * the parent's CPU. This avoids alot of nasty races. */ p->cpus_allowed = current->cpus_allowed; set_task_cpu(p, smp_processor_id()); /* * Check for pending SIGKILL! The new thread should not be allowed * to slip out of an OOM kill. (or normal SIGKILL.) */ if (sigismember(¤t->pending.signal, SIGKILL)) { write_unlock_irq(&tasklist_lock); retval = -EINTR; goto bad_fork_cleanup_namespace; } /* CLONE_PARENT re-uses the old parent */ if (clone_flags & (CLONE_PARENT|CLONE_THREAD)) p->real_parent = current->real_parent; else p->real_parent = current; p->parent = p->real_parent; if (clone_flags & CLONE_THREAD) { spin_lock(¤t->sighand->siglock); /* * Important: if an exit-all has been started then * do not create this new thread - the whole thread * group is supposed to exit anyway. */ if (current->signal->flags & SIGNAL_GROUP_EXIT) { spin_unlock(¤t->sighand->siglock); write_unlock_irq(&tasklist_lock); retval = -EAGAIN; goto bad_fork_cleanup_namespace; } p->group_leader = current->group_leader; if (current->signal->group_stop_count > 0) { /* * There is an all-stop in progress for the group. * We ourselves will stop as soon as we check signals. * Make the new thread part of that group stop too. */ current->signal->group_stop_count++; set_tsk_thread_flag(p, TIF_SIGPENDING); } spin_unlock(¤t->sighand->siglock); } SET_LINKS(p); if (unlikely(p->ptrace & PT_PTRACED)) __ptrace_link(p, current->parent); attach_pid(p, PIDTYPE_PID, p->pid); attach_pid(p, PIDTYPE_TGID, p->tgid); if (thread_group_leader(p)) { attach_pid(p, PIDTYPE_PGID, process_group(p)); attach_pid(p, PIDTYPE_SID, p->signal->session); if (p->pid) __get_cpu_var(process_counts)++; } nr_threads++; total_forks++; write_unlock_irq(&tasklist_lock); retval = 0; fork_out: if (retval) return ERR_PTR(retval); return p; bad_fork_cleanup_namespace: exit_namespace(p); bad_fork_cleanup_keys: exit_keys(p); bad_fork_cleanup_mm: if (p->mm) mmput(p->mm); bad_fork_cleanup_signal: exit_signal(p); bad_fork_cleanup_sighand: exit_sighand(p); bad_fork_cleanup_fs: exit_fs(p); /* blocking */ bad_fork_cleanup_files: exit_files(p); /* blocking */ bad_fork_cleanup_semundo: exit_sem(p); bad_fork_cleanup_audit: audit_free(p); bad_fork_cleanup_security: security_task_free(p); bad_fork_cleanup_policy: #ifdef CONFIG_NUMA mpol_free(p->mempolicy); #endif bad_fork_cleanup: if (p->binfmt) module_put(p->binfmt->module); bad_fork_cleanup_put_domain: module_put(p->thread_info->exec_domain->module); bad_fork_cleanup_count: put_group_info(p->group_info); atomic_dec(&p->user->processes); free_uid(p->user); bad_fork_free: free_task(p); goto fork_out; }
int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp) { struct svc_cred cred = rqstp->rq_cred; int i; int flags = nfsexp_flags(rqstp, exp); int ret; if (flags & NFSEXP_ALLSQUASH) { cred.cr_uid = exp->ex_anon_uid; cred.cr_gid = exp->ex_anon_gid; cred.cr_group_info = groups_alloc(0); } else if (flags & NFSEXP_ROOTSQUASH) { struct group_info *gi; if (!cred.cr_uid) cred.cr_uid = exp->ex_anon_uid; if (!cred.cr_gid) cred.cr_gid = exp->ex_anon_gid; gi = groups_alloc(cred.cr_group_info->ngroups); if (gi) for (i = 0; i < cred.cr_group_info->ngroups; i++) { if (!GROUP_AT(cred.cr_group_info, i)) GROUP_AT(gi, i) = exp->ex_anon_gid; else GROUP_AT(gi, i) = GROUP_AT(cred.cr_group_info, i); } cred.cr_group_info = gi; } else get_group_info(cred.cr_group_info); if (cred.cr_uid != (uid_t) -1) current->fsuid = cred.cr_uid; else current->fsuid = exp->ex_anon_uid; if (cred.cr_gid != (gid_t) -1) current->fsgid = cred.cr_gid; else current->fsgid = exp->ex_anon_gid; if (!cred.cr_group_info) return -ENOMEM; ret = set_current_groups(cred.cr_group_info); put_group_info(cred.cr_group_info); if ((cred.cr_uid)) { current->cap_effective = cap_drop_nfsd_set(current->cap_effective); } else { current->cap_effective = cap_raise_nfsd_set(current->cap_effective, current->cap_permitted); } return ret; }