All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tyler Hicks <tyhicks@linux.vnet.ibm.com>
To: Erez Zadok <ezk@cs.sunysb.edu>
Cc: Dustin Kirkland <kirkland@canonical.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] ecryptfs: don't ignore return value from lock_rename
Date: Mon, 7 Dec 2009 15:46:06 -0600	[thread overview]
Message-ID: <20091207214606.GA9807@fedora-virt> (raw)
In-Reply-To: <200912060217.nB62H945020961@agora.fsl.cs.sunysb.edu>

On Sat Dec 05, 2009 at 09:17:09PM -0500, Erez Zadok (ezk@cs.sunysb.edu) was quoted:
> Tyler/Dustin,
> 
> Here's another patch: use return value from lock_rename() in
> ecryptfs_rename, and properly check that return value.  I've tested it
> briefly with ecryptfs: moved some files/directories at both the same level,
> as well as into subdirectories which may share a common ancestor.  Things
> seem to work, but perhaps more testing is needed.
> 
> BTW, identical code to this has been running in Unionfs for a couple of
> years, so I'm reasonably confident that this patch is correct.
> 
> diffstat:
>  inode.c |   13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> Cheers,
> Erez.
> 
> ------------------------------------------------------------------------------
> 
> ecryptfs: don't ignore return value from lock_rename
> 
> Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>

Looks correct to me - thanks!

Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/ecryptfs/ecryptfs-2.6.git#next

> diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
> index 429ca0b..e4dd0c6 100644
> --- a/fs/ecryptfs/inode.c
> +++ b/fs/ecryptfs/inode.c
> @@ -614,6 +614,7 @@ ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	struct dentry *lower_new_dentry;
>  	struct dentry *lower_old_dir_dentry;
>  	struct dentry *lower_new_dir_dentry;
> +	struct dentry *trap = NULL;
> 
>  	lower_old_dentry = ecryptfs_dentry_to_lower(old_dentry);
>  	lower_new_dentry = ecryptfs_dentry_to_lower(new_dentry);
> @@ -621,7 +622,17 @@ ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	dget(lower_new_dentry);
>  	lower_old_dir_dentry = dget_parent(lower_old_dentry);
>  	lower_new_dir_dentry = dget_parent(lower_new_dentry);
> -	lock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
> +	trap = lock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
> +	/* source should not be ancestor of target */
> +	if (trap == lower_old_dentry) {
> +		rc = -EINVAL;
> +		goto out_lock;
> +	}
> +	/* target should not be ancestor of source */
> +	if (trap == lower_new_dentry) {
> +		rc = -ENOTEMPTY;
> +		goto out_lock;
> +	}
>  	rc = vfs_rename(lower_old_dir_dentry->d_inode, lower_old_dentry,
>  			lower_new_dir_dentry->d_inode, lower_new_dentry);
>  	if (rc)

      reply	other threads:[~2009-12-07 21:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-06  2:17 [PATCH] ecryptfs: don't ignore return value from lock_rename Erez Zadok
2009-12-07 21:46 ` Tyler Hicks [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091207214606.GA9807@fedora-virt \
    --to=tyhicks@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=ezk@cs.sunysb.edu \
    --cc=kirkland@canonical.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.