hc
2024-05-11 297b60346df8beafee954a0fd7c2d64f33f3b9bc
kernel/fs/ext2/ioctl.c
....@@ -60,18 +60,10 @@
6060 }
6161 oldflags = ei->i_flags;
6262
63
- /*
64
- * The IMMUTABLE and APPEND_ONLY flags can only be changed by
65
- * the relevant capability.
66
- *
67
- * This test looks nicer. Thanks to Pauline Middelink
68
- */
69
- if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
70
- if (!capable(CAP_LINUX_IMMUTABLE)) {
71
- inode_unlock(inode);
72
- ret = -EPERM;
73
- goto setflags_out;
74
- }
63
+ ret = vfs_ioc_setflags_prepare(inode, oldflags, flags);
64
+ if (ret) {
65
+ inode_unlock(inode);
66
+ goto setflags_out;
7567 }
7668
7769 flags = flags & EXT2_FL_USER_MODIFIABLE;
....@@ -153,10 +145,13 @@
153145 if (ei->i_block_alloc_info){
154146 struct ext2_reserve_window_node *rsv = &ei->i_block_alloc_info->rsv_window_node;
155147 rsv->rsv_goal_size = rsv_window_size;
148
+ } else {
149
+ ret = -ENOMEM;
156150 }
151
+
157152 mutex_unlock(&ei->truncate_mutex);
158153 mnt_drop_write_file(filp);
159
- return 0;
154
+ return ret;
160155 }
161156 default:
162157 return -ENOTTY;