ocfs2: Use xs->bucket to set xattr value outside

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Saturday, March 14, 2009 - 1:00 pm

Gitweb:     http://git.kernel.org/linus/712e53e46a1da35fcd88c05aa0c675b10f7c0e9d
Commit:     712e53e46a1da35fcd88c05aa0c675b10f7c0e9d
Parent:     74e77eb30d0ecbb12964d005b439c8b84a505b84
Author:     Tao Ma <tao.ma@oracle.com>
AuthorDate: Thu Mar 12 08:37:34 2009 +0800
Committer:  Mark Fasheh <mfasheh@suse.com>
CommitDate: Thu Mar 12 16:46:09 2009 -0700

    ocfs2: Use xs->bucket to set xattr value outside
    
    A long time ago, xs->base is allocated a 4K size and all the contents
    in the bucket are copied to the it. Now we use ocfs2_xattr_bucket to
    abstract xattr bucket and xs->base is initialized to the start of the
    bu_bhs[0]. So xs->base + offset will overflow when the value root is
    stored outside the first block.
    
    Then why we can survive the xattr test by now? It is because we always
    read the bucket contiguously now and kernel mm allocate continguous
    memory for us. We are lucky, but we should fix it. So just get the
    right value root as other callers do.
    
    Signed-off-by: Tao Ma <tao.ma@oracle.com>
    Acked-by: Joel Becker <joel.becker@oracle.com>
    Signed-off-by: Mark Fasheh <mfasheh@suse.com>
---
 fs/ocfs2/xattr.c |   26 ++++++++++++++++++++------
 1 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index c63efb5..2563df8 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -4795,19 +4795,33 @@ static int ocfs2_xattr_bucket_set_value_outside(struct inode *inode,
 						char *val,
 						int value_len)
 {
-	int offset;
+	int ret, offset, block_off;
 	struct ocfs2_xattr_value_root *xv;
 	struct ocfs2_xattr_entry *xe = xs->here;
+	struct ocfs2_xattr_header *xh = bucket_xh(xs->bucket);
+	void *base;
 
 	BUG_ON(!xs->base || !xe || ocfs2_xattr_is_local(xe));
 
-	offset = le16_to_cpu(xe->xe_name_offset) +
-		 OCFS2_XATTR_SIZE(xe->xe_name_len);
+	ret = ocfs2_xattr_bucket_get_name_value(inode, xh,
+						xe - xh->xh_entries,
+						&block_off,
+						&offset);
+	if (ret) {
+		mlog_errno(ret);
+		goto out;
+	}
 
-	xv = (struct ocfs2_xattr_value_root *)(xs->base + offset);
+	base = bucket_block(xs->bucket, block_off);
+	xv = (struct ocfs2_xattr_value_root *)(base + offset +
+		 OCFS2_XATTR_SIZE(xe->xe_name_len));
 
-	return __ocfs2_xattr_set_value_outside(inode, handle,
-					       xv, val, value_len);
+	ret = __ocfs2_xattr_set_value_outside(inode, handle,
+					      xv, val, value_len);
+	if (ret)
+		mlog_errno(ret);
+out:
+	return ret;
 }
 
 static int ocfs2_rm_xattr_cluster(struct inode *inode,
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
ocfs2: Use xs->bucket to set xattr value outside, Linux Kernel Mailing ..., (Sat Mar 14, 1:00 pm)