Re: [syzbot] [ocfs2?] possible deadlock in ocfs2_setattr

From: Edward Adam Davis
Date: Wed Aug 21 2024 - 07:05:10 EST


use trylock to replace

#syz test: upstream 521b1e7f4cf0

diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c
index 62464d194da3..f60e3178fe74 100644
--- a/fs/ocfs2/acl.c
+++ b/fs/ocfs2/acl.c
@@ -363,7 +363,8 @@ int ocfs2_init_acl(handle_t *handle,

if (!S_ISLNK(inode->i_mode)) {
if (osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) {
- down_read(&OCFS2_I(dir)->ip_xattr_sem);
+ if (!down_read_trylock(&OCFS2_I(dir)->ip_xattr_sem))
+ return -EBUSY;
acl = ocfs2_get_acl_nolock(dir, ACL_TYPE_DEFAULT,
dir_bh);
up_read(&OCFS2_I(dir)->ip_xattr_sem);