Date: Fri, 25 Aug 95 19:58:29 MDT From: terry@cs.weber.edu (Terry Lambert) To: current@freebsd.org Subject: Re: Re(4): KERNEL PATCHES FOR NFS LOCKING SUPPORT (fwd) Message-ID: <9508260158.AA13784@cs.weber.edu>
next in thread | raw e-mail | index | archive | help
Andrew, who's working on the hard part of NFS locking, has pointed out some errors in my NFS locking patches. Here are the patches to correct the errors. They assume the previous patches have been applied. The comments or the if statements were correct, depending on your point of view. ---- Rats. I switched the copyin's -- you missed the "suser" returns 0 or EPERM -- 0 if it's root. And I missed 2 value compares and 2 copyin and 1 copyout swap. The point was for a non-root call or for a call with the non "remote" versions to use the old structure for the copyin/copyout for binary compatability with old root and non-root code, and to protect against proxy calls from non-root users. I knew I was going to out-clever myself here... I combined the cases at the last minute, and didn't save before generating the patch. 8-(. Here is a patch that fixes the oversights (3 of them!): ============================================================================== *** kern_descrip.c.BAD Fri Aug 25 18:38:20 1995 --- kern_descrip.c Fri Aug 25 18:45:51 1995 *************** *** 263,274 **** vp = (struct vnode *)fp->f_data; if( suser(p->p_ucred, &p->p_acflag) || ( uap->cmd == F_SETLKW) || ( uap->cmd == F_SETLK)) { /* Copy in the lock structure */ - error = copyin((caddr_t)uap->arg, (caddr_t)&flk, sizeof(flk)); - } else { /* non-root/non-remote*/ - /* Copy in the lock structure */ error = copyin((caddr_t)uap->arg, (caddr_t)&flk, sizeof(struct oflock)); flk.l_rsys = FLOCK_LOCAL_LOCK; flk.l_rpid = FLOCK_LOCAL_LOCK; } if (error) return (error); --- 263,274 ---- vp = (struct vnode *)fp->f_data; if( suser(p->p_ucred, &p->p_acflag) || ( uap->cmd == F_SETLKW) || ( uap->cmd == F_SETLK)) { /* Copy in the lock structure */ error = copyin((caddr_t)uap->arg, (caddr_t)&flk, sizeof(struct oflock)); flk.l_rsys = FLOCK_LOCAL_LOCK; flk.l_rpid = FLOCK_LOCAL_LOCK; + } else { /* root & remote*/ + /* Copy in the lock structure */ + error = copyin((caddr_t)uap->arg, (caddr_t)&flk, sizeof(flk)); } if (error) return (error); *************** *** 301,314 **** if (fp->f_type != DTYPE_VNODE) return (EBADF); vp = (struct vnode *)fp->f_data; ! if( suser(p->p_ucred, &p->p_acflag)) { ! /* Copy in the lock structure */ ! error = copyin((caddr_t)uap->arg, (caddr_t)&flk, sizeof (flk)); ! } else { /* non-root/non-remote*/ /* Copy in the lock structure */ error = copyin((caddr_t)uap->arg, (caddr_t)&flk, sizeof(struct oflock)); flk.l_rsys = FLOCK_LOCAL_LOCK; flk.l_rpid = FLOCK_LOCAL_LOCK; } if (error) return (error); --- 301,314 ---- if (fp->f_type != DTYPE_VNODE) return (EBADF); vp = (struct vnode *)fp->f_data; ! if( suser(p->p_ucred, &p->p_acflag) || ( uap->cmd == F_GETLK)) { /* Copy in the lock structure */ error = copyin((caddr_t)uap->arg, (caddr_t)&flk, sizeof(struct oflock)); flk.l_rsys = FLOCK_LOCAL_LOCK; flk.l_rpid = FLOCK_LOCAL_LOCK; + } else { /* root & remote*/ + /* Copy in the lock structure */ + error = copyin((caddr_t)uap->arg, (caddr_t)&flk, sizeof (flk)); } if (error) return (error); *************** *** 316,325 **** flk.l_start += fp->f_offset; if ((error = VOP_ADVLOCK(vp,(caddr_t)p,F_GETLK,&flk,F_POSIX))) return (error); ! if( suser(p->p_ucred, &p->p_acflag)) { ! return (copyout((caddr_t)&flk, (caddr_t)uap->arg, sizeof(flk))); ! } else { /* non-root/local*/ return (copyout((caddr_t)&flk, (caddr_t)uap->arg, sizeof(struct oflock))); } default: --- 316,325 ---- flk.l_start += fp->f_offset; if ((error = VOP_ADVLOCK(vp,(caddr_t)p,F_GETLK,&flk,F_POSIX))) return (error); ! if( suser(p->p_ucred, &p->p_acflag) || ( uap->cmd == F_GETLK)) { return (copyout((caddr_t)&flk, (caddr_t)uap->arg, sizeof(struct oflock))); + } else { /* root & remote*/ + return (copyout((caddr_t)&flk, (caddr_t)uap->arg, sizeof(flk))); } default: ============================================================================== Terry Lambert terry@cs.weber.edu --- Any opinions in this posting are my own and not those of my present or previous employers.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9508260158.AA13784>