Skip to content

Commit f070e5a

Browse files
eaferkleikamp
authored andcommitted
jfs: preserve i_mode if __jfs_set_acl() fails
When changing a file's acl mask, __jfs_set_acl() will first set the group bits of i_mode to the value of the mask, and only then set the actual extended attribute representing the new acl. If the second part fails (due to lack of space, for example) and the file had no acl attribute to begin with, the system will from now on assume that the mask permission bits are actual group permission bits, potentially granting access to the wrong users. Prevent this by only changing the inode mode after the acl has been set. Signed-off-by: Ernesto A. Fernández <[email protected]> Signed-off-by: Dave Kleikamp <[email protected]>
1 parent 9bcf66c commit f070e5a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

fs/jfs/acl.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,26 @@ int jfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
108108
{
109109
int rc;
110110
tid_t tid;
111+
int update_mode = 0;
112+
umode_t mode = inode->i_mode;
111113

112114
tid = txBegin(inode->i_sb, 0);
113115
mutex_lock(&JFS_IP(inode)->commit_mutex);
114116
if (type == ACL_TYPE_ACCESS && acl) {
115-
rc = posix_acl_update_mode(inode, &inode->i_mode, &acl);
117+
rc = posix_acl_update_mode(inode, &mode, &acl);
116118
if (rc)
117119
goto end_tx;
118-
inode->i_ctime = current_time(inode);
119-
mark_inode_dirty(inode);
120+
update_mode = 1;
120121
}
121122
rc = __jfs_set_acl(tid, inode, type, acl);
122-
if (!rc)
123+
if (!rc) {
124+
if (update_mode) {
125+
inode->i_mode = mode;
126+
inode->i_ctime = current_time(inode);
127+
mark_inode_dirty(inode);
128+
}
123129
rc = txCommit(tid, 1, &inode, 0);
130+
}
124131
end_tx:
125132
txEnd(tid);
126133
mutex_unlock(&JFS_IP(inode)->commit_mutex);

0 commit comments

Comments
 (0)