Message ID | CABBk=J93+1TRnjtr5D2cJWmre+tf85hAw3H1JnOL8hwKJuHDJA@mail.gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
[Adding Brian to CC list again :)] On Wed, 17 Apr 2013, Yehuda Sadeh wrote: > On Wed, Apr 17, 2013 at 9:37 AM, Jeff Mitchell > <jeffrey.mitchell@gmail.com> wrote: > > Henry C Chang wrote: > >> > >> I looked into this problem earlier. The problem is that zfs does not > >> return ERANGE when the size of value buffer passed to getxattr is too > >> small. zfs returns with truncated xattr value. > > > > > > Is this a bug in ZFS, or simply different behavior? > > Took a brief look at the zfs code, seems like a zfs bug. > > diff --git a/module/zfs/zpl_xattr.c b/module/zfs/zpl_xattr.c > index c03764f..96db7dd 100644 > --- a/module/zfs/zpl_xattr.c > +++ b/module/zfs/zpl_xattr.c > @@ -263,6 +263,9 @@ zpl_xattr_get_sa(struct inode *ip, const char > *name, void *value, size_t size) > if (!size) > return (nv_size); > > + if (size < nv_size) > + return (-ERANGE); > + > memcpy(value, nv_value, MIN(size, nv_size)); > > return (MIN(size, nv_size)); > > > This should fix it. Not tested of course. > > Yehuda > -- > To unsubscribe from this list: send the line "unsubscribe ceph-devel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > > -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Apr 17, 2013 at 10:05 AM, Sage Weil <sage@inktank.com> wrote: > [Adding Brian to CC list again :)] > > On Wed, 17 Apr 2013, Yehuda Sadeh wrote: > >> On Wed, Apr 17, 2013 at 9:37 AM, Jeff Mitchell >> <jeffrey.mitchell@gmail.com> wrote: >> > Henry C Chang wrote: >> >> >> >> I looked into this problem earlier. The problem is that zfs does not >> >> return ERANGE when the size of value buffer passed to getxattr is too >> >> small. zfs returns with truncated xattr value. >> > >> > >> > Is this a bug in ZFS, or simply different behavior? >> >> Took a brief look at the zfs code, seems like a zfs bug. >> >> diff --git a/module/zfs/zpl_xattr.c b/module/zfs/zpl_xattr.c >> index c03764f..96db7dd 100644 >> --- a/module/zfs/zpl_xattr.c >> +++ b/module/zfs/zpl_xattr.c >> @@ -263,6 +263,9 @@ zpl_xattr_get_sa(struct inode *ip, const char >> *name, void *value, size_t size) >> if (!size) >> return (nv_size); >> >> + if (size < nv_size) >> + return (-ERANGE); >> + >> memcpy(value, nv_value, MIN(size, nv_size)); >> >> return (MIN(size, nv_size)); >> >> >> This should fix it. Not tested of course. Well, looking at the code again it's not going to work, as setxattr is going to fail with ERANGE. Yehuda -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 04/17/2013 10:15 AM, Yehuda Sadeh wrote: > On Wed, Apr 17, 2013 at 10:05 AM, Sage Weil <sage@inktank.com> wrote: >> [Adding Brian to CC list again :)] >> >> On Wed, 17 Apr 2013, Yehuda Sadeh wrote: >> >>> On Wed, Apr 17, 2013 at 9:37 AM, Jeff Mitchell >>> <jeffrey.mitchell@gmail.com> wrote: >>>> Henry C Chang wrote: >>>>> >>>>> I looked into this problem earlier. The problem is that zfs does not >>>>> return ERANGE when the size of value buffer passed to getxattr is too >>>>> small. zfs returns with truncated xattr value. >>>> >>>> >>>> Is this a bug in ZFS, or simply different behavior? >>> >>> Took a brief look at the zfs code, seems like a zfs bug. >>> >>> diff --git a/module/zfs/zpl_xattr.c b/module/zfs/zpl_xattr.c >>> index c03764f..96db7dd 100644 >>> --- a/module/zfs/zpl_xattr.c >>> +++ b/module/zfs/zpl_xattr.c >>> @@ -263,6 +263,9 @@ zpl_xattr_get_sa(struct inode *ip, const char >>> *name, void *value, size_t size) >>> if (!size) >>> return (nv_size); >>> >>> + if (size < nv_size) >>> + return (-ERANGE); >>> + >>> memcpy(value, nv_value, MIN(size, nv_size)); >>> >>> return (MIN(size, nv_size)); >>> >>> >>> This should fix it. Not tested of course. > > Well, looking at the code again it's not going to work, as setxattr is > going to fail with ERANGE. > > Yehuda > That does sounds like a zfs bug, According to getxattr(2) it should return ERANGE if the buffer is too small. I'll take a look but it's strange that this hasn't surfaced before. If the size of the value buffer is too small to hold the result, errno is set to ERANGE. Thanks, Brian -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/module/zfs/zpl_xattr.c b/module/zfs/zpl_xattr.c index c03764f..96db7dd 100644 --- a/module/zfs/zpl_xattr.c +++ b/module/zfs/zpl_xattr.c @@ -263,6 +263,9 @@ zpl_xattr_get_sa(struct inode *ip, const char *name, void *value, size_t size) if (!size) return (nv_size); + if (size < nv_size) + return (-ERANGE); + memcpy(value, nv_value, MIN(size, nv_size));