From: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
To: Duane Griffin <duaneg@dghda.com>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Boaz Harrosh <bharrosh@panasas.com>,
Dave.Kleikamp.shaggy@austin.ibm.com,
jfs-discussion@lists.sourceforge.net
Subject: Re: [PATCH] JFS: ensure link targets are NULL-terminated
Date: Thu, 11 Dec 2008 14:06:11 -0600 [thread overview]
Message-ID: <1229025971.9245.18.camel@norville.austin.ibm.com> (raw)
In-Reply-To: <1229022995-9898-9-git-send-email-duaneg@dghda.com>
On Thu, 2008-12-11 at 19:16 +0000, Duane Griffin wrote:
> Ensure link targets are NULL-terminated, even if corrupted on-disk.
>
> Signed-off-by: Duane Griffin <duaneg@dghda.com>
> ---
> fs/jfs/symlink.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/fs/jfs/symlink.c b/fs/jfs/symlink.c
> index 4af1a05..f5f1b5d 100644
> --- a/fs/jfs/symlink.c
> +++ b/fs/jfs/symlink.c
> @@ -18,6 +18,7 @@
>
> #include <linux/fs.h>
> #include <linux/namei.h>
> +#include "jfs_filsys.h"
> #include "jfs_incore.h"
> #include "jfs_inode.h"
> #include "jfs_xattr.h"
> @@ -25,6 +26,7 @@
> static void *jfs_follow_link(struct dentry *dentry, struct nameidata *nd)
> {
> char *s = JFS_IP(dentry->d_inode)->i_inline;
> + s[IDATASIZE - 1] = '\0';
> nd_set_link(nd, s);
> return NULL;
> }
Thanks.
I came up with an alternate patch that I like slightly better. This one
null-terminates the string when the inode is read rather than every time
the link is followed, and at the proper place (i_size). It's not a big
deal, since the symlink will be corrupted either way. What do you think
of this patch?
Signed-off-by: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 2103397..b00ee9f 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -59,8 +59,14 @@ struct inode *jfs_iget(struct super_block *sb, unsigned long ino)
if (inode->i_size >= IDATASIZE) {
inode->i_op = &page_symlink_inode_operations;
inode->i_mapping->a_ops = &jfs_aops;
- } else
+ } else {
inode->i_op = &jfs_symlink_inode_operations;
+ /*
+ * The inline data should be null-terminated, but
+ * don't let on-disk corruption crash the kernel
+ */
+ JFS_IP(inode)->i_inline[inode->i_size] = '\0';
+ }
} else {
inode->i_op = &jfs_file_inode_operations;
init_special_inode(inode, inode->i_mode, inode->i_rdev);
--
David Kleikamp
IBM Linux Technology Center
next prev parent reply other threads:[~2008-12-11 20:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-11 19:16 [PATCH 0/11] make link target handling more robust Duane Griffin
[not found] ` <1229022995-9898-2-git-send-email-duaneg@dghda.com>
[not found] ` <1229022995-9898-3-git-send-email-duaneg@dghda.com>
[not found] ` <1229022995-9898-4-git-send-email-duaneg@dghda.com>
2008-12-11 19:16 ` [PATCH] ext2: ensure link targets are NULL-terminated Duane Griffin
2008-12-11 19:21 ` Matthew Wilcox
2008-12-11 20:25 ` Duane Griffin
2008-12-11 22:23 ` [PATCH, v2] ext2: ensure link targets are NUL-terminated Duane Griffin
[not found] ` <1229022995-9898-6-git-send-email-duaneg@dghda.com>
2008-12-11 22:26 ` [PATCH, v2] ext3: ensure link targets are NULL-terminated Duane Griffin
2008-12-12 3:32 ` Andrew Morton
2008-12-12 9:40 ` Duane Griffin
2008-12-12 10:19 ` Duane Griffin
2008-12-16 0:09 ` Andrew Morton
[not found] ` <1229022995-9898-7-git-send-email-duaneg@dghda.com>
2008-12-11 22:27 ` [PATCH, v2] ext4: ensure link targets are NUL-terminated Duane Griffin
[not found] ` <1229022995-9898-8-git-send-email-duaneg@dghda.com>
[not found] ` <1229022995-9898-9-git-send-email-duaneg@dghda.com>
2008-12-11 20:06 ` Dave Kleikamp [this message]
2008-12-11 20:34 ` [PATCH] JFS: ensure link targets are NULL-terminated Duane Griffin
[not found] ` <1229022995-9898-10-git-send-email-duaneg@dghda.com>
[not found] ` <1229022995-9898-11-git-send-email-duaneg@dghda.com>
2008-12-11 22:35 ` [PATCH, v2] sysv: ensure link targets are NUL-terminated Duane Griffin
2008-12-15 10:12 ` Al Viro
[not found] ` <1229022995-9898-12-git-send-email-duaneg@dghda.com>
2008-12-11 22:36 ` [PATCH, v2] ufs: " Duane Griffin
2008-12-14 21:12 ` Evgeniy Dushistov
2008-12-11 22:37 ` [PATCH, v2] freevxfs: " Duane Griffin
2008-12-11 19:32 ` [PATCH] eCryptfs: check readlink result was not an error before using it Michael Halcrow
2008-12-12 1:48 ` Tim Gardner
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=1229025971.9245.18.camel@norville.austin.ibm.com \
--to=shaggy@linux.vnet.ibm.com \
--cc=Dave.Kleikamp.shaggy@austin.ibm.com \
--cc=bharrosh@panasas.com \
--cc=duaneg@dghda.com \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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®