summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2018-07-12 19:43:01 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2018-07-14 18:56:46 -0400
commitf6b4e6b11e12b4395587b3918ca2d6c385beeb94 (patch)
tree61e95c46bfd7a064397734decbd62b493c690fe8
parent940d6ca657ea70758f3f43323bfd531019a40d3c (diff)
bcachefs: work around an older xattr bug
similar to the dirent bug - making struct bch_dirent and bch_xattr 8 byte aligned changed sizeof, and size calculations that used sizeof(bch_xattr)/sizeof(bch_dirent) wrong
-rw-r--r--fs/bcachefs/xattr.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/fs/bcachefs/xattr.c b/fs/bcachefs/xattr.c
index c6b5015a0087..8eb1b1703e7e 100644
--- a/fs/bcachefs/xattr.c
+++ b/fs/bcachefs/xattr.c
@@ -74,7 +74,6 @@ const char *bch2_xattr_invalid(const struct bch_fs *c, struct bkey_s_c k)
{
const struct xattr_handler *handler;
struct bkey_s_c_xattr xattr;
- unsigned u64s;
switch (k.k->type) {
case BCH_XATTR:
@@ -82,13 +81,15 @@ const char *bch2_xattr_invalid(const struct bch_fs *c, struct bkey_s_c k)
return "value too small";
xattr = bkey_s_c_to_xattr(k);
- u64s = xattr_val_u64s(xattr.v->x_name_len,
- le16_to_cpu(xattr.v->x_val_len));
- if (bkey_val_u64s(k.k) < u64s)
+ if (bkey_val_u64s(k.k) <
+ xattr_val_u64s(xattr.v->x_name_len,
+ le16_to_cpu(xattr.v->x_val_len)))
return "value too small";
- if (bkey_val_u64s(k.k) > u64s)
+ if (bkey_val_u64s(k.k) >
+ xattr_val_u64s(xattr.v->x_name_len,
+ le16_to_cpu(xattr.v->x_val_len) + 4))
return "value too big";
handler = bch2_xattr_type_to_handler(xattr.v->x_type);