[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20081216194053.GA17671@rain>
Date: Tue, 16 Dec 2008 22:40:55 +0300
From: Evgeniy Dushistov <dushistov@...l.ru>
To: Duane Griffin <duaneg@...da.com>
Cc: linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH] ufs: ensure fast symlinks are NUL-terminated
On Tue, Dec 16, 2008 at 03:51:58PM +0000, Duane Griffin wrote:
> Ensure fast symlink targets are NUL-terminated, even if corrupted
> on-disk.
>
> Cc: Evgeniy Dushistov <dushistov@...l.ru>
> Signed-off-by: Duane Griffin <duaneg@...da.com>
> ---
> fs/ufs/inode.c | 8 ++++++--
> 1 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
> index 39f8778..aca4b58 100644
> --- a/fs/ufs/inode.c
> +++ b/fs/ufs/inode.c
> @@ -36,6 +36,7 @@
> #include <linux/mm.h>
> #include <linux/smp_lock.h>
> #include <linux/buffer_head.h>
> +#include <linux/namei.h>
>
> #include "ufs_fs.h"
> #include "ufs.h"
> @@ -606,9 +607,12 @@ static void ufs_set_inode_ops(struct inode *inode)
> inode->i_fop = &ufs_dir_operations;
> inode->i_mapping->a_ops = &ufs_aops;
> } else if (S_ISLNK(inode->i_mode)) {
> - if (!inode->i_blocks)
> + if (!inode->i_blocks) {
> inode->i_op = &ufs_fast_symlink_inode_operations;
> - else {
> + nd_terminate_link(UFS_I(inode)->i_u1.i_symlink,
> + inode->i_size,
> + sizeof(UFS_I(inode)->i_u1.i_symlink));
> + } else {
> inode->i_op = &page_symlink_inode_operations;
> inode->i_mapping->a_ops = &ufs_aops;
> }
> --
> 1.6.0.4
There is different types of ufs, one used 64 bit for "pointers to
blocks", another 32 bit,
so sizeof(UFS_I(inode)->i_u1.i_symlink))
is not right choice every time,
in ufs2 it should be
sizeof(UFS_I(inode)->i_u1.u2_i_data) which 2 times bigger,
also there is hint for *BSD ufs
fs/ufs/ufs_fs.h:
__fs32 fs_maxsymlinklen;/* max length of an internal symlink */
which may be used if ufs type ufs1 or ufs2
--
/Evgeniy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists