I'm just working on LFS support for ext3, and I noticed that in
ext[23]_notify_change() the testing for ATTR_ATTR_FLAG is quite
different between ext2 (2.2.18) and ext3, and one of them is wrong.
In ext2_notify_change() we have:
if (iattr->ia_valid & ATTR_ATTR_FLAG)
{
if((!(iattr->ia_attr_flags & ATTR_FLAG_APPEND) !=
!(inode->u.ext2_i.i_flags & EXT2_APPEND_FL)) ||
(!(iattr->ia_attr_flags & ATTR_FLAG_IMMUTABLE) !=
!(inode->u.ext2_i.i_flags & EXT2_IMMUTABLE_FL))) {
if (!capable(CAP_LINUX_IMMUTABLE))
goto out;
}
else if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
goto out;
}
and in ext3_notify_change() we have:
if (iattr->ia_valid & ATTR_ATTR_FLAG) {
if ((iattr->ia_attr_flags &
(ATTR_FLAG_APPEND | ATTR_FLAG_IMMUTABLE)) ^
(inode->u.ext3_i.i_flags &
(EXT3_APPEND_FL | EXT3_IMMUTABLE_FL))) {
if (!capable(CAP_LINUX_IMMUTABLE))
goto out;
}
}
if (iattr->ia_valid & ATTR_UID) {
if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
goto out;
}
Looking at 2.4.0 fs/ext2/inode.c, I now think both of the 2.2 versions
are wrong. The ext2 code is wrong because the fsuid/capable checks are
inside the ATTR_ATTR_FLAG test, and the ext3 code is wrong because it
assumes that ATTR_FLAG_APPEND and ATTR_FLAG_IMMUTABLE are the same values
as EXT3_APPEND_FL and EXT3_IMMUTABLE_FL. It appears 2.4 is right with:
if (iattr->ia_valid & ATTR_ATTR_FLAG &&
((!(iattr->ia_attr_flags & ATTR_FLAG_APPEND) !=
!(inode->u.ext2_i.i_flags & EXT2_APPEND_FL)) ||
(!(iattr->ia_attr_flags & ATTR_FLAG_IMMUTABLE) !=
!(inode->u.ext2_i.i_flags & EXT2_IMMUTABLE_FL)))) {
if (!capable(CAP_LINUX_IMMUTABLE))
goto out;
} else if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
goto out;
Unless someone tells me I'm out to lunch, I will send out a fix for ext2 2.2
(I can't see any patch in 2.2.19-pre7 for this), and the ext3 fix will be
included in my ext3 LFS patch, which is due today or tomorrow.
Cheers, Andreas
--
Andreas Dilger \ "If a man ate a pound of pasta and a pound of antipasto,
\ would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/ -- Dogbert
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [EMAIL PROTECTED]