[ 3.5.yuz extended stable ] Patch "libceph: (re)initialize bio_iter on start of message" has been added to staging queue

Herton Ronaldo Krzesinski herton.krzesinski at canonical.com
Tue Nov 20 17:18:13 UTC 2012

This is a note to let you know that I have just added a patch titled

    libceph: (re)initialize bio_iter on start of message

to the linux-3.5.y-queue branch of the 3.5.yuz extended stable tree 
which can be found at:


If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.5.yuz tree, see



>From 6846d455196d0d94f80e0b3c0175916d36c1d4d9 Mon Sep 17 00:00:00 2001
From: Sage Weil <sage at inktank.com>
Date: Mon, 30 Jul 2012 16:20:25 -0700
Subject: [PATCH 51/78] libceph: (re)initialize bio_iter on start of message

commit a4107026976f06c9a6ce8cc84a763564ee39d901 upstream.

Previously, we were opportunistically initializing the bio_iter if it
appeared to be uninitialized in the middle of the read path.  The problem
is that a sequence like:

 - start reading message
 - initialize bio_iter
 - read half a message
 - messenger fault, reconnect
 - restart reading message
 - ** bio_iter now non-NULL, not reinitialized **
 - read past end of bio, crash

Instead, initialize the bio_iter unconditionally when we allocate/claim
the message for read.

Signed-off-by: Sage Weil <sage at inktank.com>
Reviewed-by: Alex Elder <elder at inktank.com>
Reviewed-by: Yehuda Sadeh <yehuda at inktank.com>
Signed-off-by: Herton Ronaldo Krzesinski <herton.krzesinski at canonical.com>
 net/ceph/messenger.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index e65b15d..f1bd3bb 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -1872,6 +1872,11 @@ static int read_partial_message(struct ceph_connection *con)
 			con->in_msg_pos.page_pos = 0;
 		con->in_msg_pos.data_pos = 0;
+		if (m->bio)
+			init_bio_iter(m->bio, &m->bio_iter, &m->bio_seg);

 	/* front */
@@ -1888,10 +1893,6 @@ static int read_partial_message(struct ceph_connection *con)
 		if (ret <= 0)
 			return ret;
-	if (m->bio && !m->bio_iter)
-		init_bio_iter(m->bio, &m->bio_iter, &m->bio_seg);

 	/* (page) data */
 	while (con->in_msg_pos.data_pos < data_len) {
@@ -1902,7 +1903,7 @@ static int read_partial_message(struct ceph_connection *con)
 				return ret;
 		} else if (m->bio) {
+			BUG_ON(!m->bio_iter);
 			ret = read_partial_message_bio(con,
 						 &m->bio_iter, &m->bio_seg,
 						 data_len, do_datacrc);

More information about the kernel-team mailing list