Proc locking to protect p_ucred while we obtain additional references.

This commit is contained in:
John Baldwin 2001-01-24 00:26:19 +00:00
parent 1e3e44f22f
commit cfb4c0b4f9
2 changed files with 30 additions and 4 deletions

View File

@ -183,6 +183,7 @@ cd9660_mount(mp, path, data, ndp, p)
{
struct vnode *devvp;
struct iso_args args;
struct ucred *uc;
size_t size;
int error;
mode_t accessmode;
@ -227,7 +228,12 @@ cd9660_mount(mp, path, data, ndp, p)
*/
accessmode = VREAD;
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p);
PROC_LOCK(p);
uc = p->p_ucred;
crhold(uc);
PROC_UNLOCK(p);
error = VOP_ACCESS(devvp, accessmode, uc, p);
crfree(uc);
if (error)
error = suser(p);
if (error) {
@ -271,6 +277,7 @@ iso_mountfs(devvp, mp, p, argp)
register struct iso_mnt *isomp = (struct iso_mnt *)0;
struct buf *bp = NULL;
struct buf *pribp = NULL, *supbp = NULL;
struct ucred *uc;
dev_t dev = devvp->v_rdev;
int error = EINVAL;
int needclose = 0;
@ -298,7 +305,13 @@ iso_mountfs(devvp, mp, p, argp)
return error;
if (vcount(devvp) > 1 && devvp != rootvp)
return EBUSY;
if ((error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0)))
PROC_LOCK(p);
uc = p->p_ucred;
crhold(uc);
PROC_UNLOCK(p);
error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0);
crfree(uc);
if (error)
return (error);
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);

View File

@ -183,6 +183,7 @@ cd9660_mount(mp, path, data, ndp, p)
{
struct vnode *devvp;
struct iso_args args;
struct ucred *uc;
size_t size;
int error;
mode_t accessmode;
@ -227,7 +228,12 @@ cd9660_mount(mp, path, data, ndp, p)
*/
accessmode = VREAD;
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p);
PROC_LOCK(p);
uc = p->p_ucred;
crhold(uc);
PROC_UNLOCK(p);
error = VOP_ACCESS(devvp, accessmode, uc, p);
crfree(uc);
if (error)
error = suser(p);
if (error) {
@ -271,6 +277,7 @@ iso_mountfs(devvp, mp, p, argp)
register struct iso_mnt *isomp = (struct iso_mnt *)0;
struct buf *bp = NULL;
struct buf *pribp = NULL, *supbp = NULL;
struct ucred *uc;
dev_t dev = devvp->v_rdev;
int error = EINVAL;
int needclose = 0;
@ -298,7 +305,13 @@ iso_mountfs(devvp, mp, p, argp)
return error;
if (vcount(devvp) > 1 && devvp != rootvp)
return EBUSY;
if ((error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0)))
PROC_LOCK(p);
uc = p->p_ucred;
crhold(uc);
PROC_UNLOCK(p);
error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0);
crfree(uc);
if (error)
return (error);
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);