diff options
author | kato <kato@FreeBSD.org> | 1997-08-14 03:57:46 +0000 |
---|---|---|
committer | kato <kato@FreeBSD.org> | 1997-08-14 03:57:46 +0000 |
commit | 9e0af5b4e34026a6a2f8e78e634573fd80be2307 (patch) | |
tree | 58661914604b0b75367c416dfcd52882705ebb04 | |
parent | a9c600c63035342e94d798348c02629f4d112a2b (diff) | |
download | FreeBSD-src-9e0af5b4e34026a6a2f8e78e634573fd80be2307.zip FreeBSD-src-9e0af5b4e34026a6a2f8e78e634573fd80be2307.tar.gz |
If the user doesn't have read permission, union_copyup should not copy
a file to upper layer.
Reviewed by: Naofumi Honda <honda@Kururu.math.sci.hokudai.ac.jp>
-rw-r--r-- | sys/fs/unionfs/union_subr.c | 12 | ||||
-rw-r--r-- | sys/miscfs/union/union_subr.c | 12 |
2 files changed, 22 insertions, 2 deletions
diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c index 493a172..7f85e65 100644 --- a/sys/fs/unionfs/union_subr.c +++ b/sys/fs/unionfs/union_subr.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * @(#)union_subr.c 8.20 (Berkeley) 5/20/95 - * $Id: union_subr.c,v 1.18 1997/04/16 16:24:24 kato Exp $ + * $Id: union_subr.c,v 1.19 1997/08/02 14:32:28 bde Exp $ */ #include <sys/param.h> @@ -650,6 +650,16 @@ union_copyup(un, docopy, cred, p) int error; struct vnode *lvp, *uvp; + /* + * If the user does not have read permission, the vnode should not + * be copied to upper layer. + */ + vn_lock(un->un_lowervp, LK_EXCLUSIVE | LK_RETRY, p); + error = VOP_ACCESS(un->un_lowervp, VREAD, cred, p); + VOP_UNLOCK(un->un_lowervp, 0, p); + if (error) + return (error); + error = union_vn_create(&uvp, un, p); if (error) return (error); diff --git a/sys/miscfs/union/union_subr.c b/sys/miscfs/union/union_subr.c index 493a172..7f85e65 100644 --- a/sys/miscfs/union/union_subr.c +++ b/sys/miscfs/union/union_subr.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * @(#)union_subr.c 8.20 (Berkeley) 5/20/95 - * $Id: union_subr.c,v 1.18 1997/04/16 16:24:24 kato Exp $ + * $Id: union_subr.c,v 1.19 1997/08/02 14:32:28 bde Exp $ */ #include <sys/param.h> @@ -650,6 +650,16 @@ union_copyup(un, docopy, cred, p) int error; struct vnode *lvp, *uvp; + /* + * If the user does not have read permission, the vnode should not + * be copied to upper layer. + */ + vn_lock(un->un_lowervp, LK_EXCLUSIVE | LK_RETRY, p); + error = VOP_ACCESS(un->un_lowervp, VREAD, cred, p); + VOP_UNLOCK(un->un_lowervp, 0, p); + if (error) + return (error); + error = union_vn_create(&uvp, un, p); if (error) return (error); |