Skip to content

Commit 743b5f1

Browse files
Tariq Saeedtorvalds
authored andcommitted
ocfs2: take inode lock in ocfs2_iop_set/get_acl()
This bug in mainline code is pointed out by Mark Fasheh. When ocfs2_iop_set_acl() and ocfs2_iop_get_acl() are entered from VFS layer, inode lock is not held. This seems to be regression from older kernels. The patch is to fix that. Orabug: 20189959 Signed-off-by: Tariq Saeed <tariq.x.saeed@oracle.com> Reviewed-by: Mark Fasheh <mfasheh@suse.de> Cc: Joel Becker <jlbec@evilplan.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 3d46a44 commit 743b5f1

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

fs/ocfs2/acl.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,27 +284,41 @@ int ocfs2_set_acl(handle_t *handle,
284284

285285
int ocfs2_iop_set_acl(struct inode *inode, struct posix_acl *acl, int type)
286286
{
287-
return ocfs2_set_acl(NULL, inode, NULL, type, acl, NULL, NULL);
287+
struct buffer_head *bh = NULL;
288+
int status = 0;
289+
290+
status = ocfs2_inode_lock(inode, &bh, 1);
291+
if (status < 0) {
292+
if (status != -ENOENT)
293+
mlog_errno(status);
294+
return status;
295+
}
296+
status = ocfs2_set_acl(NULL, inode, bh, type, acl, NULL, NULL);
297+
ocfs2_inode_unlock(inode, 1);
298+
brelse(bh);
299+
return status;
288300
}
289301

290302
struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type)
291303
{
292304
struct ocfs2_super *osb;
293305
struct buffer_head *di_bh = NULL;
294306
struct posix_acl *acl;
295-
int ret = -EAGAIN;
307+
int ret;
296308

297309
osb = OCFS2_SB(inode->i_sb);
298310
if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
299311
return NULL;
300-
301-
ret = ocfs2_read_inode_block(inode, &di_bh);
302-
if (ret < 0)
312+
ret = ocfs2_inode_lock(inode, &di_bh, 0);
313+
if (ret < 0) {
314+
if (ret != -ENOENT)
315+
mlog_errno(ret);
303316
return ERR_PTR(ret);
317+
}
304318

305319
acl = ocfs2_get_acl_nolock(inode, type, di_bh);
306320

321+
ocfs2_inode_unlock(inode, 0);
307322
brelse(di_bh);
308-
309323
return acl;
310324
}

0 commit comments

Comments
 (0)