mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Trond Myklebust <trond.myklebust@fys.uio.no>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/7] fuse: check directory aliasing in mkdir
Date: Mon, 28 Nov 2005 14:57:11 -0500	[thread overview]
Message-ID: <1133207831.27574.95.camel@lade.trondhjem.org> (raw)
In-Reply-To: <E1EgouE-0006sp-00@dorka.pomaz.szeredi.hu>

On Mon, 2005-11-28 at 20:43 +0100, Miklos Szeredi wrote:
> Check the created directory inode for aliases in the mkdir() method.


Can't you use d_add_unique() here?

Cheers,
  Trond

> Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>
> 
> ---
> Index: linux/fs/fuse/dir.c
> ===================================================================
> --- linux.orig/fs/fuse/dir.c	2005-11-28 14:01:08.000000000 +0100
> +++ linux/fs/fuse/dir.c	2005-11-28 14:01:52.000000000 +0100
> @@ -74,6 +74,19 @@ static int fuse_dentry_revalidate(struct
>  	return 1;
>  }
>  
> +static int dir_alias(struct inode *inode)
> +{
> +	if (S_ISDIR(inode->i_mode)) {
> +		/* Don't allow creating an alias to a directory  */
> +		struct dentry *alias = d_find_alias(inode);
> +		if (alias) {
> +			dput(alias);
> +			return 1;
> +		}
> +	}
> +	return 0;
> +}
> +
>  static struct dentry_operations fuse_dentry_operations = {
>  	.d_revalidate	= fuse_dentry_revalidate,
>  };
> @@ -263,7 +276,7 @@ static int create_new_entry(struct fuse_
>  	fuse_put_request(fc, req);
>  
>  	/* Don't allow userspace to do really stupid things... */
> -	if ((inode->i_mode ^ mode) & S_IFMT) {
> +	if (((inode->i_mode ^ mode) & S_IFMT) || dir_alias(inode)) {
>  		iput(inode);
>  		return -EIO;
>  	}
> @@ -874,14 +887,9 @@ static struct dentry *fuse_lookup(struct
>  	err = fuse_lookup_iget(dir, entry, &inode);
>  	if (err)
>  		return ERR_PTR(err);
> -	if (inode && S_ISDIR(inode->i_mode)) {
> -		/* Don't allow creating an alias to a directory  */
> -		struct dentry *alias = d_find_alias(inode);
> -		if (alias) {
> -			dput(alias);
> -			iput(inode);
> -			return ERR_PTR(-EIO);
> -		}
> +	if (inode && dir_alias(inode)) {
> +		iput(inode);
> +		return ERR_PTR(-EIO);
>  	}
>  	d_add(entry, inode);
>  	return NULL;
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


  parent reply	other threads:[~2005-11-28 19:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-28 19:41 [PATCH 0/7] fuse updates Miklos Szeredi
2005-11-28 19:43 ` [PATCH 1/7] fuse: check directory aliasing in mkdir Miklos Szeredi
2005-11-28 19:45   ` [PATCH 2/7] fuse: check for invalid node ID in fuse_create_open() Miklos Szeredi
2005-11-28 19:46     ` [PATCH 3/7] fuse: clean up fuse_lookup() Miklos Szeredi
2005-11-28 19:47       ` [PATCH 4/7] fuse: clean up page offset calculation Miklos Szeredi
2005-11-28 19:49         ` [PATCH 5/7] fuse: bump interface version Miklos Szeredi
2005-11-28 19:50           ` [PATCH 6/7] fuse: add frsize to statfs reply Miklos Szeredi
2005-11-28 19:51             ` [PATCH 7/7] fuse: support caching negative dentries Miklos Szeredi
2005-11-28 20:40               ` Andrew Morton
2005-11-28 21:06                 ` Miklos Szeredi
2005-11-28 19:57   ` Trond Myklebust [this message]
2005-11-28 20:09     ` [PATCH 1/7] fuse: check directory aliasing in mkdir Miklos Szeredi

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=1133207831.27574.95.camel@lade.trondhjem.org \
    --to=trond.myklebust@fys.uio.no \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®