Subject: [PATCH] tmpfs: Correct checking of VWRITE

From: Rumko <[email-masked]>
Date: Mon, 1 Nov 2010 09:59:34 +0100

In tmpfs_access(), checking for VWRITE mode was incorrect.
This enables us to chroot into schg dirs again (e.g. /var/empty).
---
 sys/vfs/tmpfs/tmpfs_vnops.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/vfs/tmpfs/tmpfs_vnops.c b/sys/vfs/tmpfs/tmpfs_vnops.c
index fccc6b8..9119266 100644
--- a/sys/vfs/tmpfs/tmpfs_vnops.c
+++ b/sys/vfs/tmpfs/tmpfs_vnops.c
@@ -260,7 +260,7 @@ tmpfs_access(struct vop_access_args *v)
 	case VLNK:
 		/* FALLTHROUGH */
 	case VREG:
-		if (VWRITE && vp->v_mount->mnt_flag & MNT_RDONLY) {
+		if ((v->a_mode & VWRITE) && vp->v_mount->mnt_flag & MNT_RDONLY) {
 			error = EROFS;
 			goto out;
 		}
@@ -280,7 +280,7 @@ tmpfs_access(struct vop_access_args *v)
 		goto out;
 	}
 
-	if (VWRITE && node->tn_flags & IMMUTABLE) {
+	if ((v->a_mode & VWRITE) && node->tn_flags & IMMUTABLE) {
 		error = EPERM;
 		goto out;
 	}
-- 
1.7.0.5