Patchwork [1/1] eCryptfs: Copy up lower inode attrs after setting lower xattr

login
register
mail settings
Submitter Colin King
Date March 12, 2012, 9 p.m.
Message ID <1331586028-22746-2-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/146250/
State New
Headers show

Comments

Colin King - March 12, 2012, 9 p.m.
From: Tyler Hicks <tyhicks@canonical.com>

After passing through a ->setxattr() call, eCryptfs needs to copy the
inode attributes from the lower inode to the eCryptfs inode, as they
may have changed in the lower filesystem's ->setxattr() path.

One example is if an extended attribute containing a POSIX Access
Control List is being set. The new ACL may cause the lower filesystem to
modify the mode of the lower inode and the eCryptfs inode would need to
be updated to reflect the new mode.

https://launchpad.net/bugs/926292

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Reported-by: Sebastien Bacher <seb128@ubuntu.com>
Cc: John Johansen <john.johansen@canonical.com>
Cc: <stable@vger.kernel.org>
(cherry picked from commit 545d680938be1e86a6c5250701ce9abaf360c495)
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 fs/ecryptfs/inode.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Herton Ronaldo Krzesinski - March 12, 2012, 9:14 p.m.
On Mon, Mar 12, 2012 at 09:00:28PM +0000, Colin King wrote:
> From: Tyler Hicks <tyhicks@canonical.com>
> 
> After passing through a ->setxattr() call, eCryptfs needs to copy the
> inode attributes from the lower inode to the eCryptfs inode, as they
> may have changed in the lower filesystem's ->setxattr() path.
> 
> One example is if an extended attribute containing a POSIX Access
> Control List is being set. The new ACL may cause the lower filesystem to
> modify the mode of the lower inode and the eCryptfs inode would need to
> be updated to reflect the new mode.
> 
> https://launchpad.net/bugs/926292
> 
> Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
> Reported-by: Sebastien Bacher <seb128@ubuntu.com>
> Cc: John Johansen <john.johansen@canonical.com>
> Cc: <stable@vger.kernel.org>
> (cherry picked from commit 545d680938be1e86a6c5250701ce9abaf360c495)
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  fs/ecryptfs/inode.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
> index 19892d7..ab35b11 100644
> --- a/fs/ecryptfs/inode.c
> +++ b/fs/ecryptfs/inode.c
> @@ -1085,6 +1085,8 @@ ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value,
>  	}
>  
>  	rc = vfs_setxattr(lower_dentry, name, value, size, flags);
> +	if (!rc)
> +		fsstack_copy_attr_all(dentry->d_inode, lower_dentry->d_inode);
>  out:
>  	return rc;
>  }
> -- 
> 1.7.9.1
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
>
Andy Whitcroft - March 12, 2012, 9:45 p.m.
On Mon, Mar 12, 2012 at 09:00:28PM +0000, Colin King wrote:
> From: Tyler Hicks <tyhicks@canonical.com>
> 
> After passing through a ->setxattr() call, eCryptfs needs to copy the
> inode attributes from the lower inode to the eCryptfs inode, as they
> may have changed in the lower filesystem's ->setxattr() path.
> 
> One example is if an extended attribute containing a POSIX Access
> Control List is being set. The new ACL may cause the lower filesystem to
> modify the mode of the lower inode and the eCryptfs inode would need to
> be updated to reflect the new mode.
> 
> https://launchpad.net/bugs/926292
> 
> Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
> Reported-by: Sebastien Bacher <seb128@ubuntu.com>
> Cc: John Johansen <john.johansen@canonical.com>
> Cc: <stable@vger.kernel.org>
> (cherry picked from commit 545d680938be1e86a6c5250701ce9abaf360c495)
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  fs/ecryptfs/inode.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
> index 19892d7..ab35b11 100644
> --- a/fs/ecryptfs/inode.c
> +++ b/fs/ecryptfs/inode.c
> @@ -1085,6 +1085,8 @@ ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value,
>  	}
>  
>  	rc = vfs_setxattr(lower_dentry, name, value, size, flags);
> +	if (!rc)
> +		fsstack_copy_attr_all(dentry->d_inode, lower_dentry->d_inode);
>  out:
>  	return rc;
>  }

Looks to do what is claimed.

Acked-by: Andy Whitcroft <apw@canonical.com>

-apw

Patch

diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 19892d7..ab35b11 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -1085,6 +1085,8 @@  ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value,
 	}
 
 	rc = vfs_setxattr(lower_dentry, name, value, size, flags);
+	if (!rc)
+		fsstack_copy_attr_all(dentry->d_inode, lower_dentry->d_inode);
 out:
 	return rc;
 }