lkml.org 
[lkml]   [2008]   [Dec]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [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@mail.ru>
> Signed-off-by: Duane Griffin <duaneg@dghda.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


\
 
 \ /
  Last update: 2008-12-16 20:27    [W:2.139 / U:0.208 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site