aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2013-04-30 07:39:35 -0400
committerBen Myers <bpm@sgi.com>2013-05-01 15:13:55 -0400
commit946217ba28637d7a08e03e93ef40586ce621f557 (patch)
tree5939657206b29c7678a347a3a13ea4880a1d4f82
parent123887e8433e58ebbcc4c91491d8b8cde31d6d79 (diff)
xfs: Remote attr validation fixes and optimisations
- optimise the calcuation for the number of blocks in a remote xattr. - check attribute length against MAX_XATTR_SIZE, not MAXPATHLEN - whitespace fixes Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Ben Myers <bpm@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
-rw-r--r--fs/xfs/xfs_attr_remote.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/fs/xfs/xfs_attr_remote.c b/fs/xfs/xfs_attr_remote.c
index 53da46b46c2f..dee84466dcc9 100644
--- a/fs/xfs/xfs_attr_remote.c
+++ b/fs/xfs/xfs_attr_remote.c
@@ -52,15 +52,9 @@ xfs_attr3_rmt_blocks(
52 struct xfs_mount *mp, 52 struct xfs_mount *mp,
53 int attrlen) 53 int attrlen)
54{ 54{
55 int fsblocks = 0; 55 int buflen = XFS_ATTR3_RMT_BUF_SPACE(mp,
56 int len = attrlen; 56 mp->m_sb.sb_blocksize);
57 57 return (attrlen + buflen - 1) / buflen;
58 do {
59 fsblocks++;
60 len -= XFS_ATTR3_RMT_BUF_SPACE(mp, mp->m_sb.sb_blocksize);
61 } while (len > 0);
62
63 return fsblocks;
64} 58}
65 59
66static bool 60static bool
@@ -79,7 +73,7 @@ xfs_attr3_rmt_verify(
79 if (bp->b_bn != be64_to_cpu(rmt->rm_blkno)) 73 if (bp->b_bn != be64_to_cpu(rmt->rm_blkno))
80 return false; 74 return false;
81 if (be32_to_cpu(rmt->rm_offset) + 75 if (be32_to_cpu(rmt->rm_offset) +
82 be32_to_cpu(rmt->rm_bytes) >= MAXPATHLEN) 76 be32_to_cpu(rmt->rm_bytes) >= XATTR_SIZE_MAX)
83 return false; 77 return false;
84 if (rmt->rm_owner == 0) 78 if (rmt->rm_owner == 0)
85 return false; 79 return false;
@@ -183,7 +177,6 @@ xfs_attr3_rmt_hdr_ok(
183 177
184 /* ok */ 178 /* ok */
185 return true; 179 return true;
186
187} 180}
188 181
189/* 182/*
@@ -367,7 +360,6 @@ xfs_attr_rmtval_set(
367 * spill for another block every 9 headers we require in this 360 * spill for another block every 9 headers we require in this
368 * loop. 361 * loop.
369 */ 362 */
370
371 if (crcs && blkcnt == 0) { 363 if (crcs && blkcnt == 0) {
372 int total_len; 364 int total_len;
373 365
@@ -422,9 +414,8 @@ xfs_attr_rmtval_set(
422 414
423 byte_cnt = BBTOB(bp->b_length); 415 byte_cnt = BBTOB(bp->b_length);
424 byte_cnt = XFS_ATTR3_RMT_BUF_SPACE(mp, byte_cnt); 416 byte_cnt = XFS_ATTR3_RMT_BUF_SPACE(mp, byte_cnt);
425 if (valuelen < byte_cnt) { 417 if (valuelen < byte_cnt)
426 byte_cnt = valuelen; 418 byte_cnt = valuelen;
427 }
428 419
429 buf = bp->b_addr; 420 buf = bp->b_addr;
430 buf += xfs_attr3_rmt_hdr_set(mp, dp->i_ino, offset, 421 buf += xfs_attr3_rmt_hdr_set(mp, dp->i_ino, offset,