Skip to content

Commit 95f4e9f

Browse files
dhowellsgregkh
authored andcommitted
afs: Fix updating of i_mode due to 3rd party change
[ Upstream commit 6e1eb04 ] Fix afs_apply_status() to mask off the irrelevant bits from status->mode when OR'ing them into i_mode. This can happen when a 3rd party chmod occurs. Also fix afs_inode_init_from_status() to mask off the mode bits when initialising i_mode. Fixes: 260a980 ("[AFS]: Add "directory write" support.") Reported-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 80862cb commit 95f4e9f

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎fs/afs/inode.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ static int afs_inode_init_from_status(struct afs_operation *op,
102102

103103
switch (status->type) {
104104
case AFS_FTYPE_FILE:
105-
inode->i_mode = S_IFREG | status->mode;
105+
inode->i_mode = S_IFREG | (status->mode & S_IALLUGO);
106106
inode->i_op = &afs_file_inode_operations;
107107
inode->i_fop = &afs_file_operations;
108108
inode->i_mapping->a_ops = &afs_fs_aops;
109109
break;
110110
case AFS_FTYPE_DIR:
111-
inode->i_mode = S_IFDIR | status->mode;
111+
inode->i_mode = S_IFDIR | (status->mode & S_IALLUGO);
112112
inode->i_op = &afs_dir_inode_operations;
113113
inode->i_fop = &afs_dir_file_operations;
114114
inode->i_mapping->a_ops = &afs_dir_aops;
@@ -198,7 +198,7 @@ static void afs_apply_status(struct afs_operation *op,
198198
if (status->mode != vnode->status.mode) {
199199
mode = inode->i_mode;
200200
mode &= ~S_IALLUGO;
201-
mode |= status->mode;
201+
mode |= status->mode & S_IALLUGO;
202202
WRITE_ONCE(inode->i_mode, mode);
203203
}
204204

0 commit comments

Comments
 (0)