mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-24 16:10:11 +00:00
Use proc lock to safely obtain references to p_ucred before vnode
operations.
This commit is contained in:
parent
fb29c3e083
commit
07a1f31cd0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=71446
@ -162,7 +162,7 @@ static int
|
||||
pecoff_coredump(register struct proc * p, register struct vnode * vp,
|
||||
off_t limit)
|
||||
{
|
||||
register struct ucred *cred = p->p_ucred;
|
||||
register struct ucred *cred;
|
||||
register struct vmspace *vm = p->p_vmspace;
|
||||
int error;
|
||||
#ifdef PECOFF_DEBUG
|
||||
@ -184,6 +184,10 @@ pecoff_coredump(register struct proc * p, register struct vnode * vp,
|
||||
ent = &map->header;
|
||||
printf("%p %p %p\n", ent, ent->prev, ent->next);
|
||||
#endif
|
||||
PROC_LOCK(p);
|
||||
cred = p->p_ucred;
|
||||
crhold(cred);
|
||||
PROC_UNLOCK(p);
|
||||
error = cpu_coredump(p, vp, cred);
|
||||
if (error == 0)
|
||||
error = vn_rdwr(UIO_WRITE, vp, vm->vm_daddr,
|
||||
@ -195,6 +199,7 @@ pecoff_coredump(register struct proc * p, register struct vnode * vp,
|
||||
round_page(ctob(vm->vm_ssize)),
|
||||
(off_t) ctob(UPAGES) + ctob(vm->vm_dsize), UIO_USERSPACE,
|
||||
IO_NODELOCKED | IO_UNIT, cred, (int *) NULL, p);
|
||||
crfree(cred);
|
||||
return (error);
|
||||
|
||||
}
|
||||
@ -600,10 +605,15 @@ pecoff_read_from(p, vp, pos, buf, siz)
|
||||
{
|
||||
int error;
|
||||
size_t resid;
|
||||
struct ucred *uc;
|
||||
|
||||
PROC_LOCK(p);
|
||||
uc = p->p_ucred;
|
||||
crhold(uc);
|
||||
PROC_UNLOCK(p);
|
||||
error = vn_rdwr(UIO_READ, vp, buf, siz, pos,
|
||||
UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred,
|
||||
&resid, p);
|
||||
UIO_SYSSPACE, IO_NODELOCKED, uc, &resid, p);
|
||||
crfree(uc);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user