Skip to content

Commit b9cb981

Browse files
committed
[GFS2] Fix attributes setting logic
The attributes logic for immutable was wrong so that there was not way to remove this attribute once set. This fixes the bug. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
1 parent 9801f64 commit b9cb981

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

‎fs/gfs2/ops_file.c‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,10 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)
611611

612612
gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
613613
error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
614-
if (error)
614+
if (error) {
615+
gfs2_holder_uninit(&gh);
615616
return error;
617+
}
616618

617619
flags = ip->i_di.di_flags;
618620
new_flags = (flags & ~mask) | (reqflags & mask);
@@ -635,9 +637,14 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)
635637
goto out;
636638
if (IS_APPEND(inode) && (new_flags & GFS2_DIF_APPENDONLY))
637639
goto out;
638-
error = gfs2_repermission(inode, MAY_WRITE, NULL);
639-
if (error)
640+
if (((new_flags ^ flags) & GFS2_DIF_IMMUTABLE) &&
641+
!capable(CAP_LINUX_IMMUTABLE))
640642
goto out;
643+
if (!IS_IMMUTABLE(inode)) {
644+
error = gfs2_repermission(inode, MAY_WRITE, NULL);
645+
if (error)
646+
goto out;
647+
}
641648

642649
error = gfs2_trans_begin(sdp, RES_DINODE, 0);
643650
if (error)

0 commit comments

Comments
 (0)