aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph/xattr.c
diff options
context:
space:
mode:
authorAlex Elder <elder@dreamhost.com>2012-03-08 17:50:09 -0500
committerAlex Elder <elder@dreamhost.com>2012-03-22 11:47:52 -0400
commit3489b42a72a41d477665ab37f196ae9257180abb (patch)
treef90c349a10cb7ca6c1c2da5d141324c636817d33 /fs/ceph/xattr.c
parent8d63e318c4eb1bea6f7e3cb4b77849eaa167bfec (diff)
ceph: fix three bugs, two in ceph_vxattrcb_file_layout()
In ceph_vxattrcb_file_layout(), there is a check to determine whether a preferred PG should be formatted into the output buffer. That check assumes that a preferred PG number of 0 indicates "no preference," but that is wrong. No preference is indicated by a negative (specifically, -1) PG number. In addition, if that condition yields true, the preferred value is formatted into a sized buffer, but the size consumed by the earlier snprintf() call is not accounted for, opening up the possibilty of a buffer overrun. Finally, in ceph_vxattrcb_dir_rctime() where the nanoseconds part of the time displayed did not include leading 0's, which led to erroneous (sub-second portion of) time values being shown. This fixes these three issues: http://tracker.newdream.net/issues/2155 http://tracker.newdream.net/issues/2156 http://tracker.newdream.net/issues/2157 Signed-off-by: Alex Elder <elder@dreamhost.com> Reviewed-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/xattr.c')
-rw-r--r--fs/ceph/xattr.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index 8294f461ecd1..35b86331d8a5 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -79,7 +79,7 @@ static size_t ceph_vxattrcb_dir_rbytes(struct ceph_inode_info *ci, char *val,
79static size_t ceph_vxattrcb_dir_rctime(struct ceph_inode_info *ci, char *val, 79static size_t ceph_vxattrcb_dir_rctime(struct ceph_inode_info *ci, char *val,
80 size_t size) 80 size_t size)
81{ 81{
82 return snprintf(val, size, "%ld.%ld", (long)ci->i_rctime.tv_sec, 82 return snprintf(val, size, "%ld.09%ld", (long)ci->i_rctime.tv_sec,
83 (long)ci->i_rctime.tv_nsec); 83 (long)ci->i_rctime.tv_nsec);
84} 84}
85 85
@@ -118,10 +118,15 @@ static size_t ceph_vxattrcb_file_layout(struct ceph_inode_info *ci, char *val,
118 (unsigned long long)ceph_file_layout_su(ci->i_layout), 118 (unsigned long long)ceph_file_layout_su(ci->i_layout),
119 (unsigned long long)ceph_file_layout_stripe_count(ci->i_layout), 119 (unsigned long long)ceph_file_layout_stripe_count(ci->i_layout),
120 (unsigned long long)ceph_file_layout_object_size(ci->i_layout)); 120 (unsigned long long)ceph_file_layout_object_size(ci->i_layout));
121 if (ceph_file_layout_pg_preferred(ci->i_layout)) 121
122 ret += snprintf(val + ret, size, "preferred_osd=%lld\n", 122 if (ceph_file_layout_pg_preferred(ci->i_layout) >= 0) {
123 val += ret;
124 size -= ret;
125 ret += snprintf(val, size, "preferred_osd=%lld\n",
123 (unsigned long long)ceph_file_layout_pg_preferred( 126 (unsigned long long)ceph_file_layout_pg_preferred(
124 ci->i_layout)); 127 ci->i_layout));
128 }
129
125 return ret; 130 return ret;
126} 131}
127 132