aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/xattr.c
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-10-20 18:20:43 -0700
committerMark Fasheh <mfasheh@suse.com>2008-11-10 09:51:44 -0800
commitf6087fb799e097e7c9d912daa75701de9d62dc53 (patch)
tree010e8455fa5e53e68c76b949b4abd39876c2921f /fs/ocfs2/xattr.c
parentocfs2: add handler_map array bounds checking (diff)
downloadlinux-dev-f6087fb799e097e7c9d912daa75701de9d62dc53.tar.xz
linux-dev-f6087fb799e097e7c9d912daa75701de9d62dc53.zip
ocfs2: Check xattr block signatures properly.
The xattr.c code is currently memcmp()ing naking buffer pointers. Create the OCFS2_IS_VALID_XATTR_BLOCK() macro to match its peers and use that. In addition, failed signature checks were returning -EFAULT, which is completely wrong. Return -EIO. Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/xattr.c')
-rw-r--r--fs/ocfs2/xattr.c38
1 files changed, 16 insertions, 22 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index e19980a71a3c..151ba6257fbb 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -555,14 +555,12 @@ static int ocfs2_xattr_block_list(struct inode *inode,
mlog_errno(ret);
return ret;
}
- /*Verify the signature of xattr block*/
- if (memcmp((void *)blk_bh->b_data, OCFS2_XATTR_BLOCK_SIGNATURE,
- strlen(OCFS2_XATTR_BLOCK_SIGNATURE))) {
- ret = -EFAULT;
- goto cleanup;
- }
xb = (struct ocfs2_xattr_block *)blk_bh->b_data;
+ if (!OCFS2_IS_VALID_XATTR_BLOCK(xb)) {
+ ret = -EIO;
+ goto cleanup;
+ }
if (!(le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED)) {
struct ocfs2_xattr_header *header = &xb->xb_attrs.xb_header;
@@ -779,15 +777,14 @@ static int ocfs2_xattr_block_get(struct inode *inode,
mlog_errno(ret);
return ret;
}
- /*Verify the signature of xattr block*/
- if (memcmp((void *)blk_bh->b_data, OCFS2_XATTR_BLOCK_SIGNATURE,
- strlen(OCFS2_XATTR_BLOCK_SIGNATURE))) {
- ret = -EFAULT;
+
+ xb = (struct ocfs2_xattr_block *)blk_bh->b_data;
+ if (!OCFS2_IS_VALID_XATTR_BLOCK(xb)) {
+ ret = -EIO;
goto cleanup;
}
xs->xattr_bh = blk_bh;
- xb = (struct ocfs2_xattr_block *)blk_bh->b_data;
if (!(le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED)) {
xs->header = &xb->xb_attrs.xb_header;
@@ -1527,10 +1524,9 @@ static int ocfs2_xattr_free_block(struct inode *inode,
goto out;
}
- /*Verify the signature of xattr block*/
- if (memcmp((void *)blk_bh->b_data, OCFS2_XATTR_BLOCK_SIGNATURE,
- strlen(OCFS2_XATTR_BLOCK_SIGNATURE))) {
- ret = -EFAULT;
+ xb = (struct ocfs2_xattr_block *)blk_bh->b_data;
+ if (!OCFS2_IS_VALID_XATTR_BLOCK(xb)) {
+ ret = -EIO;
goto out;
}
@@ -1540,7 +1536,6 @@ static int ocfs2_xattr_free_block(struct inode *inode,
goto out;
}
- xb = (struct ocfs2_xattr_block *)blk_bh->b_data;
blk = le64_to_cpu(xb->xb_blkno);
bit = le16_to_cpu(xb->xb_suballoc_bit);
bg_blkno = ocfs2_which_suballoc_group(blk, bit);
@@ -1784,15 +1779,14 @@ static int ocfs2_xattr_block_find(struct inode *inode,
mlog_errno(ret);
return ret;
}
- /*Verify the signature of xattr block*/
- if (memcmp((void *)blk_bh->b_data, OCFS2_XATTR_BLOCK_SIGNATURE,
- strlen(OCFS2_XATTR_BLOCK_SIGNATURE))) {
- ret = -EFAULT;
- goto cleanup;
+
+ xb = (struct ocfs2_xattr_block *)blk_bh->b_data;
+ if (!OCFS2_IS_VALID_XATTR_BLOCK(xb)) {
+ ret = -EIO;
+ goto cleanup;
}
xs->xattr_bh = blk_bh;
- xb = (struct ocfs2_xattr_block *)blk_bh->b_data;
if (!(le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED)) {
xs->header = &xb->xb_attrs.xb_header;