* Use curthread->td_ucred in numerous places, primarily system calls,
where curproc->p_ucred was used before.
* Clean up local variable use related to the above.
* Adjust several places where p_ucred is replaced to properly deal
with lwp threading races to avoid accessing and freeing a potentially
stale ucred.
* Adjust static procedures in the ktrace code to generally take lwp
pointers instead of proc pointers.
34 files changed:
sys_osethostname(struct sethostname_args *uap)
{
struct thread *td = curthread;
sys_osethostname(struct sethostname_args *uap)
{
struct thread *td = curthread;
- struct proc *p = td->td_proc;
size_t len;
char *hostname;
int name[2];
int error;
size_t len;
char *hostname;
int name[2];
int error;
name[0] = CTL_KERN;
name[1] = KERN_HOSTNAME;
name[0] = CTL_KERN;
name[1] = KERN_HOSTNAME;
- error = priv_check_cred(p->p_ucred, PRIV_SETHOSTNAME, 0);
+ error = priv_check_cred(td->td_ucred, PRIV_SETHOSTNAME, 0);
if (error)
return (error);
len = MIN(uap->len, MAXHOSTNAMELEN);
if (error)
return (error);
len = MIN(uap->len, MAXHOSTNAMELEN);
}
if ((error = VFS_FHTOVP(mp, NULL, &fh.fh_fid, &vp)))
goto done;
}
if ((error = VFS_FHTOVP(mp, NULL, &fh.fh_fid, &vp)))
goto done;
- error = vn_stat(vp, &sb, td->td_proc->p_ucred);
+ error = vn_stat(vp, &sb, td->td_ucred);
vput(vp);
if (error)
goto done;
vput(vp);
if (error)
goto done;
fp = holdfp(p->p_fd, args->sysmsg_iresult, -1);
if (fp) {
fp = holdfp(p->p_fd, args->sysmsg_iresult, -1);
if (fp) {
- if (fp->f_type == DTYPE_VNODE)
- fo_ioctl(fp, TIOCSCTTY, NULL, p->p_ucred, NULL);
+ if (fp->f_type == DTYPE_VNODE) {
+ fo_ioctl(fp, TIOCSCTTY, NULL,
+ td->td_ucred, NULL);
+ }
static int
linux_fcntl_common(struct linux_fcntl64_args *args)
{
static int
linux_fcntl_common(struct linux_fcntl64_args *args)
{
- struct proc *p = curproc;
+ struct thread *td = curthread;
struct l_flock linux_flock;
struct file *fp;
union fcntl_dat dat;
struct l_flock linux_flock;
struct file *fp;
union fcntl_dat dat;
* significant effect for pipes (SIGIO is not delivered for
* pipes under Linux-2.2.35 at least).
*/
* significant effect for pipes (SIGIO is not delivered for
* pipes under Linux-2.2.35 at least).
*/
- fp = holdfp(p->p_fd, args->fd, -1);
+ fp = holdfp(td->td_proc->p_fd, args->fd, -1);
if (fp == NULL)
return (EBADF);
if (fp->f_type == DTYPE_PIPE) {
if (fp == NULL)
return (EBADF);
if (fp->f_type == DTYPE_PIPE) {
- error = kern_fcntl(args->fd, cmd, &dat, p->p_ucred);
+ error = kern_fcntl(args->fd, cmd, &dat, td->td_ucred);
if (error == 0) {
switch (args->cmd) {
if (error == 0) {
switch (args->cmd) {
int
sys_linux_fcntl64(struct linux_fcntl64_args *args)
{
int
sys_linux_fcntl64(struct linux_fcntl64_args *args)
{
+ struct thread *td = curthread;
struct l_flock64 linux_flock;
union fcntl_dat dat;
int error, cmd = 0;
struct l_flock64 linux_flock;
union fcntl_dat dat;
int error, cmd = 0;
linux_to_bsd_flock64(&linux_flock, &dat.fc_flock);
/* MPSAFE */
linux_to_bsd_flock64(&linux_flock, &dat.fc_flock);
/* MPSAFE */
- error = kern_fcntl(args->fd, cmd, &dat, curproc->p_ucred);
+ error = kern_fcntl(args->fd, cmd, &dat, td->td_ucred);
if (error == 0 && args->cmd == LINUX_F_GETLK64) {
bsd_to_linux_flock64(&dat.fc_flock, &linux_flock);
if (error == 0 && args->cmd == LINUX_F_GETLK64) {
bsd_to_linux_flock64(&dat.fc_flock, &linux_flock);
- error = VOP_OPEN(vp, FREAD, p->p_ucred, NULL);
+ error = VOP_OPEN(vp, FREAD, td->td_ucred, NULL);
int ngrp, error;
ngrp = args->gidsetsize;
int ngrp, error;
ngrp = args->gidsetsize;
+ oldcred = td->td_ucred;
/*
* cr_groups[0] holds egid. Setting the whole set from
/*
* cr_groups[0] holds egid. Setting the whole set from
+ oldcred = p->p_ucred; /* reload, deal with threads race */
p->p_ucred = newcred;
crfree(oldcred);
rel_mplock();
p->p_ucred = newcred;
crfree(oldcred);
rel_mplock();
sys_linux_getgroups(struct linux_getgroups_args *args)
{
struct thread *td = curthread;
sys_linux_getgroups(struct linux_getgroups_args *args)
{
struct thread *td = curthread;
- struct proc *p = td->td_proc;
struct ucred *cred;
l_gid_t linux_gidset[NGROUPS];
gid_t *bsd_gidset;
int bsd_gidsetsz, ngrp, error;
struct ucred *cred;
l_gid_t linux_gidset[NGROUPS];
gid_t *bsd_gidset;
int bsd_gidsetsz, ngrp, error;
bsd_gidset = cred->cr_groups;
bsd_gidsetsz = cred->cr_ngroups - 1;
bsd_gidset = cred->cr_groups;
bsd_gidsetsz = cred->cr_ngroups - 1;
sys_linux_getgid(struct linux_getgid_args *args)
{
struct thread *td = curthread;
sys_linux_getgid(struct linux_getgid_args *args)
{
struct thread *td = curthread;
- struct proc *p = td->td_proc;
- args->sysmsg_result = p->p_ucred->cr_rgid;
+ args->sysmsg_result = td->td_ucred->cr_rgid;
sys_linux_getuid(struct linux_getuid_args *args)
{
struct thread *td = curthread;
sys_linux_getuid(struct linux_getuid_args *args)
{
struct thread *td = curthread;
- struct proc *p = td->td_proc;
- args->sysmsg_result = p->p_ucred->cr_ruid;
+ args->sysmsg_result = td->td_ucred->cr_ruid;
static int
linux_accept(struct linux_accept_args *args, int *res)
{
static int
linux_accept(struct linux_accept_args *args, int *res)
{
+ struct thread *td = curthread;
struct linux_accept_args linux_args;
struct sockaddr *sa = NULL;
union fcntl_dat dat = { 0 };
struct linux_accept_args linux_args;
struct sockaddr *sa = NULL;
union fcntl_dat dat = { 0 };
* accepted one, so we must clear the flags in the new descriptor.
* Ignore any errors, because we already have an open fd.
*/
* accepted one, so we must clear the flags in the new descriptor.
* Ignore any errors, because we already have an open fd.
*/
- kern_fcntl(*res, F_SETFL, &dat, curproc->p_ucred);
+ kern_fcntl(*res, F_SETFL, &dat, td->td_ucred);
int
sys_linux_ustat(struct linux_ustat_args *args)
{
int
sys_linux_ustat(struct linux_ustat_args *args)
{
+ struct thread *td = curthread;
struct l_ustat lu;
cdev_t dev;
struct vnode *vp;
struct l_ustat lu;
cdev_t dev;
struct vnode *vp;
goto done;
}
stat = &(vp->v_mount->mnt_stat);
goto done;
}
stat = &(vp->v_mount->mnt_stat);
- error = VFS_STATFS(vp->v_mount, stat, curproc->p_ucred);
+ error = VFS_STATFS(vp->v_mount, stat, td->td_ucred);
vrele(vp);
if (error == 0) {
lu.f_tfree = stat->f_bfree;
vrele(vp);
if (error == 0) {
lu.f_tfree = stat->f_bfree;
int
sys_linux_setgroups16(struct linux_setgroups16_args *args)
{
int
sys_linux_setgroups16(struct linux_setgroups16_args *args)
{
- struct proc *p = curproc;
+ struct thread *td = curthread;
+ struct proc *p = td->td_proc;
struct ucred *newcred, *oldcred;
l_gid16_t linux_gidset[NGROUPS];
gid_t *bsd_gidset;
struct ucred *newcred, *oldcred;
l_gid16_t linux_gidset[NGROUPS];
gid_t *bsd_gidset;
#endif
ngrp = args->gidsetsize;
#endif
ngrp = args->gidsetsize;
+ oldcred = td->td_ucred;
/*
* cr_groups[0] holds egid. Setting the whole set from
/*
* cr_groups[0] holds egid. Setting the whole set from
+ oldcred = p->p_ucred; /* deal with threads race */
p->p_ucred = newcred;
crfree(oldcred);
error = 0;
p->p_ucred = newcred;
crfree(oldcred);
error = 0;
goto done;
/* retrieve underlying stat information and release vnode */
goto done;
/* retrieve underlying stat information and release vnode */
- error = vn_stat(vrtmp, &st, td->td_proc->p_ucred);
+ error = vn_stat(vrtmp, &st, td->td_ucred);
vput(vrtmp);
if (error)
goto done;
vput(vrtmp);
if (error)
goto done;
int
sys_exec_sys_register(struct exec_sys_register_args *uap)
{
int
sys_exec_sys_register(struct exec_sys_register_args *uap)
{
+ struct thread *td = curthread;
struct vmresident *vmres;
struct vnode *vp;
struct proc *p;
int error;
struct vmresident *vmres;
struct vnode *vp;
struct proc *p;
int error;
- p = curproc;
- if ((error = priv_check_cred(p->p_ucred, PRIV_VM_RESIDENT, 0)) != 0)
+ p = td->td_proc;
+ error = priv_check_cred(td->td_ucred, PRIV_VM_RESIDENT, 0);
+ if (error)
return(error);
get_mplock();
return(error);
get_mplock();
int
sys_exec_sys_unregister(struct exec_sys_unregister_args *uap)
{
int
sys_exec_sys_unregister(struct exec_sys_unregister_args *uap)
{
+ struct thread *td = curthread;
struct vmresident *vmres;
struct proc *p;
int error;
int id;
int count;
struct vmresident *vmres;
struct proc *p;
int error;
int id;
int count;
- p = curproc;
- if ((error = priv_check_cred(p->p_ucred, PRIV_VM_RESIDENT, 0)) != 0)
+ p = td->td_proc;
+ error = priv_check_cred(td->td_ucred, PRIV_VM_RESIDENT, 0);
+ if (error)
p->p_ucred->cr_ruidinfo = uifind(0);
p->p_ucred->cr_ngroups = 1; /* group 0 */
p->p_ucred->cr_uidinfo = uifind(0);
p->p_ucred->cr_ruidinfo = uifind(0);
p->p_ucred->cr_ngroups = 1; /* group 0 */
p->p_ucred->cr_uidinfo = uifind(0);
+ thread0.td_ucred = crhold(p->p_ucred); /* bootstrap fork1() */
/* Don't jail it */
p->p_ucred->cr_prison = NULL;
/* Don't jail it */
p->p_ucred->cr_prison = NULL;
error = copyin(aclp, &inkernacl, sizeof(struct acl));
if (error)
return(error);
error = copyin(aclp, &inkernacl, sizeof(struct acl));
if (error)
return(error);
- KKASSERT(td->td_proc);
- ucred = td->td_proc->p_ucred;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_SETACL(vp, type, &inkernacl, ucred);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_SETACL(vp, type, &inkernacl, ucred);
struct ucred *ucred;
int error;
struct ucred *ucred;
int error;
- KKASSERT(td->td_proc);
- ucred = td->td_proc->p_ucred;
error = VOP_GETACL(vp, type, &inkernelacl, ucred);
if (error == 0)
error = copyout(&inkernelacl, aclp, sizeof(struct acl));
error = VOP_GETACL(vp, type, &inkernelacl, ucred);
if (error == 0)
error = copyout(&inkernelacl, aclp, sizeof(struct acl));
struct ucred *ucred;
int error;
struct ucred *ucred;
int error;
- KKASSERT(td->td_proc);
- ucred = td->td_proc->p_ucred;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_SETACL(vp, ACL_TYPE_DEFAULT, 0, ucred);
vn_unlock(vp);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_SETACL(vp, ACL_TYPE_DEFAULT, 0, ucred);
vn_unlock(vp);
struct acl inkernelacl;
int error;
struct acl inkernelacl;
int error;
- KKASSERT(td->td_proc);
- ucred = td->td_proc->p_ucred;
error = copyin(aclp, &inkernelacl, sizeof(struct acl));
if (error)
return(error);
error = copyin(aclp, &inkernelacl, sizeof(struct acl));
if (error)
return(error);
sys_sys_checkpoint(struct sys_checkpoint_args *uap)
{
int error = 0;
sys_sys_checkpoint(struct sys_checkpoint_args *uap)
{
int error = 0;
- struct lwp *lp = curthread->td_lwp;
- struct proc *p = curthread->td_proc;
+ struct thread *td = curthread;
+ struct proc *p = td->td_proc;
struct file *fp;
/*
* Only certain groups (to reduce our security exposure). -1
* allows any group.
*/
struct file *fp;
/*
* Only certain groups (to reduce our security exposure). -1
* allows any group.
*/
- if (ckptgroup >= 0 && groupmember(ckptgroup, p->p_ucred) == 0)
+ if (ckptgroup >= 0 && groupmember(ckptgroup, td->td_ucred) == 0)
case CKPT_FREEZE:
fp = NULL;
if (uap->fd == -1 && uap->pid == (pid_t)-1)
case CKPT_FREEZE:
fp = NULL;
if (uap->fd == -1 && uap->pid == (pid_t)-1)
- error = checkpoint_signal_handler(lp);
+ error = checkpoint_signal_handler(td->td_lwp);
else if ((fp = holdfp(p->p_fd, uap->fd, FWRITE)) == NULL)
error = EBADF;
else
else if ((fp = holdfp(p->p_fd, uap->fd, FWRITE)) == NULL)
error = EBADF;
else
- error = ckpt_freeze_proc(lp, fp);
+ error = ckpt_freeze_proc(td->td_lwp, fp);
if (fp)
fdrop(fp);
break;
if (fp)
fdrop(fp);
break;
break;
}
uap->sysmsg_result = uap->retval;
break;
}
uap->sysmsg_result = uap->retval;
- error = ckpt_thaw_proc(lp, fp);
+ error = ckpt_thaw_proc(td->td_lwp, fp);
fdrop(fp);
break;
default:
fdrop(fp);
break;
default:
int
checkpoint_signal_handler(struct lwp *lp)
{
int
checkpoint_signal_handler(struct lwp *lp)
{
+ struct thread *td = lp->lwp_thread;
struct proc *p = lp->lwp_proc;
char *buf;
struct file *fp;
struct proc *p = lp->lwp_proc;
char *buf;
struct file *fp;
- buf = ckpt_expand_name(p->p_comm, p->p_ucred->cr_uid, p->p_pid);
+ buf = ckpt_expand_name(p->p_comm, td->td_ucred->cr_uid, p->p_pid);
if (buf == NULL) {
chptinuse--;
return (ENOMEM);
if (buf == NULL) {
chptinuse--;
return (ENOMEM);
log(LOG_INFO, "pid %d (%s), uid %d: checkpointing to %s\n",
p->p_pid, p->p_comm,
log(LOG_INFO, "pid %d (%s), uid %d: checkpointing to %s\n",
p->p_pid, p->p_comm,
- (p->p_ucred ? p->p_ucred->cr_uid : -1),
+ (td->td_ucred ? td->td_ucred->cr_uid : -1),
buf);
PRINTF(("ckpt handler called, using '%s'\n", buf));
buf);
PRINTF(("ckpt handler called, using '%s'\n", buf));
- error = kern_fcntl(uap->fd, uap->cmd, &dat, curproc->p_ucred);
+ error = kern_fcntl(uap->fd, uap->cmd, &dat, curthread->td_ucred);
if (error == 0) {
switch (uap->cmd) {
if (error == 0) {
switch (uap->cmd) {
sigio->sio_pgrp = pgrp;
}
sigio->sio_pgid = pgid;
sigio->sio_pgrp = pgrp;
}
sigio->sio_pgid = pgid;
- sigio->sio_ucred = crhold(curproc->p_ucred);
+ sigio->sio_ucred = crhold(curthread->td_ucred);
/* It would be convenient if p_ruid was in ucred. */
/* It would be convenient if p_ruid was in ucred. */
- sigio->sio_ruid = curproc->p_ucred->cr_ruid;
+ sigio->sio_ruid = sigio->sio_ucred->cr_ruid;
sigio->sio_myref = sigiop;
crit_enter();
*sigiop = sigio;
sigio->sio_myref = sigiop;
crit_enter();
*sigiop = sigio;
if ((fp = holdfp(p->p_fd, fd, -1)) == NULL)
return (EBADF);
if ((fp = holdfp(p->p_fd, fd, -1)) == NULL)
return (EBADF);
- error = fo_stat(fp, ub, p->p_ucred);
+ error = fo_stat(fp, ub, td->td_ucred);
fdrop(fp);
return (error);
fdrop(fp);
return (error);
if (p->p_stat == SIDL || p->p_stat == SZOMB)
return(0);
if (p->p_stat == SIDL || p->p_stat == SZOMB)
return(0);
- if (!PRISON_CHECK(info->req->td->td_proc->p_ucred, p->p_ucred) != 0)
+ if (!PRISON_CHECK(info->req->td->td_ucred, p->p_ucred) != 0)
}
if (p == NULL)
return (ESRCH);
}
if (p == NULL)
return (ESRCH);
- if (! PRISON_CHECK(curproc->p_ucred, p->p_ucred))
+ if (!PRISON_CHECK(curthread->td_ucred, p->p_ucred))
return (EACCES);
kn->kn_ptr.p_proc = p;
return (EACCES);
kn->kn_ptr.p_proc = p;
* exceed the limit. The variable nprocs is the current number of
* processes, maxproc is the limit.
*/
* exceed the limit. The variable nprocs is the current number of
* processes, maxproc is the limit.
*/
- uid = p1->p_ucred->cr_ruid;
+ uid = lp1->lwp_thread->td_ucred->cr_ruid;
if ((nprocs >= maxproc - 10 && uid != 0) || nprocs >= maxproc) {
if (ppsratecheck(&lastfail, &curfail, 1))
kprintf("maxproc limit exceeded by uid %d, please "
if ((nprocs >= maxproc - 10 && uid != 0) || nprocs >= maxproc) {
if (ppsratecheck(&lastfail, &curfail, 1))
kprintf("maxproc limit exceeded by uid %d, please "
* Increment the count of procs running with this uid. Don't allow
* a nonprivileged user to exceed their current limit.
*/
* Increment the count of procs running with this uid. Don't allow
* a nonprivileged user to exceed their current limit.
*/
- ok = chgproccnt(p1->p_ucred->cr_ruidinfo, 1,
+ ok = chgproccnt(lp1->lwp_thread->td_ucred->cr_ruidinfo, 1,
(uid != 0) ? p1->p_rlimit[RLIMIT_NPROC].rlim_cur : 0);
if (!ok) {
/*
(uid != 0) ? p1->p_rlimit[RLIMIT_NPROC].rlim_cur : 0);
if (!ok) {
/*
*/
if (p1->p_flag & P_PROFIL)
startprofclock(p2);
*/
if (p1->p_flag & P_PROFIL)
startprofclock(p2);
- p2->p_ucred = crhold(p1->p_ucred);
+ p2->p_ucred = crhold(lp1->lwp_thread->td_ucred);
KKASSERT(p2->p_lock == 0);
if (jailed(p2->p_ucred))
KKASSERT(p2->p_lock == 0);
if (jailed(p2->p_ucred))
if (td->td_proc == NULL)
return (1);
if (td->td_proc == NULL)
return (1);
- if ((pr = td->td_proc->p_ucred->cr_prison) == NULL)
+ if ((pr = td->td_ucred->cr_prison) == NULL)
return (1);
if ((ip->sa_family == AF_INET &&
return (1);
if ((ip->sa_family == AF_INET &&
if (td == NULL || td->td_proc == NULL)
return(1);
if (td == NULL || td->td_proc == NULL)
return(1);
- if ((pr = td->td_proc->p_ucred->cr_prison) == NULL)
+ if ((pr = td->td_ucred->cr_prison) == NULL)
return(1);
if ((ip->sa_family == AF_INET &&
ip4->sin_addr.s_addr == htonl(INADDR_LOOPBACK)) ||
return(1);
if ((ip->sa_family == AF_INET &&
ip4->sin_addr.s_addr == htonl(INADDR_LOOPBACK)) ||
static int
sysctl_jail_list(SYSCTL_HANDLER_ARGS)
{
static int
sysctl_jail_list(SYSCTL_HANDLER_ARGS)
{
+ struct thread *td = curthread;
struct jail_ip_storage *jip;
#ifdef INET6
struct sockaddr_in6 *jsin6;
#endif
struct sockaddr_in *jsin;
struct jail_ip_storage *jip;
#ifdef INET6
struct sockaddr_in6 *jsin6;
#endif
struct sockaddr_in *jsin;
struct prison *pr;
unsigned int jlssize, jlsused;
int count, error;
struct prison *pr;
unsigned int jlssize, jlsused;
int count, error;
char *fullpath, *freepath;
jlsused = 0;
char *fullpath, *freepath;
jlsused = 0;
- p = curthread->td_proc;
- if (jailed(p->p_ucred))
+ if (jailed(td->td_ucred))
retry:
count = prisoncount;
retry:
count = prisoncount;
count = prisoncount;
LIST_FOREACH(pr, &allprison, pr_list) {
count = prisoncount;
LIST_FOREACH(pr, &allprison, pr_list) {
- error = cache_fullpath(p, &pr->pr_root, &fullpath, &freepath);
+ error = cache_fullpath(lp->lwp_proc, &pr->pr_root,
+ &fullpath, &freepath);
if (error)
continue;
if (jlsused && jlsused < jlssize)
if (error)
continue;
if (jlsused && jlsused < jlssize)
#ifdef KTRACE
static struct ktr_header *ktrgetheader (int type);
#ifdef KTRACE
static struct ktr_header *ktrgetheader (int type);
-static void ktrwrite (struct proc *, struct ktr_header *, struct uio *);
-static int ktrcanset (struct proc *,struct proc *);
-static int ktrsetchildren (struct proc *,struct proc *,int,int, ktrace_node_t);
-static int ktrops (struct proc *,struct proc *,int,int, ktrace_node_t);
+static void ktrwrite (struct lwp *, struct ktr_header *, struct uio *);
+static int ktrcanset (struct thread *,struct proc *);
+static int ktrsetchildren (struct thread *,struct proc *,int,int, ktrace_node_t);
+static int ktrops (struct thread *,struct proc *,int,int, ktrace_node_t);
*argp++ = args[i];
kth->ktr_buf = (caddr_t)ktp;
kth->ktr_len = len;
*argp++ = args[i];
kth->ktr_buf = (caddr_t)ktp;
kth->ktr_len = len;
- ktrwrite(lp->lwp_proc, kth, NULL);
+ ktrwrite(lp, kth, NULL);
FREE(ktp, M_KTRACE);
FREE(kth, M_KTRACE);
lp->lwp_traceflag &= ~KTRFAC_ACTIVE;
FREE(ktp, M_KTRACE);
FREE(kth, M_KTRACE);
lp->lwp_traceflag &= ~KTRFAC_ACTIVE;
kth->ktr_buf = (caddr_t)&ktp;
kth->ktr_len = sizeof(struct ktr_sysret);
kth->ktr_buf = (caddr_t)&ktp;
kth->ktr_len = sizeof(struct ktr_sysret);
- ktrwrite(lp->lwp_proc, kth, NULL);
+ ktrwrite(lp, kth, NULL);
FREE(kth, M_KTRACE);
lp->lwp_traceflag &= ~KTRFAC_ACTIVE;
}
FREE(kth, M_KTRACE);
lp->lwp_traceflag &= ~KTRFAC_ACTIVE;
}
kth->ktr_len = strlen(path);
kth->ktr_buf = path;
kth->ktr_len = strlen(path);
kth->ktr_buf = path;
- ktrwrite(lp->lwp_proc, kth, NULL);
+ ktrwrite(lp, kth, NULL);
FREE(kth, M_KTRACE);
lp->lwp_traceflag &= ~KTRFAC_ACTIVE;
}
FREE(kth, M_KTRACE);
lp->lwp_traceflag &= ~KTRFAC_ACTIVE;
}
uio->uio_offset = 0;
uio->uio_rw = UIO_WRITE;
uio->uio_offset = 0;
uio->uio_rw = UIO_WRITE;
- ktrwrite(lp->lwp_proc, kth, uio);
+ ktrwrite(lp, kth, uio);
FREE(kth, M_KTRACE);
lp->lwp_traceflag &= ~KTRFAC_ACTIVE;
}
FREE(kth, M_KTRACE);
lp->lwp_traceflag &= ~KTRFAC_ACTIVE;
}
kth->ktr_buf = (caddr_t)&kp;
kth->ktr_len = sizeof (struct ktr_psig);
kth->ktr_buf = (caddr_t)&kp;
kth->ktr_len = sizeof (struct ktr_psig);
- ktrwrite(lp->lwp_proc, kth, NULL);
+ ktrwrite(lp, kth, NULL);
FREE(kth, M_KTRACE);
lp->lwp_traceflag &= ~KTRFAC_ACTIVE;
}
FREE(kth, M_KTRACE);
lp->lwp_traceflag &= ~KTRFAC_ACTIVE;
}
kth->ktr_buf = (caddr_t)&kc;
kth->ktr_len = sizeof (struct ktr_csw);
kth->ktr_buf = (caddr_t)&kc;
kth->ktr_len = sizeof (struct ktr_csw);
- ktrwrite(lp->lwp_proc, kth, NULL);
+ ktrwrite(lp, kth, NULL);
FREE(kth, M_KTRACE);
lp->lwp_traceflag &= ~KTRFAC_ACTIVE;
}
FREE(kth, M_KTRACE);
lp->lwp_traceflag &= ~KTRFAC_ACTIVE;
}
}
LIST_FOREACH(p, &pg->pg_members, p_pglist) {
if (descend)
}
LIST_FOREACH(p, &pg->pg_members, p_pglist) {
if (descend)
- ret |= ktrsetchildren(curp, p, ops, facs, tracenode);
+ ret |= ktrsetchildren(td, p, ops, facs, tracenode);
- ret |= ktrops(curp, p, ops, facs, tracenode);
+ ret |= ktrops(td, p, ops, facs, tracenode);
goto done;
}
if (descend)
goto done;
}
if (descend)
- ret |= ktrsetchildren(curp, p, ops, facs, tracenode);
+ ret |= ktrsetchildren(td, p, ops, facs, tracenode);
- ret |= ktrops(curp, p, ops, facs, tracenode);
+ ret |= ktrops(td, p, ops, facs, tracenode);
}
if (!ret)
error = EPERM;
}
if (!ret)
error = EPERM;
}
} else {
if (p->p_tracenode->kn_vp == info->tracenode->kn_vp) {
}
} else {
if (p->p_tracenode->kn_vp == info->tracenode->kn_vp) {
- if (ktrcanset(curproc, p)) {
+ if (ktrcanset(curthread, p)) {
ktrdestroy(&p->p_tracenode);
p->p_traceflag = 0;
} else {
ktrdestroy(&p->p_tracenode);
p->p_traceflag = 0;
} else {
#ifdef KTRACE
struct ktr_header *kth;
struct thread *td = curthread; /* XXX */
#ifdef KTRACE
struct ktr_header *kth;
struct thread *td = curthread; /* XXX */
- struct proc *p = td->td_proc;
caddr_t cp;
if (!KTRPOINT(td, KTR_USER))
caddr_t cp;
if (!KTRPOINT(td, KTR_USER))
kth->ktr_buf = cp;
kth->ktr_len = uap->len;
get_mplock();
kth->ktr_buf = cp;
kth->ktr_len = uap->len;
get_mplock();
- ktrwrite(p, kth, NULL);
+ ktrwrite(td->td_lwp, kth, NULL);
rel_mplock();
}
FREE(kth, M_KTRACE);
rel_mplock();
}
FREE(kth, M_KTRACE);
-ktrops(struct proc *curp, struct proc *p, int ops, int facs,
+ktrops(struct thread *td, struct proc *p, int ops, int facs,
ktrace_node_t tracenode)
{
ktrace_node_t oldnode;
ktrace_node_t tracenode)
{
ktrace_node_t oldnode;
- if (!ktrcanset(curp, p))
return (0);
if (ops == KTROP_SET) {
if ((oldnode = p->p_tracenode) != tracenode) {
return (0);
if (ops == KTROP_SET) {
if ((oldnode = p->p_tracenode) != tracenode) {
ktrdestroy(&oldnode);
}
p->p_traceflag |= facs;
ktrdestroy(&oldnode);
}
p->p_traceflag |= facs;
- if (curp->p_ucred->cr_uid == 0)
+ if (td->td_ucred->cr_uid == 0)
p->p_traceflag |= KTRFAC_ROOT;
} else {
/* KTROP_CLEAR */
p->p_traceflag |= KTRFAC_ROOT;
} else {
/* KTROP_CLEAR */
-ktrsetchildren(struct proc *curp, struct proc *top, int ops, int facs,
+ktrsetchildren(struct thread *td, struct proc *top, int ops, int facs,
ktrace_node_t tracenode)
{
struct proc *p;
ktrace_node_t tracenode)
{
struct proc *p;
- ret |= ktrops(curp, p, ops, facs, tracenode);
+ ret |= ktrops(td, p, ops, facs, tracenode);
/*
* If this process has children, descend to them next,
* otherwise do any siblings, and if done with this level,
/*
* If this process has children, descend to them next,
* otherwise do any siblings, and if done with this level,
-ktrwrite(struct proc *p, struct ktr_header *kth, struct uio *uio)
+ktrwrite(struct lwp *lp, struct ktr_header *kth, struct uio *uio)
{
struct ktrace_clear_info info;
struct uio auio;
{
struct ktrace_clear_info info;
struct uio auio;
- if (p->p_tracenode == NULL)
+ if (lp->lwp_proc->p_tracenode == NULL)
- tracenode = ktrinherit(p->p_tracenode);
+ tracenode = ktrinherit(lp->lwp_proc->p_tracenode);
auio.uio_iov = &aiov[0];
auio.uio_offset = 0;
auio.uio_segflg = UIO_SYSSPACE;
auio.uio_iov = &aiov[0];
auio.uio_offset = 0;
auio.uio_segflg = UIO_SYSSPACE;
}
vn_lock(tracenode->kn_vp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_WRITE(tracenode->kn_vp, &auio,
}
vn_lock(tracenode->kn_vp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_WRITE(tracenode->kn_vp, &auio,
- IO_UNIT | IO_APPEND, p->p_ucred);
+ IO_UNIT | IO_APPEND, lp->lwp_thread->td_ucred);
if (error == 0 && uio != NULL) {
error = VOP_WRITE(tracenode->kn_vp, uio,
if (error == 0 && uio != NULL) {
error = VOP_WRITE(tracenode->kn_vp, uio,
- IO_UNIT | IO_APPEND, p->p_ucred);
+ IO_UNIT | IO_APPEND, lp->lwp_thread->td_ucred);
}
vn_unlock(tracenode->kn_vp);
if (error) {
}
vn_unlock(tracenode->kn_vp);
if (error) {
* TODO: check groups. use caller effective gid.
*/
static int
* TODO: check groups. use caller effective gid.
*/
static int
-ktrcanset(struct proc *callp, struct proc *targetp)
+ktrcanset(struct thread *calltd, struct proc *targetp)
- struct ucred *caller = callp->p_ucred;
+ struct ucred *caller = calltd->td_ucred;
struct ucred *target = targetp->p_ucred;
if (!PRISON_CHECK(caller, target))
struct ucred *target = targetp->p_ucred;
if (!PRISON_CHECK(caller, target))
*/
int
sys_getuid(struct getuid_args *uap)
{
*/
int
sys_getuid(struct getuid_args *uap)
{
- struct proc *p = curproc;
+ struct ucred *cred = curthread->td_ucred;
- uap->sysmsg_fds[0] = p->p_ucred->cr_ruid;
+ uap->sysmsg_fds[0] = cred->cr_ruid;
#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
- uap->sysmsg_fds[1] = p->p_ucred->cr_uid;
+ uap->sysmsg_fds[1] = cred->cr_uid;
*/
int
sys_geteuid(struct geteuid_args *uap)
{
*/
int
sys_geteuid(struct geteuid_args *uap)
{
- struct proc *p = curproc;
+ struct ucred *cred = curthread->td_ucred;
- uap->sysmsg_result = p->p_ucred->cr_uid;
+ uap->sysmsg_result = cred->cr_uid;
return (0);
}
/*
* getgid()
*
return (0);
}
/*
* getgid()
*
*/
int
sys_getgid(struct getgid_args *uap)
{
*/
int
sys_getgid(struct getgid_args *uap)
{
- struct proc *p = curproc;
+ struct ucred *cred = curthread->td_ucred;
- uap->sysmsg_fds[0] = p->p_ucred->cr_rgid;
+ uap->sysmsg_fds[0] = cred->cr_rgid;
#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
- uap->sysmsg_fds[1] = p->p_ucred->cr_groups[0];
+ uap->sysmsg_fds[1] = cred->cr_groups[0];
int
sys_getegid(struct getegid_args *uap)
{
int
sys_getegid(struct getegid_args *uap)
{
- struct proc *p = curproc;
+ struct ucred *cred = curthread->td_ucred;
- uap->sysmsg_result = p->p_ucred->cr_groups[0];
+ uap->sysmsg_result = cred->cr_groups[0];
int
sys_getgroups(struct getgroups_args *uap)
{
int
sys_getgroups(struct getgroups_args *uap)
{
- struct proc *p = curproc;
struct ucred *cr;
u_int ngrp;
int error;
struct ucred *cr;
u_int ngrp;
int error;
+ cr = curthread->td_ucred;
if ((ngrp = uap->gidsetsize) == 0) {
uap->sysmsg_result = cr->cr_ngroups;
return (0);
if ((ngrp = uap->gidsetsize) == 0) {
uap->sysmsg_result = cr->cr_ngroups;
return (0);
cr = p->p_ucred;
euid = uap->euid;
if (euid != cr->cr_ruid && /* allow seteuid(getuid()) */
euid != cr->cr_svuid && /* allow seteuid(saved uid) */
(error = priv_check_cred(cr, PRIV_CRED_SETEUID, 0))) {
cr = p->p_ucred;
euid = uap->euid;
if (euid != cr->cr_ruid && /* allow seteuid(getuid()) */
euid != cr->cr_svuid && /* allow seteuid(saved uid) */
(error = priv_check_cred(cr, PRIV_CRED_SETEUID, 0))) {
* not see our changes.
*/
if (cr->cr_uid != euid) {
* not see our changes.
*/
if (cr->cr_uid != euid) {
change_euid(euid);
setsugid();
change_euid(euid);
setsugid();
*/
int
sys_getresgid(struct getresgid_args *uap)
{
*/
int
sys_getresgid(struct getresgid_args *uap)
{
- struct proc *p = curproc;
struct ucred *cr;
int error1 = 0, error2 = 0, error3 = 0;
struct ucred *cr;
int error1 = 0, error2 = 0, error3 = 0;
- get_mplock();
- cr = p->p_ucred;
+ cr = curthread->td_ucred;
- error1 = copyout((caddr_t)&cr->cr_rgid,
- (caddr_t)uap->rgid, sizeof(cr->cr_rgid));
+ error1 = copyout(&cr->cr_rgid, uap->rgid,
+ sizeof(cr->cr_rgid));
- error2 = copyout((caddr_t)&cr->cr_groups[0],
- (caddr_t)uap->egid, sizeof(cr->cr_groups[0]));
+ error2 = copyout(&cr->cr_groups[0], uap->egid,
+ sizeof(cr->cr_groups[0]));
- error3 = copyout((caddr_t)&cr->cr_svgid,
- (caddr_t)uap->sgid, sizeof(cr->cr_svgid));
- rel_mplock();
+ error3 = copyout(&cr->cr_svgid, uap->sgid,
+ sizeof(cr->cr_svgid));
return error1 ? error1 : (error2 ? error2 : error3);
}
return error1 ? error1 : (error2 ? error2 : error3);
}
int
priv_check(struct thread *td, int priv)
{
int
priv_check(struct thread *td, int priv)
{
- struct proc *p = td->td_proc;
-
- if (p != NULL) {
- return priv_check_cred(p->p_ucred, priv, 0);
- } else {
- return (0);
- }
+ if (td->td_lwp != NULL)
+ return priv_check_cred(td->td_ucred, priv, 0);
+ return (0);
int
sys_setlogin(struct setlogin_args *uap)
{
int
sys_setlogin(struct setlogin_args *uap)
{
- struct proc *p = curproc;
+ struct thread *td = curthread;
+ struct proc *p;
+ struct ucred *cred;
char buf[MAXLOGNAME];
int error;
char buf[MAXLOGNAME];
int error;
- KKASSERT(p != NULL);
- if ((error = priv_check_cred(p->p_ucred, PRIV_PROC_SETLOGIN, 0)))
+ cred = td->td_ucred;
+ p = td->td_proc;
+
+ if ((error = priv_check_cred(cred, PRIV_PROC_SETLOGIN, 0)))
return (error);
bzero(buf, sizeof(buf));
error = copyinstr(uap->namebuf, buf, sizeof(buf), NULL);
return (error);
bzero(buf, sizeof(buf));
error = copyinstr(uap->namebuf, buf, sizeof(buf), NULL);
struct proc *p = curproc;
struct lwp *lp;
struct rtprio rtp;
struct proc *p = curproc;
struct lwp *lp;
struct rtprio rtp;
- struct ucred *cr = p->p_ucred;
+ struct ucred *cr = curthread->td_ucred;
int error;
error = copyin(uap->rtp, &rtp, sizeof(struct rtprio));
int error;
error = copyin(uap->rtp, &rtp, sizeof(struct rtprio));
struct proc *curp = curproc;
struct proc *p;
struct lwp *lp;
struct proc *curp = curproc;
struct proc *p;
struct lwp *lp;
- struct ucred *cr = curp->p_ucred;
+ struct ucred *cr = curthread->td_ucred;
struct rtprio rtp;
int error;
struct rtprio rtp;
int error;
/* Most likely only root can write */
if (!(oid->oid_kind & CTLFLAG_ANYBODY) && req->newptr && p &&
/* Most likely only root can write */
if (!(oid->oid_kind & CTLFLAG_ANYBODY) && req->newptr && p &&
- (error = priv_check_cred(p->p_ucred,
+ (error = priv_check_cred(td->td_ucred,
(oid->oid_kind & CTLFLAG_PRISON) ? PRIV_SYSCTL_WRITEJAIL :
PRIV_SYSCTL_WRITE, 0)))
return (error);
(oid->oid_kind & CTLFLAG_PRISON) ? PRIV_SYSCTL_WRITEJAIL :
PRIV_SYSCTL_WRITE, 0)))
return (error);
{
char name[MAXVARSYM_NAME];
char *buf;
{
char name[MAXVARSYM_NAME];
char *buf;
+ td = curthread;
+ lp = td->td_lwp;
+ p = lp ? lp->lwp_proc : NULL;
if ((error = copyinstr(uap->name, name, sizeof(name), NULL)) != 0)
goto done2;
if ((error = copyinstr(uap->name, name, sizeof(name), NULL)) != 0)
goto done2;
switch(uap->level) {
case VARSYM_SYS:
switch(uap->level) {
case VARSYM_SYS:
- if (p != NULL && p->p_ucred->cr_prison != NULL)
+ if (lp != NULL && td->td_ucred->cr_prison != NULL)
uap->level = VARSYM_PRISON;
case VARSYM_PRISON:
uap->level = VARSYM_PRISON;
case VARSYM_PRISON:
- if (p != NULL &&
- (error = priv_check_cred(p->p_ucred, PRIV_VARSYM_SYS, 0)) != 0)
+ if (lp != NULL &&
+ (error = priv_check_cred(td->td_ucred, PRIV_VARSYM_SYS, 0)) != 0)
break;
/* fall through */
case VARSYM_USER:
break;
/* fall through */
case VARSYM_USER:
{
struct varsymset *vss;
struct varsyment *ve;
{
struct varsymset *vss;
struct varsyment *ve;
int i;
int error;
int bytes;
int i;
int error;
int bytes;
/*
* Figure out the varsym set.
*/
/*
* Figure out the varsym set.
*/
+ td = curthread;
+ lp = td->td_lwp;
+ p = lp ? lp->lwp_proc : NULL;
+
vss = NULL;
switch (uap->level) {
vss = NULL;
switch (uap->level) {
vss = &p->p_varsymset;
break;
case VARSYM_USER:
vss = &p->p_varsymset;
break;
case VARSYM_USER:
- if (p)
- vss = &p->p_ucred->cr_uidinfo->ui_varsymset;
+ if (lp)
+ vss = &td->td_ucred->cr_uidinfo->ui_varsymset;
break;
case VARSYM_SYS:
vss = &varsymset_sys;
break;
case VARSYM_PRISON:
break;
case VARSYM_SYS:
vss = &varsymset_sys;
break;
case VARSYM_PRISON:
- if (p != NULL && p->p_ucred->cr_prison != NULL)
- vss = &p->p_ucred->cr_prison->pr_varsymset;
+ if (lp && td->td_ucred->cr_prison)
+ vss = &td->td_ucred->cr_prison->pr_varsymset;
break;
}
if (vss == NULL) {
break;
}
if (vss == NULL) {
varsym_t
varsymfind(int mask, const char *name, int namelen)
{
varsym_t
varsymfind(int mask, const char *name, int namelen)
{
- struct proc *p = curproc;
struct varsyment *ve = NULL;
struct varsymset *vss = NULL;
struct varsyment *ve = NULL;
struct varsymset *vss = NULL;
+ struct thread *td;
+ struct lwp *lp;
+ struct proc *p;
- if ((mask & (VARSYM_PROC_MASK|VARSYM_USER_MASK)) && p != NULL) {
+ td = curthread;
+ lp = td->td_lwp;
+ p = lp ? lp->lwp_proc : NULL;
+
+ if ((mask & (VARSYM_PROC_MASK|VARSYM_USER_MASK)) && lp != NULL) {
if (mask & VARSYM_PROC_MASK) {
vsslock(&vss, &p->p_varsymset);
ve = varsymlookup(vss, name, namelen);
}
if (ve == NULL && (mask & VARSYM_USER_MASK)) {
if (mask & VARSYM_PROC_MASK) {
vsslock(&vss, &p->p_varsymset);
ve = varsymlookup(vss, name, namelen);
}
if (ve == NULL && (mask & VARSYM_USER_MASK)) {
- vsslock(&vss, &p->p_ucred->cr_uidinfo->ui_varsymset);
+ vsslock(&vss, &td->td_ucred->cr_uidinfo->ui_varsymset);
ve = varsymlookup(vss, name, namelen);
}
}
if (ve == NULL && (mask & VARSYM_SYS_MASK)) {
ve = varsymlookup(vss, name, namelen);
}
}
if (ve == NULL && (mask & VARSYM_SYS_MASK)) {
- if (p != NULL && p->p_ucred->cr_prison) {
- vsslock(&vss, &p->p_ucred->cr_prison->pr_varsymset);
+ if (lp != NULL && td->td_ucred->cr_prison) {
+ vsslock(&vss, &td->td_ucred->cr_prison->pr_varsymset);
ve = varsymlookup(vss, name, namelen);
} else {
vsslock(&vss, &varsymset_sys);
ve = varsymlookup(vss, name, namelen);
} else {
vsslock(&vss, &varsymset_sys);
{
struct varsymset *vss = NULL;
struct varsyment *ve;
{
struct varsymset *vss = NULL;
struct varsyment *ve;
- struct proc *p = curproc;
+ struct thread *td;
+ struct proc *p;
+ struct lwp *lp;
varsym_t sym;
int namelen = strlen(name);
int datalen;
int error;
varsym_t sym;
int namelen = strlen(name);
int datalen;
int error;
+ td = curthread;
+ lp = td->td_lwp;
+ p = lp ? lp->lwp_proc : NULL;
+
switch(level) {
case VARSYM_PROC:
if (p)
vss = &p->p_varsymset;
break;
case VARSYM_USER:
switch(level) {
case VARSYM_PROC:
if (p)
vss = &p->p_varsymset;
break;
case VARSYM_USER:
- if (p)
- vss = &p->p_ucred->cr_uidinfo->ui_varsymset;
+ if (lp)
+ vss = &td->td_ucred->cr_uidinfo->ui_varsymset;
break;
case VARSYM_SYS:
vss = &varsymset_sys;
break;
case VARSYM_PRISON:
break;
case VARSYM_SYS:
vss = &varsymset_sys;
break;
case VARSYM_PRISON:
- if (p != NULL && p->p_ucred->cr_prison != NULL)
- vss = &p->p_ucred->cr_prison->pr_varsymset;
+ if (lp && td->td_ucred->cr_prison)
+ vss = &td->td_ucred->cr_prison->pr_varsymset;
break;
}
if (vss == NULL) {
break;
}
if (vss == NULL) {
-caps_load_ccr(caps_kinfo_t caps, caps_kmsg_t msg, struct proc *p,
- void *udata, int ubytes)
+caps_load_ccr(caps_kinfo_t caps, caps_kmsg_t msg, struct lwp *lp,
+ void *udata, int ubytes)
- int i;
- struct ucred *cr = p->p_ucred;
+ struct ucred *cr = lp ? lp->lwp_thread->td_ucred : proc0.p_ucred;
/*
* replace km_mcaps with new VM state, return the old km_mcaps. The
/*
* replace km_mcaps with new VM state, return the old km_mcaps. The
msg->km_mcaps = caps;
xio_init_ubuf(&msg->km_xio, udata, ubytes, XIOF_READ);
msg->km_mcaps = caps;
xio_init_ubuf(&msg->km_xio, udata, ubytes, XIOF_READ);
- msg->km_ccr.pid = p ? p->p_pid : -1;
+ msg->km_ccr.pid = lp ? lp->lwp_proc->p_pid : -1;
msg->km_ccr.uid = cr->cr_ruid;
msg->km_ccr.euid = cr->cr_uid;
msg->km_ccr.gid = cr->cr_rgid;
msg->km_ccr.uid = cr->cr_ruid;
msg->km_ccr.euid = cr->cr_uid;
msg->km_ccr.gid = cr->cr_rgid;
static void
caps_term(caps_kinfo_t caps, int flags, caps_kinfo_t cflush)
{
static void
caps_term(caps_kinfo_t caps, int flags, caps_kinfo_t cflush)
{
+ struct thread *td = curthread;
struct caps_kinfo **scan;
caps_kmsg_t msg;
struct caps_kinfo **scan;
caps_kmsg_t msg;
switch(msg->km_state) {
case CAPMS_REQUEST:
case CAPMS_REQUEST_RETRY:
switch(msg->km_state) {
case CAPMS_REQUEST:
case CAPMS_REQUEST_RETRY:
- rcaps = caps_load_ccr(caps, msg, curproc, NULL, 0);
+ rcaps = caps_load_ccr(caps, msg, td->td_lwp, NULL, 0);
if (rcaps->ci_flags & CAPKF_CLOSED) {
/*
* can't reply, if we never read the message (its on
if (rcaps->ci_flags & CAPKF_CLOSED) {
/*
* can't reply, if we never read the message (its on
break;
case CAPMS_REPLY:
case CAPMS_REPLY_RETRY:
break;
case CAPMS_REPLY:
case CAPMS_REPLY_RETRY:
- rcaps = caps_load_ccr(caps, msg, curproc, NULL, 0);
+ rcaps = caps_load_ccr(caps, msg, td->td_lwp, NULL, 0);
if (caps == rcaps || (rcaps->ci_flags & CAPKF_CLOSED)) {
caps_free_msg(msg); /* degenerate disposal case */
caps_drop(rcaps);
if (caps == rcaps || (rcaps->ci_flags & CAPKF_CLOSED)) {
caps_free_msg(msg); /* degenerate disposal case */
caps_drop(rcaps);
int
sys_caps_sys_service(struct caps_sys_service_args *uap)
{
int
sys_caps_sys_service(struct caps_sys_service_args *uap)
{
- struct ucred *cred = curproc->p_ucred;
+ struct ucred *cred = curthread->td_ucred;
char name[CAPS_MAXNAMELEN];
caps_kinfo_t caps;
size_t len;
char name[CAPS_MAXNAMELEN];
caps_kinfo_t caps;
size_t len;
int
sys_caps_sys_client(struct caps_sys_client_args *uap)
{
int
sys_caps_sys_client(struct caps_sys_client_args *uap)
{
- struct ucred *cred = curproc->p_ucred;
+ struct ucred *cred = curthread->td_ucred;
char name[CAPS_MAXNAMELEN];
caps_kinfo_t caps;
size_t len;
char name[CAPS_MAXNAMELEN];
caps_kinfo_t caps;
size_t len;
int
sys_caps_sys_close(struct caps_sys_close_args *uap)
{
int
sys_caps_sys_close(struct caps_sys_close_args *uap)
{
+ struct thread *td = curthread;
caps_kinfo_t caps;
int error;
get_mplock();
caps_kinfo_t caps;
int error;
get_mplock();
- if ((caps = caps_find_id(curthread, uap->portid)) != NULL) {
+ if ((caps = caps_find_id(td, uap->portid)) != NULL) {
caps_term(caps, CAPKF_TDLIST|CAPKF_HLIST|CAPKF_FLUSH|CAPKF_RCAPS,
NULL);
caps_drop(caps);
caps_term(caps, CAPKF_TDLIST|CAPKF_HLIST|CAPKF_FLUSH|CAPKF_RCAPS,
NULL);
caps_drop(caps);
int
sys_caps_sys_setgen(struct caps_sys_setgen_args *uap)
{
int
sys_caps_sys_setgen(struct caps_sys_setgen_args *uap)
{
+ struct thread *td = curthread;
caps_kinfo_t caps;
int error;
get_mplock();
caps_kinfo_t caps;
int error;
get_mplock();
- if ((caps = caps_find_id(curthread, uap->portid)) != NULL) {
+ if ((caps = caps_find_id(td, uap->portid)) != NULL) {
if (caps->ci_type == CAPT_FORKED) {
error = ENOTCONN;
} else {
if (caps->ci_type == CAPT_FORKED) {
error = ENOTCONN;
} else {
int
sys_caps_sys_getgen(struct caps_sys_getgen_args *uap)
{
int
sys_caps_sys_getgen(struct caps_sys_getgen_args *uap)
{
+ struct thread *td = curthread;
caps_kinfo_t caps;
int error;
get_mplock();
caps_kinfo_t caps;
int error;
get_mplock();
- if ((caps = caps_find_id(curthread, uap->portid)) != NULL) {
+ if ((caps = caps_find_id(td, uap->portid)) != NULL) {
if (caps->ci_type == CAPT_FORKED) {
error = ENOTCONN;
} else if (caps->ci_rcaps == NULL) {
if (caps->ci_type == CAPT_FORKED) {
error = ENOTCONN;
} else if (caps->ci_rcaps == NULL) {
int
sys_caps_sys_put(struct caps_sys_put_args *uap)
{
int
sys_caps_sys_put(struct caps_sys_put_args *uap)
{
+ struct thread *td = curthread;
caps_kinfo_t caps;
caps_kmsg_t msg;
caps_kinfo_t caps;
caps_kmsg_t msg;
- struct proc *p = curproc;
int error;
if (uap->msgsize < 0)
return(EINVAL);
get_mplock();
int error;
if (uap->msgsize < 0)
return(EINVAL);
get_mplock();
- if ((caps = caps_find_id(curthread, uap->portid)) == NULL) {
+ if ((caps = caps_find_id(td, uap->portid)) == NULL) {
error = EINVAL;
goto done;
}
error = EINVAL;
goto done;
}
* new message, load_ccr returns NULL. hold rcaps for put_msg
*/
error = 0;
* new message, load_ccr returns NULL. hold rcaps for put_msg
*/
error = 0;
- caps_load_ccr(caps, msg, p, uap->msg, uap->msgsize);
+ caps_load_ccr(caps, msg, td->td_lwp, uap->msg, uap->msgsize);
caps_hold(caps->ci_rcaps);
++caps->ci_cmsgcount;
caps_put_msg(caps->ci_rcaps, msg, CAPMS_REQUEST); /* drops rcaps */
caps_hold(caps->ci_rcaps);
++caps->ci_cmsgcount;
caps_put_msg(caps->ci_rcaps, msg, CAPMS_REQUEST); /* drops rcaps */
int
sys_caps_sys_reply(struct caps_sys_reply_args *uap)
{
int
sys_caps_sys_reply(struct caps_sys_reply_args *uap)
{
+ struct thread *td = curthread;
caps_kinfo_t caps;
caps_kinfo_t rcaps;
caps_kmsg_t msg;
caps_kinfo_t caps;
caps_kinfo_t rcaps;
caps_kmsg_t msg;
int error;
if (uap->msgsize < 0)
return(EINVAL);
get_mplock();
int error;
if (uap->msgsize < 0)
return(EINVAL);
get_mplock();
- if ((caps = caps_find_id(curthread, uap->portid)) == NULL) {
+ if ((caps = caps_find_id(td, uap->portid)) == NULL) {
error = EINVAL;
goto done;
}
error = EINVAL;
goto done;
}
*/
error = 0;
caps_dequeue_msg(caps, msg);
*/
error = 0;
caps_dequeue_msg(caps, msg);
if (msg->km_mcaps->ci_flags & CAPKF_CLOSED) {
if (msg->km_mcaps->ci_flags & CAPKF_CLOSED) {
- caps_drop(caps_load_ccr(caps, msg, p, NULL, 0));
+ caps_drop(caps_load_ccr(caps, msg, td->td_lwp, NULL, 0));
caps_hold(caps); /* ref for message */
caps_put_msg(caps, msg, CAPMS_DISPOSE);
} else {
caps_hold(caps); /* ref for message */
caps_put_msg(caps, msg, CAPMS_DISPOSE);
} else {
- rcaps = caps_load_ccr(caps, msg, p, uap->msg, uap->msgsize);
+ rcaps = caps_load_ccr(caps, msg, td->td_lwp, uap->msg, uap->msgsize);
caps_put_msg(rcaps, msg, CAPMS_REPLY);
}
}
caps_put_msg(rcaps, msg, CAPMS_REPLY);
}
}
int
sys_caps_sys_get(struct caps_sys_get_args *uap)
{
int
sys_caps_sys_get(struct caps_sys_get_args *uap)
{
+ struct thread *td = curthread;
caps_kinfo_t caps;
caps_kmsg_t msg;
int error;
caps_kinfo_t caps;
caps_kmsg_t msg;
int error;
return(EINVAL);
get_mplock();
return(EINVAL);
get_mplock();
- if ((caps = caps_find_id(curthread, uap->portid)) != NULL) {
+ if ((caps = caps_find_id(td, uap->portid)) != NULL) {
if (caps->ci_type == CAPT_FORKED) {
error = ENOTCONN;
} else if ((msg = TAILQ_FIRST(&caps->ci_msgpendq)) == NULL) {
if (caps->ci_type == CAPT_FORKED) {
error = ENOTCONN;
} else if ((msg = TAILQ_FIRST(&caps->ci_msgpendq)) == NULL) {
int
sys_caps_sys_wait(struct caps_sys_wait_args *uap)
{
int
sys_caps_sys_wait(struct caps_sys_wait_args *uap)
{
+ struct thread *td = curthread;
caps_kinfo_t caps;
caps_kmsg_t msg;
int error;
caps_kinfo_t caps;
caps_kmsg_t msg;
int error;
return(EINVAL);
get_mplock();
return(EINVAL);
get_mplock();
- if ((caps = caps_find_id(curthread, uap->portid)) != NULL) {
+ if ((caps = caps_find_id(td, uap->portid)) != NULL) {
if (caps->ci_type == CAPT_FORKED) {
error = ENOTCONN;
} else {
if (caps->ci_type == CAPT_FORKED) {
error = ENOTCONN;
} else {
caps_process_msg(caps_kinfo_t caps, caps_kmsg_t msg,
struct caps_sys_get_args *uap)
{
caps_process_msg(caps_kinfo_t caps, caps_kmsg_t msg,
struct caps_sys_get_args *uap)
{
+ struct thread *td = curthread;
int error = 0;
int msgsize;
caps_kinfo_t rcaps;
int error = 0;
int msgsize;
caps_kinfo_t rcaps;
case CAPMS_REPLY:
case CAPMS_REPLY_RETRY:
--caps->ci_cmsgcount;
case CAPMS_REPLY:
case CAPMS_REPLY_RETRY:
--caps->ci_cmsgcount;
- rcaps = caps_load_ccr(caps, msg, curproc, NULL, 0);
+ rcaps = caps_load_ccr(caps, msg, td->td_lwp, NULL, 0);
if (caps == rcaps || (rcaps->ci_flags & CAPKF_CLOSED)) {
/* degenerate disposal case */
caps_free_msg(msg);
if (caps == rcaps || (rcaps->ci_flags & CAPKF_CLOSED)) {
/* degenerate disposal case */
caps_free_msg(msg);
kern_caps_sys_service(const char *name, uid_t uid, gid_t gid,
struct ucred *cred, int flags, int *error)
{
kern_caps_sys_service(const char *name, uid_t uid, gid_t gid,
struct ucred *cred, int flags, int *error)
{
+ struct thread *td = curthread;
caps_kinfo_t caps;
int len;
caps_kinfo_t caps;
int len;
/*
* Create the service
*/
/*
* Create the service
*/
- caps = caps_alloc(curthread, name, len,
+ caps = caps_alloc(td, name, len,
uid, gid, flags & CAPF_UFLAGS, CAPT_SERVICE);
wakeup(&caps_waitsvc);
return(caps);
uid, gid, flags & CAPF_UFLAGS, CAPT_SERVICE);
wakeup(&caps_waitsvc);
return(caps);
kern_caps_sys_client(const char *name, uid_t uid, gid_t gid,
struct ucred *cred, int flags, int *error)
{
kern_caps_sys_client(const char *name, uid_t uid, gid_t gid,
struct ucred *cred, int flags, int *error)
{
+ struct thread *td = curthread;
caps_kinfo_t caps, rcaps;
int len;
caps_kinfo_t caps, rcaps;
int len;
/*
* Allocate the client side and connect to the server
*/
/*
* Allocate the client side and connect to the server
*/
- caps = caps_alloc(curthread, name, len,
+ caps = caps_alloc(td, name, len,
uid, gid, flags & CAPF_UFLAGS, CAPT_CLIENT);
caps->ci_rcaps = rcaps;
caps->ci_flags |= CAPKF_RCAPS;
uid, gid, flags & CAPF_UFLAGS, CAPT_CLIENT);
caps->ci_rcaps = rcaps;
caps->ci_flags |= CAPKF_RCAPS;
fp = holdfp(p->p_fd, fd, FREAD|FWRITE);
if (fp == NULL)
fp = holdfp(p->p_fd, fd, FREAD|FWRITE);
if (fp == NULL)
syscallarg(mode_t) mode;
syscallarg(struct mq_attr) attr;
} */
syscallarg(mode_t) mode;
syscallarg(struct mq_attr) attr;
} */
- struct proc *p = curproc;
+ struct thread *td = curthread;
+ struct proc *p = td->td_proc;
struct mqueue *mq, *mq_new = NULL;
file_t *fp;
char *name;
struct mqueue *mq, *mq_new = NULL;
file_t *fp;
char *name;
/* Store mode and effective UID with GID */
mq_new->mq_mode = ((SCARG(uap, mode) &
~p->p_fd->fd_cmask) & ALLPERMS) & ~S_ISTXT;
/* Store mode and effective UID with GID */
mq_new->mq_mode = ((SCARG(uap, mode) &
~p->p_fd->fd_cmask) & ALLPERMS) & ~S_ISTXT;
- mq_new->mq_euid = curproc->p_ucred->cr_uid;
- mq_new->mq_egid = curproc->p_ucred->cr_svgid;
+ mq_new->mq_euid = td->td_ucred->cr_uid;
+ mq_new->mq_egid = td->td_ucred->cr_svgid;
}
/* Allocate file structure and descriptor */
}
/* Allocate file structure and descriptor */
acc_mode |= VWRITE;
}
if (vaccess(VNON, mq->mq_mode, mq->mq_euid, mq->mq_egid,
acc_mode |= VWRITE;
}
if (vaccess(VNON, mq->mq_mode, mq->mq_euid, mq->mq_egid,
- acc_mode, curproc->p_ucred)) {
+ acc_mode, td->td_ucred)) {
error = EACCES;
goto exit;
error = EACCES;
goto exit;
/* {
syscallarg(const char *) name;
} */
/* {
syscallarg(const char *) name;
} */
+ struct thread *td = curthread;
struct mqueue *mq;
char *name;
int error, refcnt = 0;
struct mqueue *mq;
char *name;
int error, refcnt = 0;
}
/* Check the permissions */
}
/* Check the permissions */
- if (curproc->p_ucred->cr_uid != mq->mq_euid &&
- priv_check(curthread, PRIV_ROOT) != 0) {
+ if (td->td_ucred->cr_uid != mq->mq_euid &&
+ priv_check(td, PRIV_ROOT) != 0) {
lockmgr(&mq->mq_mtx, LK_RELEASE);
error = EACCES;
goto error;
lockmgr(&mq->mq_mtx, LK_RELEASE);
error = EACCES;
goto error;
int
sys_msgsys(struct msgsys_args *uap)
{
int
sys_msgsys(struct msgsys_args *uap)
{
- struct proc *p = curproc;
+ struct thread *td = curthread;
unsigned int which = (unsigned int)uap->which;
int error;
unsigned int which = (unsigned int)uap->which;
int error;
- if (!jail_sysvipc_allowed && p->p_ucred->cr_prison != NULL)
+ if (!jail_sysvipc_allowed && td->td_ucred->cr_prison != NULL)
return (ENOSYS);
if (which >= sizeof(msgcalls)/sizeof(msgcalls[0]))
return (ENOSYS);
if (which >= sizeof(msgcalls)/sizeof(msgcalls[0]))
kprintf("call to msgctl(%d, %d, 0x%x)\n", msqid, cmd, user_msqptr);
#endif
kprintf("call to msgctl(%d, %d, 0x%x)\n", msqid, cmd, user_msqptr);
#endif
- if (!jail_sysvipc_allowed && p->p_ucred->cr_prison != NULL)
+ if (!jail_sysvipc_allowed && td->td_ucred->cr_prison != NULL)
return (ENOSYS);
get_mplock();
return (ENOSYS);
get_mplock();
int
sys_msgget(struct msgget_args *uap)
{
int
sys_msgget(struct msgget_args *uap)
{
- struct proc *p = curproc;
+ struct thread *td = curthread;
int msqid, eval;
int key = uap->key;
int msgflg = uap->msgflg;
int msqid, eval;
int key = uap->key;
int msgflg = uap->msgflg;
- struct ucred *cred = p->p_ucred;
+ struct ucred *cred = td->td_ucred;
struct msqid_ds *msqptr = NULL;
#ifdef MSG_DEBUG_OK
kprintf("msgget(0x%x, 0%o)\n", key, msgflg);
#endif
struct msqid_ds *msqptr = NULL;
#ifdef MSG_DEBUG_OK
kprintf("msgget(0x%x, 0%o)\n", key, msgflg);
#endif
- if (!jail_sysvipc_allowed && p->p_ucred->cr_prison != NULL)
+ if (!jail_sysvipc_allowed && cred->cr_prison != NULL)
return (ENOSYS);
eval = 0;
return (ENOSYS);
eval = 0;
eval = EEXIST;
goto done;
}
eval = EEXIST;
goto done;
}
- if ((eval = ipcperm(p, &msqptr->msg_perm, msgflg & 0700 ))) {
+ if ((eval = ipcperm(td->td_proc, &msqptr->msg_perm, msgflg & 0700 ))) {
#ifdef MSG_DEBUG_OK
kprintf("requester doesn't have 0%o access\n",
msgflg & 0700);
#ifdef MSG_DEBUG_OK
kprintf("requester doesn't have 0%o access\n",
msgflg & 0700);
int
sys_msgsnd(struct msgsnd_args *uap)
{
int
sys_msgsnd(struct msgsnd_args *uap)
{
- struct proc *p = curproc;
+ struct thread *td = curthread;
int msqid = uap->msqid;
void *user_msgp = uap->msgp;
size_t msgsz = uap->msgsz;
int msqid = uap->msqid;
void *user_msgp = uap->msgp;
size_t msgsz = uap->msgsz;
- if (!jail_sysvipc_allowed && p->p_ucred->cr_prison != NULL)
+ if (!jail_sysvipc_allowed && td->td_ucred->cr_prison != NULL)
return (ENOSYS);
get_mplock();
return (ENOSYS);
get_mplock();
- if ((eval = ipcperm(p, &msqptr->msg_perm, IPC_W))) {
+ if ((eval = ipcperm(td->td_proc, &msqptr->msg_perm, IPC_W))) {
#ifdef MSG_DEBUG_OK
kprintf("requester doesn't have write access\n");
#endif
#ifdef MSG_DEBUG_OK
kprintf("requester doesn't have write access\n");
#endif
msqptr->msg_cbytes += msghdr->msg_ts;
msqptr->msg_qnum++;
msqptr->msg_cbytes += msghdr->msg_ts;
msqptr->msg_qnum++;
- msqptr->msg_lspid = p->p_pid;
+ msqptr->msg_lspid = td->td_proc->p_pid;
msqptr->msg_stime = time_second;
wakeup((caddr_t)msqptr);
msqptr->msg_stime = time_second;
wakeup((caddr_t)msqptr);
int
sys_msgrcv(struct msgrcv_args *uap)
{
int
sys_msgrcv(struct msgrcv_args *uap)
{
- struct proc *p = curproc;
+ struct thread *td = curthread;
int msqid = uap->msqid;
void *user_msgp = uap->msgp;
size_t msgsz = uap->msgsz;
int msqid = uap->msqid;
void *user_msgp = uap->msgp;
size_t msgsz = uap->msgsz;
msgsz, msgtyp, msgflg);
#endif
msgsz, msgtyp, msgflg);
#endif
- if (!jail_sysvipc_allowed && p->p_ucred->cr_prison != NULL)
+ if (!jail_sysvipc_allowed && td->td_ucred->cr_prison != NULL)
return (ENOSYS);
get_mplock();
return (ENOSYS);
get_mplock();
- if ((eval = ipcperm(p, &msqptr->msg_perm, IPC_R))) {
+ if ((eval = ipcperm(td->td_proc, &msqptr->msg_perm, IPC_R))) {
#ifdef MSG_DEBUG_OK
kprintf("requester doesn't have read access\n");
#endif
#ifdef MSG_DEBUG_OK
kprintf("requester doesn't have read access\n");
#endif
msqptr->msg_cbytes -= msghdr->msg_ts;
msqptr->msg_qnum--;
msqptr->msg_cbytes -= msghdr->msg_ts;
msqptr->msg_qnum--;
- msqptr->msg_lrpid = p->p_pid;
+ msqptr->msg_lrpid = td->td_proc->p_pid;
msqptr->msg_rtime = time_second;
/*
msqptr->msg_rtime = time_second;
/*
int
sys_semsys(struct semsys_args *uap)
{
int
sys_semsys(struct semsys_args *uap)
{
- struct proc *p = curproc;
+ struct thread *td = curthread;
unsigned int which = (unsigned int)uap->which;
int error;
unsigned int which = (unsigned int)uap->which;
int error;
- if (!jail_sysvipc_allowed && p->p_ucred->cr_prison != NULL)
+ if (!jail_sysvipc_allowed && td->td_ucred->cr_prison != NULL)
return (ENOSYS);
if (which >= sizeof(semcalls)/sizeof(semcalls[0]))
return (ENOSYS);
if (which >= sizeof(semcalls)/sizeof(semcalls[0]))
int
sys___semctl(struct __semctl_args *uap)
{
int
sys___semctl(struct __semctl_args *uap)
{
- struct proc *p = curproc;
+ struct thread *td = curthread;
int semid = uap->semid;
int semnum = uap->semnum;
int cmd = uap->cmd;
union semun *arg = uap->arg;
union semun real_arg;
int semid = uap->semid;
int semnum = uap->semnum;
int cmd = uap->cmd;
union semun *arg = uap->arg;
union semun real_arg;
- struct ucred *cred = p->p_ucred;
+ struct ucred *cred = td->td_ucred;
int i, rval, eval;
struct semid_ds sbuf;
struct semid_ds *semaptr;
int i, rval, eval;
struct semid_ds sbuf;
struct semid_ds *semaptr;
kprintf("call to semctl(%d, %d, %d, 0x%x)\n", semid, semnum, cmd, arg);
#endif
kprintf("call to semctl(%d, %d, %d, 0x%x)\n", semid, semnum, cmd, arg);
#endif
- if (!jail_sysvipc_allowed && p->p_ucred->cr_prison != NULL)
+ if (!jail_sysvipc_allowed && cred->cr_prison != NULL)
return (ENOSYS);
semid = IPCID_TO_IX(semid);
return (ENOSYS);
semid = IPCID_TO_IX(semid);
switch (cmd) {
case IPC_RMID:
switch (cmd) {
case IPC_RMID:
- if ((eval = ipcperm(p, &semaptr->sem_perm, IPC_M)) != 0)
+ if ((eval = ipcperm(td->td_proc, &semaptr->sem_perm, IPC_M)) != 0)
break;
semaptr->sem_perm.cuid = cred->cr_uid;
semaptr->sem_perm.uid = cred->cr_uid;
break;
semaptr->sem_perm.cuid = cred->cr_uid;
semaptr->sem_perm.uid = cred->cr_uid;
- if ((eval = ipcperm(p, &semaptr->sem_perm, IPC_M)) != 0)
+ eval = ipcperm(td->td_proc, &semaptr->sem_perm, IPC_M);
+ if (eval)
break;
if ((eval = copyin(arg, &real_arg, sizeof(real_arg))) != 0)
break;
break;
if ((eval = copyin(arg, &real_arg, sizeof(real_arg))) != 0)
break;
- if ((eval = ipcperm(p, &semaptr->sem_perm, IPC_R)))
+ if ((eval = ipcperm(td->td_proc, &semaptr->sem_perm, IPC_R)))
break;
if ((eval = copyin(arg, &real_arg, sizeof(real_arg))) != 0)
break;
break;
if ((eval = copyin(arg, &real_arg, sizeof(real_arg))) != 0)
break;
- if ((eval = ipcperm(p, &semaptr->sem_perm, IPC_R)) != 0)
+ eval = ipcperm(td->td_proc, &semaptr->sem_perm, IPC_R);
+ if (eval)
break;
if (semnum < 0 || semnum >= semaptr->sem_nsems) {
eval = EINVAL;
break;
if (semnum < 0 || semnum >= semaptr->sem_nsems) {
eval = EINVAL;
- if ((eval = ipcperm(p, &semaptr->sem_perm, IPC_R)) != 0)
+ eval = ipcperm(td->td_proc, &semaptr->sem_perm, IPC_R);
+ if (eval)
break;
if (semnum < 0 || semnum >= semaptr->sem_nsems) {
eval = EINVAL;
break;
if (semnum < 0 || semnum >= semaptr->sem_nsems) {
eval = EINVAL;
- if ((eval = ipcperm(p, &semaptr->sem_perm, IPC_R)) != 0)
+ eval = ipcperm(td->td_proc, &semaptr->sem_perm, IPC_R);
+ if (eval)
break;
if (semnum < 0 || semnum >= semaptr->sem_nsems) {
eval = EINVAL;
break;
if (semnum < 0 || semnum >= semaptr->sem_nsems) {
eval = EINVAL;
- if ((eval = ipcperm(p, &semaptr->sem_perm, IPC_R)) != 0)
+ eval = ipcperm(td->td_proc, &semaptr->sem_perm, IPC_R);
+ if (eval)
break;
if ((eval = copyin(arg, &real_arg, sizeof(real_arg))) != 0)
break;
break;
if ((eval = copyin(arg, &real_arg, sizeof(real_arg))) != 0)
break;
- if ((eval = ipcperm(p, &semaptr->sem_perm, IPC_R)) != 0)
+ eval = ipcperm(td->td_proc, &semaptr->sem_perm, IPC_R);
+ if (eval)
break;
if (semnum < 0 || semnum >= semaptr->sem_nsems) {
eval = EINVAL;
break;
if (semnum < 0 || semnum >= semaptr->sem_nsems) {
eval = EINVAL;
- if ((eval = ipcperm(p, &semaptr->sem_perm, IPC_W)) != 0)
+ eval = ipcperm(td->td_proc, &semaptr->sem_perm, IPC_W);
+ if (eval)
break;
if (semnum < 0 || semnum >= semaptr->sem_nsems) {
eval = EINVAL;
break;
if (semnum < 0 || semnum >= semaptr->sem_nsems) {
eval = EINVAL;
- if ((eval = ipcperm(p, &semaptr->sem_perm, IPC_W)) != 0)
+ eval = ipcperm(td->td_proc, &semaptr->sem_perm, IPC_W);
+ if (eval)
break;
if ((eval = copyin(arg, &real_arg, sizeof(real_arg))) != 0)
break;
break;
if ((eval = copyin(arg, &real_arg, sizeof(real_arg))) != 0)
break;
int
sys_semget(struct semget_args *uap)
{
int
sys_semget(struct semget_args *uap)
{
- struct proc *p = curproc;
+ struct thread *td = curthread;
int semid, eval;
int key = uap->key;
int nsems = uap->nsems;
int semflg = uap->semflg;
int semid, eval;
int key = uap->key;
int nsems = uap->nsems;
int semflg = uap->semflg;
- struct ucred *cred = p->p_ucred;
+ struct ucred *cred = td->td_ucred;
#ifdef SEM_DEBUG
kprintf("semget(0x%x, %d, 0%o)\n", key, nsems, semflg);
#endif
#ifdef SEM_DEBUG
kprintf("semget(0x%x, %d, 0%o)\n", key, nsems, semflg);
#endif
- if (!jail_sysvipc_allowed && p->p_ucred->cr_prison != NULL)
+ if (!jail_sysvipc_allowed && cred->cr_prison != NULL)
return (ENOSYS);
get_mplock();
return (ENOSYS);
get_mplock();
#ifdef SEM_DEBUG
kprintf("found public key\n");
#endif
#ifdef SEM_DEBUG
kprintf("found public key\n");
#endif
- if ((eval = ipcperm(p, &sema[semid].sem_perm,
- semflg & 0700))) {
+ if ((eval = ipcperm(td->td_proc,
+ &sema[semid].sem_perm,
+ semflg & 0700))) {
goto done;
}
if (nsems > 0 && sema[semid].sem_nsems < nsems) {
goto done;
}
if (nsems > 0 && sema[semid].sem_nsems < nsems) {
int
sys_semop(struct semop_args *uap)
{
int
sys_semop(struct semop_args *uap)
{
- struct proc *p = curproc;
+ struct thread *td = curthread;
int semid = uap->semid;
u_int nsops = uap->nsops;
struct sembuf sops[MAX_SOPS];
int semid = uap->semid;
u_int nsops = uap->nsops;
struct sembuf sops[MAX_SOPS];
kprintf("call to semop(%d, 0x%x, %u)\n", semid, sops, nsops);
#endif
kprintf("call to semop(%d, 0x%x, %u)\n", semid, sops, nsops);
#endif
- if (!jail_sysvipc_allowed && p->p_ucred->cr_prison != NULL)
+ if (!jail_sysvipc_allowed && td->td_ucred->cr_prison != NULL)
return (ENOSYS);
get_mplock();
return (ENOSYS);
get_mplock();
- if ((eval = ipcperm(p, &semaptr->sem_perm, IPC_W))) {
+ if ((eval = ipcperm(td->td_proc, &semaptr->sem_perm, IPC_W))) {
#ifdef SEM_DEBUG
kprintf("eval = %d from ipaccess\n", eval);
#endif
#ifdef SEM_DEBUG
kprintf("eval = %d from ipaccess\n", eval);
#endif
adjval = sops[i].sem_op;
if (adjval == 0)
continue;
adjval = sops[i].sem_op;
if (adjval == 0)
continue;
- eval = semundo_adjust(p, &suptr, semid,
- sops[i].sem_num, -adjval);
+ eval = semundo_adjust(td->td_proc, &suptr, semid,
+ sops[i].sem_num, -adjval);
adjval = sops[j].sem_op;
if (adjval == 0)
continue;
adjval = sops[j].sem_op;
if (adjval == 0)
continue;
- if (semundo_adjust(p, &suptr, semid,
- sops[j].sem_num, adjval) != 0)
+ if (semundo_adjust(td->td_proc, &suptr, semid,
+ sops[j].sem_num, adjval) != 0)
panic("semop - can't undo undos");
}
panic("semop - can't undo undos");
}
for (i = 0; i < nsops; i++) {
sopptr = &sops[i];
semptr = &semaptr->sem_base[sopptr->sem_num];
for (i = 0; i < nsops; i++) {
sopptr = &sops[i];
semptr = &semaptr->sem_base[sopptr->sem_num];
- semptr->sempid = p->p_pid;
+ semptr->sempid = td->td_proc->p_pid;
}
/* Do a wakeup if any semaphore was up'd. */
}
/* Do a wakeup if any semaphore was up'd. */
int
sys_shmdt(struct shmdt_args *uap)
{
int
sys_shmdt(struct shmdt_args *uap)
{
- struct proc *p = curproc;
+ struct thread *td = curthread;
+ struct proc *p = td->td_proc;
struct shmmap_state *shmmap_s;
int i;
int error;
struct shmmap_state *shmmap_s;
int i;
int error;
- if (!jail_sysvipc_allowed && p->p_ucred->cr_prison != NULL)
+ if (!jail_sysvipc_allowed && td->td_ucred->cr_prison != NULL)
return (ENOSYS);
get_mplock();
return (ENOSYS);
get_mplock();
int
sys_shmat(struct shmat_args *uap)
{
int
sys_shmat(struct shmat_args *uap)
{
- struct proc *p = curproc;
+ struct thread *td = curthread;
+ struct proc *p = td->td_proc;
int error, i, flags;
struct shmid_ds *shmseg;
struct shmmap_state *shmmap_s = NULL;
int error, i, flags;
struct shmid_ds *shmseg;
struct shmmap_state *shmmap_s = NULL;
- if (!jail_sysvipc_allowed && p->p_ucred->cr_prison != NULL)
+ if (!jail_sysvipc_allowed && td->td_ucred->cr_prison != NULL)
return (ENOSYS);
get_mplock();
return (ENOSYS);
get_mplock();
sys_oshmctl(struct proc *p, struct oshmctl_args *uap)
{
#ifdef COMPAT_43
sys_oshmctl(struct proc *p, struct oshmctl_args *uap)
{
#ifdef COMPAT_43
+ struct thread *td = curthread;
struct shmid_ds *shmseg;
struct oshmid_ds outbuf;
struct shmid_ds *shmseg;
struct oshmid_ds outbuf;
- if (!jail_sysvipc_allowed && p->p_ucred->cr_prison != NULL)
+ if (!jail_sysvipc_allowed && td->td_ucred->cr_prison != NULL)
return (ENOSYS);
get_mplock();
return (ENOSYS);
get_mplock();
int
sys_shmctl(struct shmctl_args *uap)
{
int
sys_shmctl(struct shmctl_args *uap)
{
- struct proc *p = curproc;
+ struct thread *td = curthread;
+ struct proc *p = td->td_proc;
int error;
struct shmid_ds inbuf;
struct shmid_ds *shmseg;
int error;
struct shmid_ds inbuf;
struct shmid_ds *shmseg;
- if (!jail_sysvipc_allowed && p->p_ucred->cr_prison != NULL)
+ if (!jail_sysvipc_allowed && td->td_ucred->cr_prison != NULL)
return (ENOSYS);
get_mplock();
return (ENOSYS);
get_mplock();
int
sys_shmget(struct shmget_args *uap)
{
int
sys_shmget(struct shmget_args *uap)
{
- struct proc *p = curproc;
+ struct thread *td = curthread;
+ struct proc *p = td->td_proc;
- if (!jail_sysvipc_allowed && p->p_ucred->cr_prison != NULL)
+ if (!jail_sysvipc_allowed && td->td_ucred->cr_prison != NULL)
return (ENOSYS);
mode = uap->shmflg & ACCESSPERMS;
return (ENOSYS);
mode = uap->shmflg & ACCESSPERMS;
int
sys_shmsys(struct shmsys_args *uap)
{
int
sys_shmsys(struct shmsys_args *uap)
{
- struct proc *p = curproc;
+ struct thread *td = curthread;
unsigned int which = (unsigned int)uap->which;
int error;
unsigned int which = (unsigned int)uap->which;
int error;
- if (!jail_sysvipc_allowed && p->p_ucred->cr_prison != NULL)
+ if (!jail_sysvipc_allowed && td->td_ucred->cr_prison != NULL)
return (ENOSYS);
if (which >= sizeof(shmcalls)/sizeof(shmcalls[0]))
return (ENOSYS);
if (which >= sizeof(shmcalls)/sizeof(shmcalls[0]))
nfp->f_data = so;
/* Sync socket nonblocking/async state with file flags */
tmp = fflag & FNONBLOCK;
nfp->f_data = so;
/* Sync socket nonblocking/async state with file flags */
tmp = fflag & FNONBLOCK;
- fo_ioctl(nfp, FIONBIO, (caddr_t)&tmp, p->p_ucred, NULL);
+ fo_ioctl(nfp, FIONBIO, (caddr_t)&tmp, td->td_ucred, NULL);
- fo_ioctl(nfp, FIOASYNC, (caddr_t)&tmp, p->p_ucred, NULL);
+ fo_ioctl(nfp, FIOASYNC, (caddr_t)&tmp, td->td_ucred, NULL);
sa = NULL;
error = soaccept(so, &sa);
sa = NULL;
error = soaccept(so, &sa);
vn_lock(vp, LK_SHARED | LK_RETRY);
error = VOP_READ(vp, &auio,
IO_VMIO | ((MAXBSIZE / bsize) << 16),
vn_lock(vp, LK_SHARED | LK_RETRY);
error = VOP_READ(vp, &auio,
IO_VMIO | ((MAXBSIZE / bsize) << 16),
vn_unlock(vp);
vm_page_flag_clear(pg, PG_ZERO);
vm_page_io_finish(pg);
vn_unlock(vp);
vm_page_flag_clear(pg, PG_ZERO);
vm_page_io_finish(pg);
sys_mount(struct mount_args *uap)
{
struct thread *td = curthread;
sys_mount(struct mount_args *uap)
{
struct thread *td = curthread;
- struct proc *p = td->td_proc;
struct vnode *vp;
struct nchandle nch;
struct mount *mp, *nullmp;
struct vnode *vp;
struct nchandle nch;
struct mount *mp, *nullmp;
char fstypename[MFSNAMELEN];
struct ucred *cred;
char fstypename[MFSNAMELEN];
struct ucred *cred;
if (jailed(cred)) {
error = EPERM;
goto done;
if (jailed(cred)) {
error = EPERM;
goto done;
KKASSERT(p);
get_mplock();
KKASSERT(p);
get_mplock();
- if (p->p_ucred->cr_prison != NULL) {
+ if (td->td_ucred->cr_prison != NULL) {
error = EPERM;
goto done;
}
error = EPERM;
goto done;
}
* Only root, or the user that did the original mount is
* permitted to unmount this filesystem.
*/
* Only root, or the user that did the original mount is
* permitted to unmount this filesystem.
*/
- if ((mp->mnt_stat.f_owner != p->p_ucred->cr_uid) &&
+ if ((mp->mnt_stat.f_owner != td->td_ucred->cr_uid) &&
(error = priv_check(td, PRIV_ROOT)))
goto out;
(error = priv_check(td, PRIV_ROOT)))
goto out;
get_mplock();
td = curthread;
p = td->td_proc;
get_mplock();
td = curthread;
p = td->td_proc;
- if (p->p_ucred->cr_prison && !prison_quotas) {
+ if (td->td_ucred->cr_prison && !prison_quotas) {
error = EPERM;
goto done;
}
error = EPERM;
goto done;
}
* Sanity and permissions checks. We must be root.
*/
KKASSERT(p);
* Sanity and permissions checks. We must be root.
*/
KKASSERT(p);
- if (p->p_ucred->cr_prison != NULL)
+ if (td->td_ucred->cr_prison != NULL)
return (EPERM);
if ((uap->op != MOUNTCTL_MOUNTFLAGS) &&
(error = priv_check(td, PRIV_ROOT)) != 0)
return (EPERM);
if ((uap->op != MOUNTCTL_MOUNTFLAGS) &&
(error = priv_check(td, PRIV_ROOT)) != 0)
long maxcount;
int error;
int flags;
long maxcount;
int error;
int flags;
};
static int getfsstat_callback(struct mount *, void *);
};
static int getfsstat_callback(struct mount *, void *);
sys_getfsstat(struct getfsstat_args *uap)
{
struct thread *td = curthread;
sys_getfsstat(struct getfsstat_args *uap)
{
struct thread *td = curthread;
- struct proc *p = td->td_proc;
struct getfsstat_info info;
bzero(&info, sizeof(info));
struct getfsstat_info info;
bzero(&info, sizeof(info));
info.sfsp = uap->buf;
info.count = 0;
info.flags = uap->flags;
info.sfsp = uap->buf;
info.count = 0;
info.flags = uap->flags;
get_mplock();
mountlist_scan(getfsstat_callback, &info, MNTSCAN_FORWARD);
get_mplock();
mountlist_scan(getfsstat_callback, &info, MNTSCAN_FORWARD);
int error;
if (info->sfsp && info->count < info->maxcount) {
int error;
if (info->sfsp && info->count < info->maxcount) {
- if (info->p && !chroot_visible_mnt(mp, info->p))
+ if (info->td->td_proc &&
+ !chroot_visible_mnt(mp, info->td->td_proc)) {
*/
if (((info->flags & (MNT_LAZY|MNT_NOWAIT)) == 0 ||
(info->flags & MNT_WAIT)) &&
*/
if (((info->flags & (MNT_LAZY|MNT_NOWAIT)) == 0 ||
(info->flags & MNT_WAIT)) &&
- (error = VFS_STATFS(mp, sp, info->p->p_ucred))) {
+ (error = VFS_STATFS(mp, sp, info->td->td_ucred))) {
return(0);
}
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
return(0);
}
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
- error = mount_path(info->p, mp, &fullpath, &freepath);
+ error = mount_path(info->td->td_proc, mp, &fullpath, &freepath);
if (error) {
info->error = error;
return(-1);
if (error) {
info->error = error;
return(-1);
long maxcount;
int error;
int flags;
long maxcount;
int error;
int flags;
};
static int getvfsstat_callback(struct mount *, void *);
};
static int getvfsstat_callback(struct mount *, void *);
sys_getvfsstat(struct getvfsstat_args *uap)
{
struct thread *td = curthread;
sys_getvfsstat(struct getvfsstat_args *uap)
{
struct thread *td = curthread;
- struct proc *p = td->td_proc;
struct getvfsstat_info info;
bzero(&info, sizeof(info));
struct getvfsstat_info info;
bzero(&info, sizeof(info));
info.vsfsp = uap->vbuf;
info.count = 0;
info.flags = uap->flags;
info.vsfsp = uap->vbuf;
info.count = 0;
info.flags = uap->flags;
get_mplock();
mountlist_scan(getvfsstat_callback, &info, MNTSCAN_FORWARD);
get_mplock();
mountlist_scan(getvfsstat_callback, &info, MNTSCAN_FORWARD);
int error;
if (info->vsfsp && info->count < info->maxcount) {
int error;
if (info->vsfsp && info->count < info->maxcount) {
- if (info->p && !chroot_visible_mnt(mp, info->p))
+ if (info->td->td_proc &&
+ !chroot_visible_mnt(mp, info->td->td_proc)) {
sp = &mp->mnt_stat;
vsp = &mp->mnt_vstat;
sp = &mp->mnt_stat;
vsp = &mp->mnt_vstat;
*/
if (((info->flags & (MNT_LAZY|MNT_NOWAIT)) == 0 ||
(info->flags & MNT_WAIT)) &&
*/
if (((info->flags & (MNT_LAZY|MNT_NOWAIT)) == 0 ||
(info->flags & MNT_WAIT)) &&
- (error = VFS_STATFS(mp, sp, info->p->p_ucred))) {
+ (error = VFS_STATFS(mp, sp, info->td->td_ucred))) {
return(0);
}
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
if (((info->flags & (MNT_LAZY|MNT_NOWAIT)) == 0 ||
(info->flags & MNT_WAIT)) &&
return(0);
}
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
if (((info->flags & (MNT_LAZY|MNT_NOWAIT)) == 0 ||
(info->flags & MNT_WAIT)) &&
- (error = VFS_STATVFS(mp, vsp, info->p->p_ucred))) {
+ (error = VFS_STATVFS(mp, vsp, info->td->td_ucred))) {
return(0);
}
vsp->f_flag = 0;
return(0);
}
vsp->f_flag = 0;
if (mp->mnt_flag & MNT_NOSUID)
vsp->f_flag |= ST_NOSUID;
if (mp->mnt_flag & MNT_NOSUID)
vsp->f_flag |= ST_NOSUID;
- error = mount_path(info->p, mp, &fullpath, &freepath);
+ error = mount_path(info->td->td_proc, mp, &fullpath, &freepath);
if (error) {
info->error = error;
return(-1);
if (error) {
info->error = error;
return(-1);
/*
* Only privileged user can chroot
*/
/*
* Only privileged user can chroot
*/
- error = priv_check_cred(p->p_ucred, PRIV_VFS_CHROOT, 0);
+ error = priv_check_cred(td->td_ucred, PRIV_VFS_CHROOT, 0);
if (error)
return (error);
if (error)
return (error);
if (vp->v_type != VDIR)
error = ENOTDIR;
else
if (vp->v_type != VDIR)
error = ENOTDIR;
else
- error = VOP_EACCESS(vp, VEXEC, td->td_proc->p_ucred);
+ error = VOP_EACCESS(vp, VEXEC, td->td_ucred);
switch (mode & S_IFMT) {
case S_IFMT: /* used by badsect to flag bad sectors */
switch (mode & S_IFMT) {
case S_IFMT: /* used by badsect to flag bad sectors */
- error = priv_check_cred(p->p_ucred, PRIV_VFS_MKNOD_BAD, 0);
+ error = priv_check_cred(td->td_ucred, PRIV_VFS_MKNOD_BAD, 0);
vattr.va_type = VBAD;
break;
case S_IFCHR:
vattr.va_type = VBAD;
break;
case S_IFCHR:
vattr.va_type = VBLK;
break;
case S_IFWHT:
vattr.va_type = VBLK;
break;
case S_IFWHT:
- error = priv_check_cred(p->p_ucred, PRIV_VFS_MKNOD_WHT, 0);
+ error = priv_check_cred(td->td_ucred, PRIV_VFS_MKNOD_WHT, 0);
whiteout = 1;
break;
case S_IFDIR: /* special directories support for HAMMER */
whiteout = 1;
break;
case S_IFDIR: /* special directories support for HAMMER */
- error = priv_check_cred(p->p_ucred, PRIV_VFS_MKNOD_DIR, 0);
+ error = priv_check_cred(td->td_ucred, PRIV_VFS_MKNOD_DIR, 0);
vattr.va_type = VDIR;
break;
default:
vattr.va_type = VDIR;
break;
default:
/*
* Finally run the new API VOP.
*/
/*
* Finally run the new API VOP.
*/
- error = can_hardlink(vp, td, td->td_proc->p_ucred);
+ error = can_hardlink(vp, td, td->td_ucred);
if (error == 0) {
error = VOP_NLINK(&linknd->nl_nch, linknd->nl_dvp,
vp, linknd->nl_cred);
if (error == 0) {
error = VOP_NLINK(&linknd->nl_nch, linknd->nl_dvp,
vp, linknd->nl_cred);
kern_readlink(struct nlookupdata *nd, char *buf, int count, int *res)
{
struct thread *td = curthread;
kern_readlink(struct nlookupdata *nd, char *buf, int count, int *res)
{
struct thread *td = curthread;
- struct proc *p = td->td_proc;
struct vnode *vp;
struct iovec aiov;
struct uio auio;
struct vnode *vp;
struct iovec aiov;
struct uio auio;
auio.uio_segflg = UIO_USERSPACE;
auio.uio_td = td;
auio.uio_resid = count;
auio.uio_segflg = UIO_USERSPACE;
auio.uio_td = td;
auio.uio_resid = count;
- error = VOP_READLINK(vp, &auio, p->p_ucred);
+ error = VOP_READLINK(vp, &auio, td->td_ucred);
}
vput(vp);
*res = count - auio.uio_resid;
}
vput(vp);
*res = count - auio.uio_resid;
setfflags(struct vnode *vp, int flags)
{
struct thread *td = curthread;
setfflags(struct vnode *vp, int flags)
{
struct thread *td = curthread;
- struct proc *p = td->td_proc;
int error;
struct vattr vattr;
int error;
struct vattr vattr;
* chown can't fail when done as root.
*/
if ((vp->v_type == VCHR || vp->v_type == VBLK) &&
* chown can't fail when done as root.
*/
if ((vp->v_type == VCHR || vp->v_type == VBLK) &&
- ((error = priv_check_cred(p->p_ucred, PRIV_VFS_CHFLAGS_DEV, 0)) != 0))
+ ((error = priv_check_cred(td->td_ucred, PRIV_VFS_CHFLAGS_DEV, 0)) != 0))
if ((error = vget(vp, LK_EXCLUSIVE)) == 0) {
VATTR_NULL(&vattr);
vattr.va_flags = flags;
if ((error = vget(vp, LK_EXCLUSIVE)) == 0) {
VATTR_NULL(&vattr);
vattr.va_flags = flags;
- error = VOP_SETATTR(vp, &vattr, p->p_ucred);
+ error = VOP_SETATTR(vp, &vattr, td->td_ucred);
vput(vp);
}
return (error);
vput(vp);
}
return (error);
setfmode(struct vnode *vp, int mode)
{
struct thread *td = curthread;
setfmode(struct vnode *vp, int mode)
{
struct thread *td = curthread;
- struct proc *p = td->td_proc;
int error;
struct vattr vattr;
int error;
struct vattr vattr;
if ((error = vget(vp, LK_EXCLUSIVE)) == 0) {
VATTR_NULL(&vattr);
vattr.va_mode = mode & ALLPERMS;
if ((error = vget(vp, LK_EXCLUSIVE)) == 0) {
VATTR_NULL(&vattr);
vattr.va_mode = mode & ALLPERMS;
- error = VOP_SETATTR(vp, &vattr, p->p_ucred);
+ error = VOP_SETATTR(vp, &vattr, td->td_ucred);
vput(vp);
}
return error;
vput(vp);
}
return error;
setfown(struct vnode *vp, uid_t uid, gid_t gid)
{
struct thread *td = curthread;
setfown(struct vnode *vp, uid_t uid, gid_t gid)
{
struct thread *td = curthread;
- struct proc *p = td->td_proc;
int error;
struct vattr vattr;
int error;
struct vattr vattr;
VATTR_NULL(&vattr);
vattr.va_uid = uid;
vattr.va_gid = gid;
VATTR_NULL(&vattr);
vattr.va_uid = uid;
vattr.va_gid = gid;
- error = VOP_SETATTR(vp, &vattr, p->p_ucred);
+ error = VOP_SETATTR(vp, &vattr, td->td_ucred);
vput(vp);
}
return error;
vput(vp);
}
return error;
const struct timespec *ts, int nullflag)
{
struct thread *td = curthread;
const struct timespec *ts, int nullflag)
{
struct thread *td = curthread;
- struct proc *p = td->td_proc;
int error;
VATTR_NULL(vattr);
int error;
VATTR_NULL(vattr);
vattr->va_mtime = ts[1];
if (nullflag)
vattr->va_vaflags |= VA_UTIMES_NULL;
vattr->va_mtime = ts[1];
if (nullflag)
vattr->va_vaflags |= VA_UTIMES_NULL;
- error = VOP_SETATTR(vp, vattr, p->p_ucred);
+ error = VOP_SETATTR(vp, vattr, td->td_ucred);
vattr.va_mode = (mode & ACCESSPERMS) &~ p->p_fd->fd_cmask;
vp = NULL;
vattr.va_mode = (mode & ACCESSPERMS) &~ p->p_fd->fd_cmask;
vp = NULL;
- error = VOP_NMKDIR(&nd->nl_nch, nd->nl_dvp, &vp, p->p_ucred, &vattr);
+ error = VOP_NMKDIR(&nd->nl_nch, nd->nl_dvp, &vp, td->td_ucred, &vattr);
if (error == 0)
vput(vp);
return (error);
if (error == 0)
vput(vp);
return (error);
if (fmode & FREAD)
mode |= VREAD;
if (mode) {
if (fmode & FREAD)
mode |= VREAD;
if (mode) {
- error = VOP_ACCESS(vp, mode, p->p_ucred);
+ error = VOP_ACCESS(vp, mode, td->td_ucred);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); /* XXX */
VATTR_NULL(vap);
vap->va_size = 0;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); /* XXX */
VATTR_NULL(vap);
vap->va_size = 0;
- error = VOP_SETATTR(vp, vap, p->p_ucred);
+ error = VOP_SETATTR(vp, vap, td->td_ucred);
- error = VOP_OPEN(vp, fmode, p->p_ucred, fp);
+ error = VOP_OPEN(vp, fmode, td->td_ucred, fp);
if (error) {
/*
* setting f_ops this way prevents VOP_CLOSE from being
if (error) {
/*
* setting f_ops this way prevents VOP_CLOSE from being
error = ESTALE;
if (error == 0) {
if ((error = VFS_FHTOVP(mp, NULL, &fh.fh_fid, &vp)) == 0) {
error = ESTALE;
if (error == 0) {
if ((error = VFS_FHTOVP(mp, NULL, &fh.fh_fid, &vp)) == 0) {
- error = vn_stat(vp, &sb, td->td_proc->p_ucred);
+ error = vn_stat(vp, &sb, td->td_ucred);
mp = vp->v_mount;
sp = &mp->mnt_stat;
vput(vp);
mp = vp->v_mount;
sp = &mp->mnt_stat;
vput(vp);
- if ((error = VFS_STATFS(mp, sp, p->p_ucred)) != 0)
+ if ((error = VFS_STATFS(mp, sp, td->td_ucred)) != 0)
goto done;
error = mount_path(p, mp, &fullpath, &freepath);
goto done;
error = mount_path(p, mp, &fullpath, &freepath);
mp = vp->v_mount;
sp = &mp->mnt_vstat;
vput(vp);
mp = vp->v_mount;
sp = &mp->mnt_vstat;
vput(vp);
- if ((error = VFS_STATVFS(mp, sp, p->p_ucred)) != 0)
+ if ((error = VFS_STATVFS(mp, sp, td->td_ucred)) != 0)
goto done;
sp->f_flag = 0;
goto done;
sp->f_flag = 0;
struct ucred *cred;
KKASSERT(td->td_proc);
struct ucred *cred;
KKASSERT(td->td_proc);
- cred = td->td_proc->p_ucred;
checkbad(copyin(uap->li,&li,sizeof(li)));
checkbad(copyout(&connHandle,uap->connHandle,sizeof(connHandle))); /* check before */
checkbad(copyin(uap->li,&li,sizeof(li)));
checkbad(copyout(&connHandle,uap->connHandle,sizeof(connHandle))); /* check before */
- cred = td->td_proc->p_ucred;
error = ncp_conn_findhandle(uap->connHandle,td,&handle);
if (error)
error = ncp_conn_findhandle(uap->connHandle,td,&handle);
if (error)
char *pdata;
KKASSERT(td->td_proc);
char *pdata;
KKASSERT(td->td_proc);
- cred = td->td_proc->p_ucred;
error = copyin(&uap->ncpbuf->rqsize, &rqsize, sizeof(int));
if (error) return(error);
error = copyin(&uap->ncpbuf->rqsize, &rqsize, sizeof(int));
if (error) return(error);
struct ucred *cred;
KKASSERT(td->td_proc);
struct ucred *cred;
KKASSERT(td->td_proc);
- cred = td->td_proc->p_ucred;
if (uap->li) {
if (copyin(uap->li,&li,sizeof(li))) return EFAULT;
if (uap->li) {
if (copyin(uap->li,&li,sizeof(li))) return EFAULT;
DECLARE_RQ;
KKASSERT(td->td_proc);
DECLARE_RQ;
KKASSERT(td->td_proc);
- cred = td->td_proc->p_ucred;
ncp_rq_head(rqp,NCP_REQUEST,nfp->fn,td,cred);
if (nfp->rqfcnt) {
ncp_rq_head(rqp,NCP_REQUEST,nfp->fn,td,cred);
if (nfp->rqfcnt) {
if ((error = copyin(args, &ua, sizeof(struct i386_ioperm_args))) != 0)
return (error);
if ((error = copyin(args, &ua, sizeof(struct i386_ioperm_args))) != 0)
return (error);
- if ((error = priv_check_cred(lp->lwp_proc->p_ucred, PRIV_ROOT, 0)) != 0)
+ if ((error = priv_check_cred(lp->lwp_thread->td_ucred, PRIV_ROOT, 0)) != 0)
return (error);
if (securelevel > 0)
return (EPERM);
return (error);
if (securelevel > 0)
return (EPERM);
*
* NOTE: td_pri is bumped by TDPRI_CRIT when entering a critical section,
* but this does not effect how the thread is scheduled by LWKT.
*
* NOTE: td_pri is bumped by TDPRI_CRIT when entering a critical section,
* but this does not effect how the thread is scheduled by LWKT.
+ *
+ * NOTE: td_ucred is synchronized from the p_ucred on user->kernel syscall,
+ * trap, and AST/signal transitions to provide a stable ucred for
+ * (primarily) system calls. This field will be NULL for pure kernel
+ * threads.
*/
struct md_intr_info;
struct caps_kinfo;
*/
struct md_intr_info;
struct caps_kinfo;
goto done;
}
nmp->nm_state |= NFSSTA_MNTD;
goto done;
}
nmp->nm_state |= NFSSTA_MNTD;
- error = nfs_clientd(nmp, td->td_proc->p_ucred, &ncd, uap->flag,
+ error = nfs_clientd(nmp, td->td_ucred, &ncd, uap->flag,
uap->argp, td);
} else if (uap->flag & NFSSVC_ADDSOCK) {
error = copyin(uap->argp, (caddr_t)&nfsdarg, sizeof(nfsdarg));
uap->argp, td);
} else if (uap->flag & NFSSVC_ADDSOCK) {
error = copyin(uap->argp, (caddr_t)&nfsdarg, sizeof(nfsdarg));
vm_offset_t addr;
vm_offset_t tmpaddr;
vm_size_t size, pageoff;
vm_offset_t addr;
vm_offset_t tmpaddr;
vm_size_t size, pageoff;
- struct proc *p = curproc;
+ struct thread *td = curthread;
+ struct proc *p = td->td_proc;
int error;
addr = (vm_offset_t) uap->addr;
int error;
addr = (vm_offset_t) uap->addr;
- error = priv_check_cred(p->p_ucred, PRIV_ROOT, 0);
+ error = priv_check_cred(td->td_ucred, PRIV_ROOT, 0);
if (error) {
rel_mplock();
return (error);
if (error) {
rel_mplock();
return (error);
int error;
struct ucred *cred;
int error;
struct ucred *cred;
- KKASSERT(td->td_proc);
- cred = td->td_proc->p_ucred;
error = priv_check(td, PRIV_ROOT);
if (error)
error = priv_check(td, PRIV_ROOT);
if (error)
- KKASSERT(td->td_proc);
- cred = td->td_proc->p_ucred;
if (!swapdev_vp) {
error = getspecialvnode(VT_NON, NULL, &swapdev_vnode_vops_p,
if (!swapdev_vp) {
error = getspecialvnode(VT_NON, NULL, &swapdev_vnode_vops_p,