[PATCH] protect ext3 ioctl modifying append_only, immutable, etc. with i_mutex

[PATCH] protect ext3 ioctl modifying append_only, immutable, etc. with i_mutex

Post by Al Vir » Thu, 27 Apr 2006 15:40:13



All modifications of ->i_flags in inodes that might be visible to
somebody else must be under ->i_mutex. That patch fixes ext3 ioctl()
setting S_APPEND and friends.

Signed-off-by: Al Viro < XXXX@XXXXX.COM >

---

fs/ext3/ioctl.c | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)

48ef5cddd158b0bbce7b646a16ba9ce3c599b0f1
diff --git a/fs/ext3/ioctl.c b/fs/ext3/ioctl.c
index aaf1da1..8c22aa9 100644
--- a/fs/ext3/ioctl.c
+++ b/fs/ext3/ioctl.c
@@ -48,6 +48,7 @@ int ext3_ioctl (struct inode * inode, st
if (!S_ISDIR(inode->i_mode))
flags &= ~EXT3_DIRSYNC_FL;

+ mutex_lock(&inode->i_mutex);
oldflags = ei->i_flags;

/* The JOURNAL_DATA flag is modifiable only by root */
@@ -60,8 +61,10 @@ int ext3_ioctl (struct inode * inode, st
* This test looks nicer. Thanks to Pauline Middelink
*/
if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
- if (!capable(CAP_LINUX_IMMUTABLE))
+ if (!capable(CAP_LINUX_IMMUTABLE)) {
+ mutex_unlock(&inode->i_mutex);
return -EPERM;
+ }
}

/*
@@ -69,14 +72,18 @@ int ext3_ioctl (struct inode * inode, st
* the relevant capability.
*/
if ((jflag ^ oldflags) & (EXT3_JOURNAL_DATA_FL)) {
- if (!capable(CAP_SYS_RESOURCE))
+ if (!capable(CAP_SYS_RESOURCE)) {
+ mutex_unlock(&inode->i_mutex);
return -EPERM;
+ }
}


handle = ext3_journal_start(inode, 1);
- if (IS_ERR(handle))
+ if (IS_ERR(handle)) {
+ mutex_unlock(&inode->i_mutex);
return PTR_ERR(handle);
+ }
if (IS_SYNC(inode))
handle->h_sync = 1;
err = ext3_reserve_inode_write(handle, inode, &iloc);
@@ -93,11 +100,14 @@ int ext3_ioctl (struct inode * inode, st
err = ext3_mark_iloc_dirty(handle, inode, &iloc);
flags_err:
ext3_journal_stop(handle);
- if (err)
+ if (err) {
+ mutex_unlock(&inode->i_mutex);
return err;
+ }

if ((jflag ^ oldflags) & (EXT3_JOURNAL_DATA_FL))
err = ext3_change_inode_journal_flag(inode, jflag);
+ mutex_unlock(&inode->i_mutex);
return err;
}
case EXT3_IOC_GETVERSION:
--
1.3.0.g0080f

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to XXXX@XXXXX.COM
More majordomo info at http://www.yqcomputer.com/
Please read the FAQ at http://www.yqcomputer.com/
 
 
 

1. [PATCH 1/4] ext3 block reservation patch set -- ext3 preallocation cleanup

2. [PATCH 2/4] ext3 block reservation patch set --ext3 block reservation


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to XXXX@XXXXX.COM
More majordomo info at http://www.yqcomputer.com/
Please read the FAQ at http://www.yqcomputer.com/
-basic reservation structure and operations
-reservation based ext3 block allocation

diffstat ext3_rsv_base.patch
fs/ext3/balloc.c | 548
++++++++++++++++++++++++++++++++++++++++-----
fs/ext3/file.c | 2
fs/ext3/ialloc.c | 5
fs/ext3/inode.c | 9
fs/ext3/super.c | 7
include/linux/ext3_fs.h | 6
include/linux/ext3_fs_i.h | 12
include/linux/ext3_fs_sb.h | 4
8 files changed, 542 insertions(+), 51 deletions(-)

3. [PATCH 14/18] [PATCH] BLOCK: Move the Ext3 device ioctl compat stuff to the Ext3 driver [try #4]

4. [PATCH 14/18] [PATCH] BLOCK: Move the Ext3 device ioctl compat stuff to the Ext3 driver [try #3]

5. [patch] sched, ext3: fix scheduling latencies in ext3

6. [Patch 4/6]: ext3 reservations: Turn ext3 per-sb reservations list into an rbtree.

7. [PATCH] compat USB ioctl take II was compat ioctl for submiting URB

8. [Patch 2/6]: ext3 reservations: Renumber the ext3 reservations ioctls

9. [patch 04/16] ext3: fix race between ext3 make block reservation and reservation window discard

10. [PATCH] EXT3: ext3 block bitmap leakage

11. [PATCH-2.4] EXT3: ext3 block bitmap leakage

12. [patch 04/16] ext3: fix race between ext3 make block reservation and reservation window discard

13. [Patch 4/6]: ext3 reservations: Turn ext3 per-sb reservations list into an rbtree.

14. [Patch 4/6]: ext3 reservations: Turn ext3 per-sb reservations list into an rbtree.

15. [Patch 2/6]: ext3 reservations: Renumber the ext3 reservations ioctls