diff -NurBP --minimal linux-2.4.20-p8v13e-quota01/fs/attr.c linux-2.4.20-p8v13e-quota02/fs/attr.c --- linux-2.4.20-p8v13e-quota01/fs/attr.c Sat Oct 26 21:50:27 2002 +++ linux-2.4.20-p8v13e-quota02/fs/attr.c Sun Oct 27 21:59:15 2002 @@ -20,6 +20,8 @@ { int retval = -EPERM; unsigned int ia_valid = attr->ia_valid; + int context_mismatch = (inode->i_context != 0) && + (current->s_context != inode->i_context); /* If force is set do it anyway. */ if (ia_valid & ATTR_FORCE) @@ -28,27 +30,27 @@ /* Make sure a caller can chown. */ if ((ia_valid & ATTR_UID) && (current->fsuid != inode->i_uid || - attr->ia_uid != inode->i_uid) && !capable(CAP_CHOWN)) + attr->ia_uid != inode->i_uid || + context_mismatch) && !capable(CAP_CHOWN)) goto error; - /* Make sure a caller is in context. */ - if ((ia_valid & ATTR_CTX) && - (current->s_context != inode->i_context || - attr->ia_context != inode->i_context) && - !capable(CAP_CHOWN)) + /* Make sure a caller is in same context. */ +/* if ((ia_valid & ATTR_CTX) && + (attr->ia_context != inode->i_context || + context_mismatch) && !capable(CAP_CHCTX)) goto error; - +*/ /* Make sure caller can chgrp. */ if ((ia_valid & ATTR_GID) && - (!in_group_p(attr->ia_gid) && attr->ia_gid != inode->i_gid) && + ((!in_group_p(attr->ia_gid) && + attr->ia_gid != inode->i_gid) || context_mismatch) && !capable(CAP_CHOWN)) goto error; /* Make sure a caller can chmod. */ if (ia_valid & ATTR_MODE) { if (((current->fsuid != inode->i_uid) || - (current->s_context != inode->i_context)) && - !capable(CAP_FOWNER)) + context_mismatch) && !capable(CAP_FOWNER)) goto error; /* Also check the setgid bit! */ if (!in_group_p((ia_valid & ATTR_GID) ? attr->ia_gid : @@ -59,8 +61,7 @@ /* Check for setting the inode time. */ if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET)) { if (((current->fsuid != inode->i_uid) || - (current->s_context != inode->i_context)) && - !capable(CAP_FOWNER)) + context_mismatch) && !capable(CAP_FOWNER)) goto error; } fine: diff -NurBP --minimal linux-2.4.20-p8v13e-quota01/fs/locks.c linux-2.4.20-p8v13e-quota02/fs/locks.c --- linux-2.4.20-p8v13e-quota01/fs/locks.c Sat Oct 26 21:50:27 2002 +++ linux-2.4.20-p8v13e-quota02/fs/locks.c Sun Oct 27 21:56:14 2002 @@ -1271,8 +1271,9 @@ dentry = filp->f_dentry; inode = dentry->d_inode; - if (((current->fsuid != inode->i_uid) || - (current->s_context != inode->i_context)) && + if (((current->fsuid != inode->i_uid) || + ((inode->i_context != 0) && + (current->s_context != inode->i_context))) && !capable(CAP_LEASE)) return -EACCES; if (!S_ISREG(inode->i_mode)) diff -NurBP --minimal linux-2.4.20-p8v13e-quota01/fs/open.c linux-2.4.20-p8v13e-quota02/fs/open.c --- linux-2.4.20-p8v13e-quota01/fs/open.c Sat Oct 26 21:50:27 2002 +++ linux-2.4.20-p8v13e-quota02/fs/open.c Sun Oct 27 22:00:32 2002 @@ -281,7 +281,8 @@ newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET; } else { if (((current->fsuid != inode->i_uid) || - (current->s_context != inode->i_context)) && + ((inode->i_context != 0) && + (current->s_context != inode->i_context))) && (error = permission(inode,MAY_WRITE)) != 0) goto dput_and_out; } @@ -327,7 +328,8 @@ newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET; } else { if (((current->fsuid != inode->i_uid) || - (current->s_context != inode->i_context)) && + ((inode->i_context != 0) && + (current->s_context != inode->i_context))) && (error = permission(inode,MAY_WRITE)) != 0) goto dput_and_out; }