gfs2: Remove incorrect permission check in gfs2_setattr
Andreas Gruenbacher
maintainerPATCH 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
@@ -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
PATCH 1/1 gfs2: Remove incorrect permission check in gfs2_setattr
Hi,
Quoted 1 line · Andreas Gruenbacher
Function
notify_changealready 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_setattrprevents setting the atime and mtime of append-only files to the current time, which is supposed to be permitted.Fixes xfstest generic/079.
Signed-off-by Andreas Gruenbacher <[email protected]>--- fs/gfs2/inode.c | 4 ---- 1 file changed, 4 deletions(-)fs/gfs2/inode.c +0
-4@@ -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;
Andreas Gruenbacher
maintainerPATCH 1/1 gfs2: Remove incorrect permission check in gfs2_setattr
Quoted 9 lines · Steven Whitehouse
Hi,
Quoted 2 lines · Andreas Gruenbacher
Function
notify_changealready performs the necessary permission checksDoes 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