diff options
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/ocfs2.h | 3 | ||||
-rw-r--r-- | fs/ocfs2/xattr.c | 38 |
2 files changed, 19 insertions, 22 deletions
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h index a21a465490c4..fef7ece32376 100644 --- a/fs/ocfs2/ocfs2.h +++ b/fs/ocfs2/ocfs2.h | |||
@@ -473,6 +473,9 @@ static inline int ocfs2_uses_extended_slot_map(struct ocfs2_super *osb) | |||
473 | (____gd)->bg_signature); \ | 473 | (____gd)->bg_signature); \ |
474 | } while (0) | 474 | } while (0) |
475 | 475 | ||
476 | #define OCFS2_IS_VALID_XATTR_BLOCK(ptr) \ | ||
477 | (!strcmp((ptr)->xb_signature, OCFS2_XATTR_BLOCK_SIGNATURE)) | ||
478 | |||
476 | static inline unsigned long ino_from_blkno(struct super_block *sb, | 479 | static inline unsigned long ino_from_blkno(struct super_block *sb, |
477 | u64 blkno) | 480 | u64 blkno) |
478 | { | 481 | { |
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, | |||
555 | mlog_errno(ret); | 555 | mlog_errno(ret); |
556 | return ret; | 556 | return ret; |
557 | } | 557 | } |
558 | /*Verify the signature of xattr block*/ | ||
559 | if (memcmp((void *)blk_bh->b_data, OCFS2_XATTR_BLOCK_SIGNATURE, | ||
560 | strlen(OCFS2_XATTR_BLOCK_SIGNATURE))) { | ||
561 | ret = -EFAULT; | ||
562 | goto cleanup; | ||
563 | } | ||
564 | 558 | ||
565 | xb = (struct ocfs2_xattr_block *)blk_bh->b_data; | 559 | xb = (struct ocfs2_xattr_block *)blk_bh->b_data; |
560 | if (!OCFS2_IS_VALID_XATTR_BLOCK(xb)) { | ||
561 | ret = -EIO; | ||
562 | goto cleanup; | ||
563 | } | ||
566 | 564 | ||
567 | if (!(le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED)) { | 565 | if (!(le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED)) { |
568 | struct ocfs2_xattr_header *header = &xb->xb_attrs.xb_header; | 566 | struct ocfs2_xattr_header *header = &xb->xb_attrs.xb_header; |
@@ -779,15 +777,14 @@ static int ocfs2_xattr_block_get(struct inode *inode, | |||
779 | mlog_errno(ret); | 777 | mlog_errno(ret); |
780 | return ret; | 778 | return ret; |
781 | } | 779 | } |
782 | /*Verify the signature of xattr block*/ | 780 | |
783 | if (memcmp((void *)blk_bh->b_data, OCFS2_XATTR_BLOCK_SIGNATURE, | 781 | xb = (struct ocfs2_xattr_block *)blk_bh->b_data; |
784 | strlen(OCFS2_XATTR_BLOCK_SIGNATURE))) { | 782 | if (!OCFS2_IS_VALID_XATTR_BLOCK(xb)) { |
785 | ret = -EFAULT; | 783 | ret = -EIO; |
786 | goto cleanup; | 784 | goto cleanup; |
787 | } | 785 | } |
788 | 786 | ||
789 | xs->xattr_bh = blk_bh; | 787 | xs->xattr_bh = blk_bh; |
790 | xb = (struct ocfs2_xattr_block *)blk_bh->b_data; | ||
791 | 788 | ||
792 | if (!(le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED)) { | 789 | if (!(le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED)) { |
793 | xs->header = &xb->xb_attrs.xb_header; | 790 | xs->header = &xb->xb_attrs.xb_header; |
@@ -1527,10 +1524,9 @@ static int ocfs2_xattr_free_block(struct inode *inode, | |||
1527 | goto out; | 1524 | goto out; |
1528 | } | 1525 | } |
1529 | 1526 | ||
1530 | /*Verify the signature of xattr block*/ | 1527 | xb = (struct ocfs2_xattr_block *)blk_bh->b_data; |
1531 | if (memcmp((void *)blk_bh->b_data, OCFS2_XATTR_BLOCK_SIGNATURE, | 1528 | if (!OCFS2_IS_VALID_XATTR_BLOCK(xb)) { |
1532 | strlen(OCFS2_XATTR_BLOCK_SIGNATURE))) { | 1529 | ret = -EIO; |
1533 | ret = -EFAULT; | ||
1534 | goto out; | 1530 | goto out; |
1535 | } | 1531 | } |
1536 | 1532 | ||
@@ -1540,7 +1536,6 @@ static int ocfs2_xattr_free_block(struct inode *inode, | |||
1540 | goto out; | 1536 | goto out; |
1541 | } | 1537 | } |
1542 | 1538 | ||
1543 | xb = (struct ocfs2_xattr_block *)blk_bh->b_data; | ||
1544 | blk = le64_to_cpu(xb->xb_blkno); | 1539 | blk = le64_to_cpu(xb->xb_blkno); |
1545 | bit = le16_to_cpu(xb->xb_suballoc_bit); | 1540 | bit = le16_to_cpu(xb->xb_suballoc_bit); |
1546 | bg_blkno = ocfs2_which_suballoc_group(blk, bit); | 1541 | bg_blkno = ocfs2_which_suballoc_group(blk, bit); |
@@ -1784,15 +1779,14 @@ static int ocfs2_xattr_block_find(struct inode *inode, | |||
1784 | mlog_errno(ret); | 1779 | mlog_errno(ret); |
1785 | return ret; | 1780 | return ret; |
1786 | } | 1781 | } |
1787 | /*Verify the signature of xattr block*/ | 1782 | |
1788 | if (memcmp((void *)blk_bh->b_data, OCFS2_XATTR_BLOCK_SIGNATURE, | 1783 | xb = (struct ocfs2_xattr_block *)blk_bh->b_data; |
1789 | strlen(OCFS2_XATTR_BLOCK_SIGNATURE))) { | 1784 | if (!OCFS2_IS_VALID_XATTR_BLOCK(xb)) { |
1790 | ret = -EFAULT; | 1785 | ret = -EIO; |
1791 | goto cleanup; | 1786 | goto cleanup; |
1792 | } | 1787 | } |
1793 | 1788 | ||
1794 | xs->xattr_bh = blk_bh; | 1789 | xs->xattr_bh = blk_bh; |
1795 | xb = (struct ocfs2_xattr_block *)blk_bh->b_data; | ||
1796 | 1790 | ||
1797 | if (!(le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED)) { | 1791 | if (!(le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED)) { |
1798 | xs->header = &xb->xb_attrs.xb_header; | 1792 | xs->header = &xb->xb_attrs.xb_header; |