public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Marco Stornelli <marco.stornelli@gmail.com>
Cc: Vladimir Davydov <vdavydov@parallels.com>,
	linux-kernel@vger.kernel.org,
	Linux FS Devel <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH 12/19] pramfs: symlink operations
Date: Sat, 7 Sep 2013 15:41:18 +0100	[thread overview]
Message-ID: <20130907144118.GA13318@ZenIV.linux.org.uk> (raw)
In-Reply-To: <522AE3DB.7000209@gmail.com>

On Sat, Sep 07, 2013 at 10:29:15AM +0200, Marco Stornelli wrote:
> +static int pram_readlink(struct dentry *dentry, char __user *buffer, int buflen)
> +{
> +	struct inode *inode = dentry->d_inode;
> +	struct super_block *sb = inode->i_sb;
> +	u64 block;
> +	char *blockp;
> +
> +	block = pram_find_data_block(inode, 0);
> +	blockp = pram_get_block(sb, block);
> +	return vfs_readlink(dentry, buffer, buflen, blockp);
> +}

> +static void *pram_follow_link(struct dentry *dentry, struct nameidata *nd)
> +{
> +	struct inode *inode = dentry->d_inode;
> +	struct super_block *sb = inode->i_sb;
> +	off_t block;
> +	int status;
> +	char *blockp;
> +
> +	block = pram_find_data_block(inode, 0);
> +	blockp = pram_get_block(sb, block);
> +	status = vfs_follow_link(nd, blockp);
> +	return ERR_PTR(status);
> +}

Just nd_set_link(nd, blockp) instead of that vfs_follow_link() and be
done with that; that way you can use generic_readlink() instead of
pram_readlink() *and* get lower stack footprint on traversing them.

BTW, where's the error checking?  pram_get_block()/pram_find_data_block()
seem to assume that fs image isn't corrupted and if it is... that code
will happily dereference any address.  At least range checks of some sort
in pram_get_block() (and checking if it has failed) would be a good idea...

  reply	other threads:[~2013-09-07 14:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-07  8:29 [PATCH 12/19] pramfs: symlink operations Marco Stornelli
2013-09-07 14:41 ` Al Viro [this message]
2013-09-07 16:09   ` Marco Stornelli

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=20130907144118.GA13318@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marco.stornelli@gmail.com \
    --cc=vdavydov@parallels.com \
    /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