summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2006-12-06 20:37:33 -0800
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-07 08:39:37 -0800
commit93f210dd9e614ddab7ecef0b4c9ba6ad3720d860 (patch)
treef16d960d7a9e85b2405ae323246e9b6c8aec68bc /fs
parentf5738ceed46782aea7663d62cb6398eb05fc4ce0 (diff)
[PATCH] protect ext2 ioctl modifying append_only immutable etc with i_mutex
Port commit a090d9132c1e53e3517111123680c15afb25c0a4 into ext2: All modifications of ->i_flags in inodes that might be visible to somebody else must be under ->i_mutex. That patch fixes ext2 ioctl() setting S_APPEND. Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/ext2/ioctl.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c
index 1dfba77eab10..e3cf8c81507f 100644
--- a/fs/ext2/ioctl.c
+++ b/fs/ext2/ioctl.c
@@ -44,6 +44,7 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
if (!S_ISDIR(inode->i_mode))
flags &= ~EXT2_DIRSYNC_FL;
+ mutex_lock(&inode->i_mutex);
oldflags = ei->i_flags;
/*
@@ -53,13 +54,16 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
* This test looks nicer. Thanks to Pauline Middelink
*/
if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
- if (!capable(CAP_LINUX_IMMUTABLE))
+ if (!capable(CAP_LINUX_IMMUTABLE)) {
+ mutex_unlock(&inode->i_mutex);
return -EPERM;
+ }
}
flags = flags & EXT2_FL_USER_MODIFIABLE;
flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
ei->i_flags = flags;
+ mutex_unlock(&inode->i_mutex);
ext2_set_inode_flags(inode);
inode->i_ctime = CURRENT_TIME_SEC;