From: Brian Behlendorf <behlendorf1@llnl.gov>
To: Mark Nelson <mark.nelson@inktank.com>
Cc: Stefan Priebe <s.priebe@profihost.ag>,
Yehuda Sadeh <yehuda@inktank.com>, Sage Weil <sage@inktank.com>,
Jeff Mitchell <jeffrey.mitchell@gmail.com>,
Henry C Chang <henry.cy.chang@gmail.com>,
Aleksey Leonov <aleonov@nazarianin.com>,
ceph-devel <ceph-devel@vger.kernel.org>
Subject: Re: test osd on zfs
Date: Wed, 17 Apr 2013 14:14:38 -0700 [thread overview]
Message-ID: <516F10BE.6020103@llnl.gov> (raw)
In-Reply-To: <516F0321.2@inktank.com>
On 04/17/2013 01:16 PM, Mark Nelson wrote:
> I'll let Brian talk about the virtues of ZFS,
I think the virtues of ZFS have been discussed at length in various
other forums. But in short it brings some nice functionality to the
table which may be useful to ceph and that's worth exploring.
>>>>
>>>> diff --git a/module/zfs/zpl_xattr.c b/module/zfs/zpl_xattr.c
>>>> index c03764f..9f4d63c 100644
>>>> --- a/module/zfs/zpl_xattr.c
>>>> +++ b/module/zfs/zpl_xattr.c
>>>> @@ -225,6 +225,11 @@ zpl_xattr_get_dir(struct inode *ip, const char
>>>> *name,
>>>> void *value,
>>>> goto out;
>>>> }
>>>>
>>>> + if (size < i_size_read(xip)) {
>>>> + error = -ERANGE;
>>>> + goto out;
>>>> + }
>>>> +
>>>> error = zpl_read_common(xip, value, size, 0, UIO_SYSSPACE,
>>>> 0, cr);
>>>> out:
>>>> if (xip)
>>>> @@ -263,7 +268,10 @@ zpl_xattr_get_sa(struct inode *ip, const char
>>>> *name,
>>>> void *value, size_t size)
>>>> if (!size)
>>>> return (nv_size);
>>>>
>>>> - memcpy(value, nv_value, MIN(size, nv_size));
>>>>
>>>> + if (size < nv_size)
>>>> + return (-ERANGE);
>>>
>>> Note, that zpl_xattr_get_sa() is called by __zpl_xattr_get() which can
>>> also be called by zpl_xattr_get() to test for xattr existence. So it
>>> needs to make sure that zpl_xattr_set() doesn't fail if getting
>>> -ERANGE.
This shouldn't be a problem. The zpl_xattr_get() call from
zpl_xattr_set() passes a NULL value and zero size which will prevent it
from hitting the ERANGE error. It will return instead the xattr size as
expected.
>>>
>>>> +
>>>> + memcpy(value, nv_value, size);
>>>>
>>>> return (MIN(size, nv_size));
>>>
>>> No need for MIN() here.
Thanks for catching that.
I've opened a pull request at github with the updated fix and kicked it
off for automated testing. It would be nice to verify this resolves the
crash.
https://github.com/zfsonlinux/zfs/pull/1409
diff --git a/module/zfs/zpl_xattr.c b/module/zfs/zpl_xattr.c
index c03764f..42a06ad 100644
--- a/module/zfs/zpl_xattr.c
+++ b/module/zfs/zpl_xattr.c
@@ -225,6 +225,11 @@ zpl_xattr_get_dir(struct inode *ip, const char
*name, void
goto out;
}
+ if (size < i_size_read(xip)) {
+ error = -ERANGE;
+ goto out;
+ }
+
error = zpl_read_common(xip, value, size, 0, UIO_SYSSPACE, 0, cr);
out:
if (xip)
@@ -263,9 +268,12 @@ zpl_xattr_get_sa(struct inode *ip, const char
*name, void *
if (!size)
return (nv_size);
- memcpy(value, nv_value, MIN(size, nv_size));
+ if (size < nv_size)
+ return (-ERANGE);
+
+ memcpy(value, nv_value, size);
- return (MIN(size, nv_size));
+ return (size);
}
static int
next prev parent reply other threads:[~2013-04-17 21:14 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <516E7D5C.7080309@nazarianin.com>
2013-04-17 15:19 ` test osd on zfs Sage Weil
2013-04-17 15:57 ` Henry C Chang
2013-04-17 16:37 ` Jeff Mitchell
2013-04-17 17:00 ` Henry C Chang
2013-04-17 17:00 ` Sage Weil
2013-04-17 17:04 ` Yehuda Sadeh
2013-04-17 17:05 ` Sage Weil
2013-04-17 17:15 ` Yehuda Sadeh
2013-04-17 18:06 ` Brian Behlendorf
2013-04-17 18:57 ` Brian Behlendorf
2013-04-17 19:07 ` Yehuda Sadeh
2013-04-17 19:09 ` Stefan Priebe
2013-04-17 20:16 ` Mark Nelson
2013-04-17 20:49 ` Jeff Mitchell
2013-04-17 21:14 ` Brian Behlendorf [this message]
2013-04-18 2:20 ` Henry C Chang
2013-04-18 5:56 ` Stefan Priebe - Profihost AG
2013-04-18 14:50 ` Sage Weil
2013-04-18 20:07 ` Alex Elsayed
2013-04-19 10:47 ` Jeff Mitchell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=516F10BE.6020103@llnl.gov \
--to=behlendorf1@llnl.gov \
--cc=aleonov@nazarianin.com \
--cc=ceph-devel@vger.kernel.org \
--cc=henry.cy.chang@gmail.com \
--cc=jeffrey.mitchell@gmail.com \
--cc=mark.nelson@inktank.com \
--cc=s.priebe@profihost.ag \
--cc=sage@inktank.com \
--cc=yehuda@inktank.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.