2010-05-27 08:27:12

by Miao Xie

[permalink] [raw]
Subject: [PATCH] ext3: fix non-update ctime when changing the file's permission by setfacl

ext3 didn't update the ctime of the file when its permission was changed.

Steps to reproduce:
# touch aaa
# stat -c %Z aaa
1275289822
# setfacl -m 'u::x,g::x,o::x' aaa
# stat -c %Z aaa
1275289822 <- unchanged

But, according to the spec of the ctime, ext3 must update it.

Signed-off-by: Miao Xie <[email protected]>
---
fs/ext3/acl.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/fs/ext3/acl.c b/fs/ext3/acl.c
index 01552ab..8a11fe2 100644
--- a/fs/ext3/acl.c
+++ b/fs/ext3/acl.c
@@ -205,6 +205,7 @@ ext3_set_acl(handle_t *handle, struct inode *inode, int type,
return error;
else {
inode->i_mode = mode;
+ inode->i_ctime = CURRENT_TIME_SEC;
ext3_mark_inode_dirty(handle, inode);
if (error == 0)
acl = NULL;
--
1.6.5.2




2010-06-02 12:14:43

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH] ext3: fix non-update ctime when changing the file's permission by setfacl

> ext3 didn't update the ctime of the file when its permission was changed.
>
> Steps to reproduce:
> # touch aaa
> # stat -c %Z aaa
> 1275289822
> # setfacl -m 'u::x,g::x,o::x' aaa
> # stat -c %Z aaa
> 1275289822 <- unchanged
>
> But, according to the spec of the ctime, ext3 must update it.
Yeah, good spotting. Thanks. Looking at various code, the bug was probably
cut-n-pasted to all the filesystems (except XFS)... Sigh. It would be nice to
handle this somehow generically in VFS but currently I don't see a way. So
probably I'll take filesystems one by one and fix them.

Honza
>
> Signed-off-by: Miao Xie <[email protected]>
> ---
> fs/ext3/acl.c | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/fs/ext3/acl.c b/fs/ext3/acl.c
> index 01552ab..8a11fe2 100644
> --- a/fs/ext3/acl.c
> +++ b/fs/ext3/acl.c
> @@ -205,6 +205,7 @@ ext3_set_acl(handle_t *handle, struct inode *inode, int type,
> return error;
> else {
> inode->i_mode = mode;
> + inode->i_ctime = CURRENT_TIME_SEC;
> ext3_mark_inode_dirty(handle, inode);
> if (error == 0)
> acl = NULL;
> --
> 1.6.5.2
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Jan Kara <[email protected]>
SuSE CR Labs