Skip to content

Commit 7df0e03

Browse files
committed
GFS2: Fix permissions checking for setflags ioctl()
We should be checking for the ownership of the file for which flags are being set, rather than just for write access. Reported-by: Dan Rosenberg <[email protected]> Signed-off-by: Steven Whitehouse <[email protected]>
1 parent f72f2d2 commit 7df0e03

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

fs/gfs2/file.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)
218218
if (error)
219219
goto out_drop_write;
220220

221+
error = -EACCES;
222+
if (!is_owner_or_cap(inode))
223+
goto out;
224+
225+
error = 0;
221226
flags = ip->i_diskflags;
222227
new_flags = (flags & ~mask) | (reqflags & mask);
223228
if ((new_flags ^ flags) == 0)
@@ -275,8 +280,10 @@ static int gfs2_set_flags(struct file *filp, u32 __user *ptr)
275280
{
276281
struct inode *inode = filp->f_path.dentry->d_inode;
277282
u32 fsflags, gfsflags;
283+
278284
if (get_user(fsflags, ptr))
279285
return -EFAULT;
286+
280287
gfsflags = fsflags_cvt(fsflags_to_gfs2, fsflags);
281288
if (!S_ISDIR(inode->i_mode)) {
282289
if (gfsflags & GFS2_DIF_INHERIT_JDATA)

0 commit comments

Comments
 (0)