From: Alex Elder <elder@inktank.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 6/6] rbd: use rbd_obj_method_sync() return value
Date: Fri, 26 Apr 2013 07:06:56 -0500 [thread overview]
Message-ID: <517A6DE0.5080305@inktank.com> (raw)
In-Reply-To: <517A6D39.80000@inktank.com>
Now that rbd_obj_method_sync() returns the number of bytes
returned by the method call, that value should be used by
callers to ensure we don't overrun the valid portion of the
buffer.
Fix the two spots that remained that weren't doing that,
rbd_dev_image_name() and rbd_dev_v2_snap_name().
Rearrange the error path slightly in rbd_dev_v2_snap_name().
Signed-off-by: Alex Elder <elder@inktank.com>
---
drivers/block/rbd.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 2b5ba50..dcd8e58 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -2614,7 +2614,8 @@ out_cancel:
}
/*
- * Synchronous osd object method call
+ * Synchronous osd object method call. Returns the number of bytes
+ * returned in the outbound buffer, or a negative error code.
*/
static int rbd_obj_method_sync(struct rbd_device *rbd_dev,
const char *object_name,
@@ -3740,7 +3741,8 @@ static char *rbd_dev_image_name(struct rbd_device
*rbd_dev)
if (ret < 0)
goto out;
p = reply_buf;
- end = reply_buf + size;
+ end = reply_buf + ret;
+
image_name = ceph_extract_encoded_string(&p, end, &len, GFP_KERNEL);
if (IS_ERR(image_name))
image_name = NULL;
@@ -3913,26 +3915,23 @@ static char *rbd_dev_v2_snap_name(struct
rbd_device *rbd_dev, u32 which)
&snap_id, sizeof (snap_id),
reply_buf, size, NULL);
dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret);
- if (ret < 0)
+ if (ret < 0) {
+ snap_name = ERR_PTR(ret);
goto out;
+ }
p = reply_buf;
- end = reply_buf + size;
+ end = reply_buf + ret;
snap_name = ceph_extract_encoded_string(&p, end, NULL, GFP_KERNEL);
- if (IS_ERR(snap_name)) {
- ret = PTR_ERR(snap_name);
+ if (IS_ERR(snap_name))
goto out;
- } else {
- dout(" snap_id 0x%016llx snap_name = %s\n",
- (unsigned long long)le64_to_cpu(snap_id), snap_name);
- }
- kfree(reply_buf);
- return snap_name;
+ dout(" snap_id 0x%016llx snap_name = %s\n",
+ (unsigned long long)le64_to_cpu(snap_id), snap_name);
out:
kfree(reply_buf);
- return ERR_PTR(ret);
+ return snap_name;
}
static char *rbd_dev_v2_snap_info(struct rbd_device *rbd_dev, u32 which,
--
1.7.9.5
next prev parent reply other threads:[~2013-04-26 12:06 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-26 12:04 [PATCH 0/6] rbd: cleanup and plug leaks Alex Elder
2013-04-26 12:05 ` [PATCH 1/6] rbd: fix leak of snapshots during initial probe Alex Elder
2013-04-29 15:12 ` Josh Durgin
2013-04-26 12:05 ` [PATCH 2/6] rbd: make snap_size order parameter optional Alex Elder
2013-04-29 15:14 ` Josh Durgin
2013-04-26 12:06 ` [PATCH 3/6] rbd: only update values on snap_info success Alex Elder
2013-04-29 15:15 ` Josh Durgin
2013-04-26 12:06 ` [PATCH 4/6] rbd: rename __rbd_add_snap_dev() Alex Elder
2013-04-29 15:15 ` Josh Durgin
2013-04-26 12:06 ` [PATCH 5/6] rbd: fix leak of format 2 snapshot names Alex Elder
2013-04-26 17:40 ` [PATCH 5/6, v2] " Alex Elder
2013-04-29 15:16 ` [PATCH 5/6] " Josh Durgin
2013-04-29 15:18 ` Josh Durgin
2013-04-26 12:06 ` Alex Elder [this message]
2013-04-29 15:22 ` [PATCH 6/6] rbd: use rbd_obj_method_sync() return value Josh Durgin
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=517A6DE0.5080305@inktank.com \
--to=elder@inktank.com \
--cc=ceph-devel@vger.kernel.org \
/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.