Skip to contentSkip to conversation

gfs2: Remove incorrect permission check in gfs2_setattr

PATCH New Andreas Gruenbacher 2 participants 3 messages Oct 5, 2017 – Oct 6, 2017 GFS2 file system

lore
Share & tools
lore

Andreas Gruenbacher

author maintainer
#0 lore raw

PATCH 1/1 gfs2: Remove incorrect permission check in gfs2_setattr

Function notify_change already performs the necessary permission checks for immutable and append-only files, so there is no need to check again in setattr inode operations. What's worse, the check in gfs2_setattr prevents setting the atime and mtime of append-only files to the current time, which is supposed to be permitted.

Fixes xfstest generic/079.

---
 fs/gfs2/inode.c | 4 ----
 1 file changed, 4 deletions(-)
fs/gfs2/inode.c +0 -4
index 4749a6b8e4dd..05284dd2ae6c 100644
@@ -1940,10 +1940,6 @@ static int gfs2_setattr(struct dentry *dentry, struct iattr *attr)
 	if (error)
 		return error;
 
-	error = -EPERM;
-	if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
-		goto out;
-
 	error = setattr_prepare(dentry, attr);
 	if (error)
 		goto out;
Signature · 1 line
2.13.5
#1 lore raw

PATCH 1/1 gfs2: Remove incorrect permission check in gfs2_setattr

Hi,

Quoted 1 line · Andreas Gruenbacher

Function notify_change already performs the necessary permission checks

Does it do that under the glock? If not then it is racey which is probably why the second check was added,

Steve.

Quoted 27 lines

for immutable and append-only files, so there is no need to check again in setattr inode operations. What's worse, the check in gfs2_setattr prevents setting the atime and mtime of append-only files to the current time, which is supposed to be permitted.

Fixes xfstest generic/079.

---
  fs/gfs2/inode.c | 4 ----
  1 file changed, 4 deletions(-)
fs/gfs2/inode.c +0 -4
index 4749a6b8e4dd..05284dd2ae6c 100644
@@ -1940,10 +1940,6 @@ static int gfs2_setattr(struct dentry *dentry, struct iattr *attr)
  	if (error)
  		return error;
 
-	error = -EPERM;
-	if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
-		goto out;
-
  	error = setattr_prepare(dentry, attr);
  	if (error)
  		goto out;
author maintainer
#2 lore raw

PATCH 1/1 gfs2: Remove incorrect permission check in gfs2_setattr

Quoted 9 lines · Steven Whitehouse

Hi,

Quoted 2 lines · Andreas Gruenbacher

Function notify_change already performs the necessary permission checks

Does it do that under the glock? If not then it is racey which is probably why the second check was added,

Indeed, that is probably why the broken check was added here. Nowadays, those checks should probably be moved from notify_change to setattr_prepare to perform those checks only once, and at the right time. (According to the code, setattr_prepare should be called as the first thing in ->setattr implementations, possibly after taking additional locks.) There are a few other things in notify_change that check or manipulate the inode state as well.

Thanks,
Andreas